[MPlayer-dev-eng] Accurate video pts handling

Uoti Urpala uoti.urpala at pp1.inet.fi
Tue May 9 19:08:56 CEST 2006


The attached patch implements accurate video pts calculation for videos
with B frames, and allows filters to modify pts values. It's not
finished code but should be useful for people who want to test filters
that modify pts values or who want accurate playback (I've modified the
ASS subtitle patch to use the filter timestamps so subtitle changes
timed at scene changes work correctly).

The patch adds an MPlayer option called -correct-pts. If that is not
enabled things should work about the same; turning it on enables
accurate pts tracking and allows filters to manipulate pts, but also
breaks some things. The internal mpeg demuxer won't work (because
currently code in video.c with mpeg-specific cases isn't run). If the
demuxer doesn't give video timestamps for every frame things won't work
right (no attempt to calculate timestamps based on default fps). Video
decoders other than lavc won't work right if the video stream contains
skipped or broken frames. There are also some other smaller known
problems.

vf_ptstest.diff contains a simple video filter to demonstrate the pts
manipulation. It compresses each second of video into the first half of
the second with no frames in the second half.

The pts calculation with B frames works by keeping a buffer of pts
values, where the timestamp of each frame fed to the decoder is added.
Whenever the decoder outputs a frame the smallest timestamp is taken out
of the buffer and used as the output timestamp of that frame. This works
without decoder assistance and whether the demuxer returns timestamps in
coded or display order as long as the only reason the decoder doesn't
return a frame is decoder lag. However to handle broken or skipped
frames cooperation from the decoder is necessary, as it's necessary to
distinguish between decoder lag (a timestamp should be buffered for that
frame) and skipped frames (a timestamp should be dropped). The code
tries to query the decoder for the number of buffered frames that have
not been shown yet (those that should be timestamps buffered for them).
The changes to vd_ffmpeg.c (ab)use the buffer interface to get this
information out of lavc, it seems to work at least for the files I've
tested.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: videopts.diff
Type: text/x-patch
Size: 19492 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20060509/b66ae7c1/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vf_ptstest.diff
Type: text/x-patch
Size: 4146 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20060509/b66ae7c1/attachment-0001.bin>


More information about the MPlayer-dev-eng mailing list