FFmpeg av_dump_format输出的tbn、tbc、tbr、PAR、DAR的含义

来源:互联网 发布:windows 7 共享 选项卡 编辑:程序博客网 时间:2024/04/29 15:25

av_dump_format(fmtCtx, 0, "rtmp://live.hkstv.hk.lxdns.com/live/hks", 0);会打印流媒体的信息,比如:

[flv @ 0x7fa6ec813400] Stream discovered after head already parsedInput #0, flv, from 'rtmp://live.hkstv.hk.lxdns.com/live/hks':  Metadata:    author          : PowerSmart    copyright       :     description     :     datarate        : 500    livetime        : 1453688059    timeshift       : 0  Duration: 01:00:00.00, start: 0.000000, bitrate: N/A    Stream #0:0: Audio: aac (LC), 32000 Hz, stereo, fltp    Stream #0:1: Video: h264 (Constrained Baseline), yuv420p, 640x480, 15.17 fps, 15 tbr, 1k tbn, 30 tbc

其中,15 tbr, 1k tbn, 30 tbc是什么意思,很多人并不了解。

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.

tbn is the time base in AVStream that has come from the container, I think. It is used for all AVStream time stamps.

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.

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.

tbr一般被当成帧率。当视频的码率为固定码率时,FFmpeg显示tbr为正常的码率值。当视频有变长码率时,FFmpeg打印的tbr为多个码率的均值,看着像音频流。比如:

Video: h264, yuv420p, 640x480, 22050 tbr, 22050 tbn, 44100 tbc

新问题
Stream #0.0[0xfe]: Video: h264, yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 59.94 tbr, 90k tbn, 59.94 tbc中PAR、DAR是什么含义?

PAR - pixel aspect ratio大多数情况为1:1,就是一个正方形像素,否则为长方形像素

DAR - display aspect ratio就是视频播放时,我们看到的图像宽高的比例,缩放视频也要按这个比例来,否则会使图像看起来被压扁或者拉长了似的。

SAR - storage aspect ratio就是对图像采集时,横向采集与纵向采集构成的点阵,横向点数与纵向点数的比值。比如VGA图像640/480 = 4:3,D-1 PAL图像720/576 = 5:4

这三者的关系PAR x SAR = DAR或者PAR = DAR/SAR.

如果一段视频的DAR为4:3,它的SAR为VGA存储的4:3,那么可推出PAR为1:1,如果它的SAR为D-1 PAL存储的5:4,那么可以推出PAR为16:15


D-1 PAL图像

看上图,假设这就是一个D-1 PAL图像,每个方格代表一个存储的点,横向有5个点,纵向有4个点,所以SAR为5:4

现已知这幅图象的宽度为160,高度为120,即DAR为4:3

那这个方格的宽高比是多少呢?答案16:15,即PAR,这个方格代表的是一个长方形的像素。

视频三比率SAR,PAR,DAR是从宏观上描述一个视频轮廓很重要的三个参数。在不同的文档中,通常对这三个参数有不同的表述。但是,均指代同一事物。

参考及推荐阅读:

  • What does the output of ffmpeg mean? tbr tbn tbc etc?
  • What does the video output stream details from ffmpeg mean?
  • ffmpeg frame rate
  • 对PAR DAR SAR的理解


文/赖__82084788(简书作者)
原文链接:http://www.jianshu.com/p/5b78a91f1091
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
0 0
原创粉丝点击