GNOME Bugzilla – Bug 696300
H264 video is playing too fast because of invalid PTS:
Last modified: 2013-07-24 08:12:43 UTC
Created attachment 239476 [details] [review] videodecoder: adjust the PTS calculation for decoded frame. When playing some raw h264 samples, the decoder is getting invalid PTS from upstream elements and the subclass decoder is also failing to calculate the PTS for the buffers. As a result the stream is playing too fast with out sync. Another way to reproduce the issue: converting byte-stream to avc with h264 parse. sample: http://samples.mplayerhq.hu/V-codecs/h264/x264.avi pipeline: gst-launch-1.0 -v filesrc location=x264.avi ! avidemux ! h264parse ! "video/x-h264, stream-format=(string)avc, alignment=(string)au" ! avdec_h264 ! xvimagesink Attaching a patch which is to adjust the PTS if it is invalid: If the decoder didn't get a valid PTS from upstream or from the subclass before pushing the the decoded buffer downstream, then assume the DTS as PTS for decoded buffer. Of course this adjusted_PTS is not right for all frames.But at least it will make the stream playable..
Created attachment 239649 [details] [review] videodecoder: adjust the PTS calculation for decoded frame. If the decoder didn't get a valid PTS from upstream or from the subclass before pushing the the decoded buffer downstream, then assume the DTS as PTS for decoded buffer. Previous patch has been updated with this with a minor change: Added a Warning Message if DTS is interpolated as PTS.
Shouldn't it be possible to calculate the real PTS from the DTS? Like using the earliest DTS of all frames that are still not finished as the PTS of the current frame? Just using the DTS directly will cause the PTS to be non-monotonous and could cause problems in some elements
Created attachment 239788 [details] [review] videodecoder: adjust the PTS calculation for decoded frames. Attaching the new patch based on Sebastian's comment.
Marking as blocker for now, since there is a regression here. In 1.0.x: cat foo.h264 | gst-launch-1.0 -v fdsrc ! video/x-h264,framerate=25/1,stream-format=byte-stream ! h264parse ! avdec_h264 ! fakesink silent=false will produce nice timestamps (the parsers won't set any, and the decoder will just extrapolate from 0 based on framerate). In 1.1.x / git master the parser will set the dts based on the framerate, and the decoder gets confused and doesn't set either dts nor pts on the output. ---- <slomo> sree_'s patch is not correct though. ds said that here [on IRC] at least iirc <slomo> the assumption that the earliest remaining DTS is the current output frame's PTS is not always true iirc... no idea how and why though ;) i'd like him to comment there ---- David, could you comment/elaborate/make any suggestions?
I think the conclusion is that the parser is supposed to do the DTS->PTS conversion if no PTS is available. https://gitorious.org/gstreamer-omap/gst-plugins-bad/commits/v0.10.23+ti is supposed to have patches to do this.
*** This bug has been marked as a duplicate of bug 659489 ***