时间基的作用
源码来自ffmpeg5.1。
时间基在ffmpeg中是通过数据结构有理数AVRational描述的。时间基为时间戳的单位,比如时间基tbn(AVStream.time_base)=0.001秒,AVPacket的pts=40,则表明该AVPacket要在tbn*pts=0.04秒开始显示。
/** 代码路径\ffmpeg\libavutil\rational.h
* Rational number (pair of numerator and denominator). 有理数(通过分子和分母描述)
*/
typedef struct AVRational{
int num; ///< Numerator 分子
int den; ///< Denominator 分母
} AVRational;
ffmpeg官方对tbn、tbc、tbr的解释
There are three different time bases for time stamps in FFmpeg. The
values printed are actually reciprocals of these, i.e. 1/tbr, 1/tbn and
1/tbc.ffmpeg有3种不同的时间基,通常用倒数的形式表示,比如1/tbr, 1/tbn and
1/tbctbn is the time base in AVStream that has come from the container, I
think. It is used for all AVStream time stamps.tbn是AVStream的时间基,来自容器,被AVStream的所有时间戳使用
tbc is the time base in AVCodecContext for the codec used for a
particular stream. It is used for all AVCodecContext and related time
stamps.tbc是AVCodecContext的时间基用于一段特定流的codec,用于AVCodecContext
内的成员以及相关时戳使用
tbr is guessed from the video stream and is the value users want to see
when they look for the video frame rate, except sometimes it is twice
what one would expect because of field rate versus frame rate.从视频流中猜算得到,可能是帧率或场率(帧率的 2 倍)
tbn:
FFmpeg: AVStream Struct Reference
tbc:
FFmpeg: AVCodecContext Struct Reference
tbr:
从视频流中猜算得到,可能是帧率或场率(帧率的 2 倍)
参考:
FFmpeg时间戳详解 - 叶余 - 博客园