转http://blog.youkuaiyun.com/supermanwg/article/details/14521869
FFMPEG的很多结构中有AVRational time_base;这样的一个成员,它是AVRational结构的
typedef struct AVRational{
int num; ///< numerator
int den; ///< denominator
} AVRational;
AVRational这个结构标识一个分数,num为分数,den为分母。
实际上time_base的意思就是时间的刻度:
如(1,25),那么时间刻度就是1/25
(1,9000),那么时间刻度就是1/90000
那么,在刻度为1/25的体系下的time=5,转换成在刻度为1/90000体系下的时间time为(5*1/25)/(1/90000) = 3600*5=18000
ffmpeg中做pts计算时,存在大量这种转换
在以下结构中都有
AVCodecContext:编解码上下文。
AVStream:文件或其它容器中的某一个track。
如果由某个解码器产生固定帧率的码流
AVCodecContext中的AVRational根据帧率来设定,如25帧,那么num = 1,den=25
AVStream中的time_base一般根据其采样频率设定,如(1,9000