ffmpeg 时间戳
轉(zhuǎn)http://blog.csdn.net/yfh1985sdq/article/details/5721953
AVpacket里的時(shí)間戳pts和dts.單位好像是us.
問 : 時(shí)間戳pts和dts,這里兩個(gè)時(shí)間戳各有什么意義?
答 : 顯示時(shí)間,解碼時(shí)間. DTS:decoding time stamp PTS:presentation time stamp Generally the PTS and DTS will only differ when the stream we are playing has B frames in it.
問 : 在 VLC 中調(diào)用 avcodec_decode_video() 函數(shù)進(jìn)行解碼時(shí),AVFrame->pts 時(shí)間戳不對,導(dǎo)致我的圖像不能夠顯示? 請問有誰知道它的解碼原理,這個(gè) PTS 怎么得出的嗎?還是外部傳入的?
答 : AVFrame 上的時(shí)間戳是用戶事件戳 是用戶打上去的,就是你的程序。 PTS 是在包AVPacket上 顯示時(shí)間戳是在 影片被encode的時(shí)候打上的。。編碼器 會做這部分工作。 在play back 的時(shí)候會根據(jù)這個(gè)時(shí)間 調(diào)整播放進(jìn)度。 我貼下 VLC 的代碼,
(vlc-0.9.8a/modules/codec/avcodec/video.c 文件中)
i_used = avcodec_decode_video( p_sys->p_context, p_sys->p_ff_pic, &b_gotpicture, p_sys->i_buffer <= 0 && p_sys->b_flush ? NULL : (uint8_t*)p_sys->p_buffer, p_sys- >i_buffer );
中間省略 取得 PTS ,
if( p_sys->p_ff_pic->pts ) {
printf(" p_sys->p_ff_pic->pts = %Lx/n", p_sys->p_ff_pic->pts); p_sys->i_pts = p_sys->p_ff_pic->pts;
}
從 AVFrame 結(jié)構(gòu)中取得 這個(gè) PTS ,但是這個(gè) AVFrame 結(jié)構(gòu)中取得 這個(gè) PTS 從哪里取得的呢? 你的問題解決沒有,我現(xiàn)在也是這個(gè)問題,AVFrame->pts 時(shí)間戳不對,只有第一幀能顯示,其他的都不能顯示
轉(zhuǎn)載于:https://www.cnblogs.com/littlejohnny/p/3487215.html
總結(jié)
以上是生活随笔為你收集整理的ffmpeg 时间戳的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: js之定时器
- 下一篇: cpu卡操作协议iso14443协议