View Full Version : A question about PTS and DTS in the MPEG-2 ts
sjtu_dukelee
30th April 2008, 18:55
i am freshman in this forum and i just have learned few about the MPEG-2,only reading the standard document and some code ,and if one picture frame have a time stamp(PTS,DTS),how can i make sure the next frame's time stamp?
how can i know the increment between the two frame's time stamp?
by the way,i download some PES stream ,and i look at it carefully,and i compute the increment is changing,the time increment changing like this from 1800,1800 to 3600.why?
:thanks:
neuron2
2nd May 2008, 06:55
i am freshman in this forum and i just have learned few about the MPEG-2,only reading the standard document and some code ,and if one picture frame have a time stamp(PTS,DTS),how can i make sure the next frame's time stamp? To determine the next frame's timestamp, add a time equal to 1 divided by the frame rate, i.e., the frame time.
how can i know the increment between the two frame's time stamp? Subtraction.
by the way,i download some PES stream ,and i look at it carefully,and i compute the increment is changing,the time increment changing like this from 1800,1800 to 3600.why? Not clear enough to answer.
sjtu_dukelee
2nd May 2008, 09:31
To determine the next frame's timestamp, add a time equal to 1 divided by the frame rate, i.e., the frame time.
yes ,i know .for example,the frame rate is 25fps,and the increment is 3600(clock frequency 90kHz),but the gop is not the sequence that each frame add a time ,such as the group of picture is I P B B P B B,how can i make sure the pts and dts of the frames of P B B P B B.in that case i must arrange the frame in their sequence,is there a simple method for the pts and dts adding?
:thanks:
neuron2
2nd May 2008, 13:50
yes ,i know .for example,the frame rate is 25fps,and the increment is 3600(clock frequency 90kHz),but the gop is not the sequence that each frame add a time ,such as the group of picture is I P B B P B B,how can i make sure the pts and dts of the frames of P B B P B B.in that case i must arrange the frame in their sequence,is there a simple method for the pts and dts adding?
:thanks: I'm still having big problems following your English. When B frames are involved, the PTS and DTS will differ. If you just need to reorder the frames, you can use the temporal_reference field of the picture header.
I don't understand you when you talk about "pts and dts adding". What exactly are you trying to do?
sjtu_dukelee
2nd May 2008, 16:35
i am so sorry for my english.now i am going to write a program to pack es(elementry stream) to pes and pes to ts according to the MPEG-2.from es to pes ,i must add the pes header,includeing the time stamp.i want to append the pts and dts for each frame.previously,you talk about the reorder and the temporal_reference field ,yes that is the key point!
please give me more details about that.
and i have read some material,i know the dts is:
dts = last_dts + delta(3600 for 25fps)
but pts is complex,how can i append the pts for each frame which is likely to be I , B , or P
:thanks:
neuron2
2nd May 2008, 16:58
Apply the DTS to the frames in decode order. Apply the PTS to the frames in display order.
You can use the temporal_reference. Increment the DTS as you say at each new picture in decode order. Increment the PTS according to the difference in temporal reference between the current picture and the previous picture. You'll need to watch out for the temporal_reference resetting to 0 at the start of each GOP, and for wrap-around if the stream has no GOP headers.
You can probably find open source muxing code, such as in ffmpeg.
sjtu_dukelee
2nd May 2008, 18:50
Increment the PTS according to the difference in temporal reference between the current picture and the previous picture. i still donot understand clearly.and i read some papers,
find a simple relationship for the pts:
pts(i) = pts(1) + (N + temporal_reference + 1)*3600
pts(i):the number i frame's pts
pts(1):the first(initial) pts
N:the number of frames before the current GOP
temporal_reference:the number i frame's temporal reference
is this formula right?
by the way,i download the ffmpeg code,and there are so many files in the ffmpeg,which files are about es -> pes -> ts?mpeg.c ,mpegts.c ,or mpegtsenc.c?
:thanks:
neuron2
2nd May 2008, 19:06
I'm sorry but I haven't time to help you with the level of support you seem to require. Maybe someone else has time for it.
sjtu_dukelee
3rd May 2008, 04:08
you already help me a lot,thank you all the same
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.