1. 程式人生 > >視訊流中的DTS/PTS到底是什麼;

視訊流中的DTS/PTS到底是什麼;

翻譯了一下:
Q:
hi,這可能是一個弱智問題,但是當我使用bbMEG1.24beta17編碼時,一直以來總是遇到這個下溢的問題。我從日誌檔案中得到的唯一啟示就是我應該更改mux率。。。但是幫助文件卻說將mux率設定為0可以強制其值由編碼器來計算。有誰知道我應該設定什麼值麼?能有人準確的描述一下什麼是PTS/DTS麼?我一直使用一款SigmaDesigns NS2000卡來播放,卻還沒有看到我的視訊效果。。。

###
Input information
Video:
width: 720, height: 480
first frame: 1, number of frames: 300000
Audio:
sample rate: 48.0 kHz
channels: stereo
bits per sample: 16
Output MPEG information
Video: C:/WINNT/Profiles/jstarkey/Desktop/videoOut.m2v, deleted if multiplexed
MPEG-2, 720x480 @ 29.97 fps, variable bitrate, quant value = 1
Audio: C:/WINNT/Profiles/jstarkey/Desktop/videoOut.mp2, deleted if multiplexed
Layer 2, 64 kbps, 48.0 kHz, stereo
Multiplexing: video and one audio stream
program stream type: MPEG-2 with pulldown auto-detection
video file: C:/WINNT/Profiles/jstarkey/Desktop/videoOut.m2v
audio 1 file: C:/WINNT/Profiles/jstarkey/Desktop/videoOut.mp2
program file: C:/WINNT/Profiles/jstarkey/Desktop/videoOut
Encoding Video:
Video Encoding finished at frame # 1228.
Min bitrate of any one frame = 2773 bits
Max bitrate of any one frame = 339049 bits
Min bitrate over any one second = 1486741 bps
Avg bitrate over any one second = 2706791 bps
Max bitrate over any one second = 3040605 bps
Total time: 1658 seconds (00:27:38), 0.74 frames/sec, 1.350 sec/frame.
Encoding Audio:
Avg slots/frame = 192.000; b/smp = 1.33; br = 64.000 kbps.
Multiplexing video and audio:
Scanning video stream for a sequence header and pulldown type ...
no pulldown detected ...
Scanning video stream for pictures ...
Found 1242 picture headers.
Video stream information
Stream length : 15621086
Total time (seconds) : 41
Sequence start : 83
Sequence end : 1
No. Pictures : 1242
No. Groups : 83
No. I Frames : 82 avg. size 21925 bytes
No. P Frames : 332 avg. size 16821 bytes
No. B Frames : 828 avg. size 9958 bytes
No. D Frames : 0 avg. size 0 bytes
Horizontal size : 720
Vertical size : 480
Aspect ratio : 0.6735
Picture rate : 29.970 frames/sec
Bit rate : 375000 bytes/sec (3000000 bits/sec)
Computed avg rate : 377500 bytes/sec (3020000 bits/sec)
Computed max rate : 1798000 bytes/sec (14384000 bits/sec)
Vbv buffer size : 194560 bytes
CSPF : 0
Scanning audio stream for access units information
Found 1710 audio frame headers.
MPEG audio stream information
Stream length : 328320
Syncwords : 1710
Frames : 1710 size 192 bytes
Frames : 0 size 193 bytes
Layer : 2
CRC checksums : no
Bit rate : 8000 bytes/sec (64 kbit/sec)
Frequency : 48.0 kHz
Mode : 0 stereo
Mode extension : 0
Copyright bit : 0 no copyright
Original/Copy : 0 copy
Emphasis : 0 none
Multiplexing information
Video stream data rate : 1798000 bytes/sec (14384000 bits/sec)
Audio stream 1 data rate : 8000 bytes/sec (64000 bits/sec)
Overhead data rate : 32350 bytes/sec (258800 bits/sec)
Total data rate : 1838350 bytes/sec (14706800 bits/sec)
Multiplexing file c:/winnt/profiles/jstarkey/desktop/videoout
video PTS (41287.73ms) underflow at pack 7288 by 35.57ms
video PTS (41321.10ms) underflow at pack 7351 by 72.43ms
video DTS (41354.47ms) underflow at pack 7416 by 111.53ms
video PTS (41387.83ms) underflow at pack 7506 by 178.50ms
video PTS (41421.20ms) underflow at pack 7572 by 218.71ms
video DTS (41454.57ms) underflow at pack 7635 by 255.58ms
video PTS (41487.93ms) underflow at pack 7725 by 322.55ms
video PTS (41521.30ms) underflow at pack 7783 by 353.84ms
video DTS (41554.67ms) underflow at pack 7843 by 387.36ms
9 video underflows (SCR >= PTS or DTS)
NOTE: The resulting file may not play back correctly.
Try increasing the mux rate.
Finished multiplexing c:/winnt/profiles/jstarkey/desktop/videoout
###
A:From:BEYELER
To:JAMUELS
DTS(解碼時間戳)和PTS(顯示時間戳)分別是解碼器進行解碼和顯示幀時相對於SCR(系統參考)的時間戳。SCR可以理解為解碼器應該開始從磁碟讀取資料時的時間。
mpeg檔案中的每一個包都有一個SCR時間戳並且這個時間戳就是讀取這個資料包時的系統時間。通常情況下,解碼器會在它開始讀取mpeg流時啟動系統時鐘(系統時鐘的初始值是第一個資料包的SCR值,通常為0但也可以不從0開始)。
DTS時間戳決定了解碼器在SCR時間等於DTS時間時進行解碼,PTS時間戳也是類似的。通常,DTS/PTS時間戳指示的是晚於音視訊包中的SCR的一個時間。例如,如果一個視訊資料包的SCR是100ms(意味著此包是播放100ms以後從磁碟中讀取的),那麼DTS/PTS值就差不多是200/280ms,表明當SCR到200ms時這個視訊資料應該被解碼並在80ms以後被顯示出來(視訊資料在一個buffer中一直儲存到開始解碼)
下溢通常發生在設定的視訊資料流相關mux率太高。如果mux率是1000000bits/sec(意味著解碼器要以1000000bits/sec的速率讀取檔案),可是視訊速率是2000000bits/sec(意味著需要以2000000bits/sec的速率顯示視訊資料),從磁碟中讀取視訊資料時速度不夠快以至於1秒鐘內不能夠讀取足夠的視訊資料
。這種情況下DTS/PTS時間戳就會指示視訊在從硬碟中讀出來之前進行解碼或顯示(DTS/PTS時間戳就要比包含它們的資料包中的SCR時間要早了)。
如今依靠解碼器,著基本已經不是什麼問題了(儘管MPEG檔案因為應該沒有下溢而並不完全符合MPEG標準)。一些解碼器(很多著名的基於PC的播放器)儘可能快的讀取檔案以便顯示視訊,可以的話直接忽略SCR。
注意在你提供的列表中,平均的視訊流速率為~3Mbps(3000000bits/sec)但是它的峰值達到了14Mbps(相當大,DVD限制在9.8Mbps內)。這意味著mux率需要調整足夠大以處理14Mbps的部分, bbMPEG計算出來的mux率有時候太低而導致下溢。
你計劃讓視訊流速率這麼高麼?這已經超過了DVD的說明了,而且很可能在大多數獨立播放其中都不能播放。如果你不是這麼計劃,我會從1增加mquant的值並且在視訊設定中將最大碼流設定為9Mbps以保持一個小一點的碼流。
如果你確實想讓視訊位元速率那麼高,你需要增大mux率。從提供的列表可以得出bbMPEG使用14706800bits/sec或者1838350bytes/sec的mux率(總資料速率為:1838350bytes/sec(14706800bits/sec)行)。你在強制mux率欄位設定的值應該是以bytes/sec為單位並被50整除。所以我會從36767(1838350/50)開始,一直增加直到不會再出現下溢錯誤為止;


From: JAMUELS Mar-2 6:16 pm
To: ALL (1 of 3)
329.1
Hi,
This is probably a dumb question, but I’ve been experiencing underflow errors on some
material that I’ve encoded with bbMEG 1.24 beta 17. The only thing I can deduce from the
log file is that I should change the mux rate . . . But the help file says that setting the mux rate
to "0" will force it to be computed by the encoder. Any ideas as to what value I should try?
Would someone mind describing what exactly PTS/DTS are and how underflows can impact
the final program(or point me to a relevant source of info)? I’ve been playing back with a
Sigma Designs NS2000 card and haven’t seen my video affected per se . .
BTW, I’ve enclosed my log file for reference.
TIA and Regards,
JPS
###
Input information
Video:
width: 720, height: 480
first frame: 1, number of frames: 300000
Audio:
sample rate: 48.0 kHz
channels: stereo
bits per sample: 16
Output MPEG information
Video: C:/WINNT/Profiles/jstarkey/Desktop/videoOut.m2v, deleted if multiplexed
MPEG-2, 720x480 @ 29.97 fps, variable bitrate, quant value = 1
Audio: C:/WINNT/Profiles/jstarkey/Desktop/videoOut.mp2, deleted if multiplexed
Layer 2, 64 kbps, 48.0 kHz, stereo
Multiplexing: video and one audio stream
program stream type: MPEG-2 with pulldown auto-detection
video file: C:/WINNT/Profiles/jstarkey/Desktop/videoOut.m2v
audio 1 file: C:/WINNT/Profiles/jstarkey/Desktop/videoOut.mp2
program file: C:/WINNT/Profiles/jstarkey/Desktop/videoOut
Encoding Video:
Video Encoding finished at frame # 1228.
Min bitrate of any one frame = 2773 bits
Max bitrate of any one frame = 339049 bits
Min bitrate over any one second = 1486741 bps
Avg bitrate over any one second = 2706791 bps
Max bitrate over any one second = 3040605 bps
Total time: 1658 seconds (00:27:38), 0.74 frames/sec, 1.350 sec/frame.
Encoding Audio:
Avg slots/frame = 192.000; b/smp = 1.33; br = 64.000 kbps.
Multiplexing video and audio:
Scanning video stream for a sequence header and pulldown type ...
no pulldown detected ...
Scanning video stream for pictures ...
Found 1242 picture headers.
Video stream information
Stream length : 15621086
Total time (seconds) : 41
Sequence start : 83
Sequence end : 1
No. Pictures : 1242
No. Groups : 83
No. I Frames : 82 avg. size 21925 bytes
No. P Frames : 332 avg. size 16821 bytes
No. B Frames : 828 avg. size 9958 bytes
No. D Frames : 0 avg. size 0 bytes
Horizontal size : 720
Vertical size : 480
Aspect ratio : 0.6735
Picture rate : 29.970 frames/sec
Bit rate : 375000 bytes/sec (3000000 bits/sec)
Computed avg rate : 377500 bytes/sec (3020000 bits/sec)
Computed max rate : 1798000 bytes/sec (14384000 bits/sec)
Vbv buffer size : 194560 bytes
CSPF : 0
Scanning audio stream for access units information
Found 1710 audio frame headers.
MPEG audio stream information
Stream length : 328320
Syncwords : 1710
Frames : 1710 size 192 bytes
Frames : 0 size 193 bytes
Layer : 2
CRC checksums : no
Bit rate : 8000 bytes/sec (64 kbit/sec)
Frequency : 48.0 kHz
Mode : 0 stereo
Mode extension : 0
Copyright bit : 0 no copyright
Original/Copy : 0 copy
Emphasis : 0 none
Multiplexing information
Video stream data rate : 1798000 bytes/sec (14384000 bits/sec)
Audio stream 1 data rate : 8000 bytes/sec (64000 bits/sec)
Overhead data rate : 32350 bytes/sec (258800 bits/sec)
Total data rate : 1838350 bytes/sec (14706800 bits/sec)
Multiplexing file c:/winnt/profiles/jstarkey/desktop/videoout
video PTS (41287.73ms) underflow at pack 7288 by 35.57ms
video PTS (41321.10ms) underflow at pack 7351 by 72.43ms
video DTS (41354.47ms) underflow at pack 7416 by 111.53ms
video PTS (41387.83ms) underflow at pack 7506 by 178.50ms
video PTS (41421.20ms) underflow at pack 7572 by 218.71ms
video DTS (41454.57ms) underflow at pack 7635 by 255.58ms
video PTS (41487.93ms) underflow at pack 7725 by 322.55ms
video PTS (41521.30ms) underflow at pack 7783 by 353.84ms
video DTS (41554.67ms) underflow at pack 7843 by 387.36ms
9 video underflows (SCR >= PTS or DTS)
NOTE: The resulting file may not play back correctly.
Try increasing the mux rate.
Finished multiplexing c:/winnt/profiles/jstarkey/desktop/videoout
Options Reply
From: BEYELER Mar-5 2:35 pm
To: JAMUELS (2 of 3)
329.2 in reply to 329.1
The DTS (Decoding Time Stamp) and PTS (Presentation Time Stamp) timestamps are when
the decoder is supposed to decode and display the frame relative to the SCR (System Clock
Reference) timestamp. The SCR can be thought of as the time the decoder is supposed to read
the data from the disk.
Every packet of data in the mpeg file has an SCR timestamp and this timestamp is the value
the system clock should be at when the packet is read. Usually, a decoder will start the system
clock when it starts reading an mpeg stream (the initial value of the system clock is the SCR
from the first packet of data, usually zero but it does not have to start at zero).
The DTS timestamp tells the decoder to decode the frame when the SCR time reaches the
DTS time, likewise for the PTS timestamp. Usually, the DTS/PTS timestamps indicate a time
later than the SCR of the packet the video/audio appear in. For example, if the SCR of a
packet of video data is 100ms (meaning it is read from the disk 100ms after the start of
playback), the DTS/PTS values would be something like 200/280ms, meaning when the SCR
reaches 200ms this video data is supposed to be decoded and then 80ms later it is to be
displayed (the video data is held in a buffer until decoding time).
Underflows usually occur when the video data rate is too high with respect to the muxing rate.
If the muxing rate is 1000000 bits/sec (meaning the decoder will read 1000000 bits/sec from
the file), but the video bitrate is 2000000 bits/sec (meaning 2000000 bits/sec are needed to
display a seconds worth of video data), the video data is not being read off the disk fast
enough to read all the video bits needed for one second. In this case the DTS/PTS timestamps
will indicate the video was to be decoded/displayed before it is read from the disk (the
DTS/PTS timestamps are earlier in time than the SCR timestamps of the packet they are
contained in).
Now depending on the decoder, this can be a problem or not (although the MPEG file is not
MPEG compliant as there should be no underflows!). Some decoders (most notably PC based
players) read the file as fast as needed to display the video, ignoring the SCR as needed.
Note that in the listing you provided, the average video bitrate is ~3Mbps (3000000 bits/sec)
but that it peaks as high as 14Mbps (rather large, DVD is limited to 9.8Mbps). This means the
mux rate needs to be large enough to handle the 14Mbps part and bbMPEG’s calculated mux
rate is sometimes too low leading to underflows.
Are you intending the video bitrate to be so high? This is beyond DVD specifications and
probably not playable on most standalone players. If not, I would either increase the mquant
value from 1 or enter a maximum bitrate of 9Mbps on the Video Settings page to keep the
bitrate down a bit.
If you do want the video bitrate to be that high, you will need to increase the mux rate. From
the listing provided, bbMPEG determined the mux rate to be 14706800 bits/sec or 1838350
bytes/sec (the Total data rate : 1838350 bytes/sec (14706800 bits/sec) line). The value you
would enter in the Force Mux Rate field would be the bytes/sec value divided by 50. So I
would start with 36767 (1838350 / 50) and increase the value from there until you get rid of
the underflow messages.