FFmpeg av_dump_format输出的tbn、tbc、tbr、PAR、DAR的含义
http://www.jianshu.com/p/5b78a91f1091
利用 ffmpeg 系統函數 dump 碼流信息
ffmpeg 提供了一個函數直接幫助你打印出解析到的媒體信息,用法如下:
av_dump_format(ic, 0, ic->filename, 0); 如:av_dump_format(fmtCtx, 0, "rtmp://live.hkstv.hk.lxdns.com/live/hks", 0);會打印流媒體的信息,比如:
[flv @ 0x7fa6ec813400] Stream discovered after head already parsed Input #0, flv, from 'rtmp://live.hkstv.hk.lxdns.com/live/hks':Metadata:author : PowerSmartcopyright : description : datarate : 500livetime : 1453688059timeshift : 0Duration: 01:00:00.00, start: 0.000000, bitrate: N/AStream #0:0: Audio: aac (LC), 32000 Hz, stereo, fltpStream #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的理解
總結
以上是生活随笔為你收集整理的FFmpeg av_dump_format输出的tbn、tbc、tbr、PAR、DAR的含义的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java开发用allman风格_缩进风格
- 下一篇: MFC 右键菜单呼出