After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 696300 - H264 video is playing too fast because of invalid PTS:
H264 video is playing too fast because of invalid PTS:
Status: RESOLVED DUPLICATE of bug 659489
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal blocker
: 1.1.2
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2013-03-21 15:45 UTC by sreerenj
Modified: 2013-07-24 08:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
videodecoder: adjust the PTS calculation for decoded frame. (1.50 KB, patch)
2013-03-21 15:45 UTC, sreerenj
none Details | Review
videodecoder: adjust the PTS calculation for decoded frame. (1.70 KB, patch)
2013-03-23 22:28 UTC, sreerenj
none Details | Review
videodecoder: adjust the PTS calculation for decoded frames. (1.97 KB, patch)
2013-03-25 16:49 UTC, sreerenj
none Details | Review

Description sreerenj 2013-03-21 15:45:35 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..
Comment 1 sreerenj 2013-03-23 22:28:05 UTC
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.
Comment 2 Sebastian Dröge (slomo) 2013-03-25 08:38:27 UTC
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
Comment 3 sreerenj 2013-03-25 16:49:27 UTC
Created attachment 239788 [details] [review]
videodecoder: adjust the PTS calculation for decoded frames.

Attaching the new patch based on Sebastian's comment.
Comment 4 Tim-Philipp Müller 2013-06-07 09:24:53 UTC
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?
Comment 5 Sebastian Dröge (slomo) 2013-06-07 10:26:42 UTC
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.
Comment 6 Edward Hervey 2013-07-24 08:12:43 UTC

*** This bug has been marked as a duplicate of bug 659489 ***