ffmpeg时间基种类及转换
一、ffmpeg中時(shí)間基相關(guān)數(shù)據(jù)結(jié)構(gòu):
typedef struct AVRational{
int num; ///< numerator
int den; ///< denominator
} AVRational;
二、時(shí)間基有如下幾種:
不同時(shí)間基單位:
1、InputStream: 時(shí)間基 1:1000000(單位:us)
2、AVStream:時(shí)間基 1:90000(單位:s)- 根據(jù)mpeg的協(xié)議,壓縮后或解壓前的數(shù)據(jù),pts和dts是90kHz時(shí)鐘的采樣值
3、AVCodecContext:時(shí)間基 1:framerate (單位:s)
不同結(jié)構(gòu)使用的時(shí)間基種類:
1、AVPacket:使用AVStream時(shí)間基
2、AVFrame:pts使用AVCodecContext時(shí)間基;pkt_pts、pkt_dts使用AVStream時(shí)間基
3、InputStream:使用InputStream時(shí)間基
四、時(shí)間基轉(zhuǎn)換函數(shù)
1、
? int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const;? 其中:a為待轉(zhuǎn)換時(shí)間;bq為待轉(zhuǎn)換時(shí)間依賴的時(shí)間基;cq為目標(biāo)時(shí)間基。
? 上述公式等同于:
a * bq / cq2、
void av_packet_rescale_ts(AVPacket *pkt, AVRational tb_src, AVRational tb_dst);? 其中:pkt為編碼后數(shù)據(jù)包;src為原始時(shí)間基;dst為目標(biāo)時(shí)間基
五、時(shí)間基擴(kuò)展
AVFrame->pts和AVPacket->pts、AVPacket->dts的值,在解碼/編碼后,會(huì)經(jīng)歷短暫的time_base不匹配的情況:
1、解碼后,decoded_frame->pts的值使用AVStream->time_base為單位,后在AVFilter里面轉(zhuǎn)換成以AVCodecContext->time_base為單位。
2、編碼后,pkt.pts、pkt.dts使用AVCodecContext->time_base為單位,后通過調(diào)用"av_packet_rescale_ts"轉(zhuǎn)換為AVStream->time_base為單位。
https://blog.csdn.net/DONGHONGBAI/article/details/82775588
總結(jié)
以上是生活随笔為你收集整理的ffmpeg时间基种类及转换的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux之用户态和内核态
- 下一篇: int printf(const cha