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 638288 - qtmux: fails to handle out-of-order buffers without duration
qtmux: fails to handle out-of-order buffers without duration
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other All
: Normal normal
: 0.10.21
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 646012 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2010-12-29 17:02 UTC by Jonas Larsson
Modified: 2011-04-04 10:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
diff describing my changes to solve the issue (4.42 KB, patch)
2010-12-29 17:02 UTC, Jonas Larsson
none Details | Review
Example of flv with AVC and B-frames (512.00 KB, video/x-flv)
2010-12-29 17:04 UTC, Jonas Larsson
  Details

Description Jonas Larsson 2010-12-29 17:02:40 UTC
Created attachment 177199 [details] [review]
diff describing my changes to solve the issue

After upgrading gst + plugins remuxing flv -> mp4 is now broken and I have traced the issue to the added CTS offset code in flvdemux.

The current code correctly calculates PTS using embedded CTS offsets, which is great for playback but not for remuxing. When remuxing I want DTS set on the buffers, not PTS. If buffers are stamped with PTS, they arrive out of order to the downstream muxer if video is AVC/H264 with B-frames. That's not really good when using for example the gst qtmux element.

I solved this by adding a new property on flvdemux and I wanted to share my solution.

What I want to do:
gst-launch filesrc location=in.flv ! flvdemux ! queue ! video/x-h264,width=640,height=360 ! qtmux ! filesink location=out.mp4

What I get:
ERROR: from element /GstPipeline:pipeline0/GstQTMux:qtmux0: Could not multiplex stream.
Additional debug info:
gstqtmux.c(2186): gst_qt_mux_add_buffer (): /GstPipeline:pipeline0/GstQTMux:qtmux0:
Received buffer without timestamp/duration.

Problem is illustrated by (fakesink output reformatted for clarity):
gst-launch -v filesrc location=in.flv ! flvdemux ! queue ! video/x-h264,width=640,height=360 ! fakesink num-buffers=5

chain timestamp: 0:00:00.040000000, duration: none
chain timestamp: 0:00:00.120000000, duration: none
chain timestamp: 0:00:00.080000000, duration: none
chain timestamp: 0:00:00.200000000, duration: none
chain timestamp: 0:00:00.160000000, duration: none

Note the out of order timestamps due to B-frames.

With my changes:
gst-launch -v filesrc location=in.flv ! flvdemux avc-cts=false ! queue ! video/x-h264,width=640,height=360 ! fakesink num-buffers=10

chain timestamp: 0:00:00.000000000, duration: none
chain timestamp: 0:00:00.040000000, duration: none
chain timestamp: 0:00:00.080000000, duration: none
chain timestamp: 0:00:00.120000000, duration: none
chain timestamp: 0:00:00.160000000, duration: none

Timestamps are now monotonically increasing and I can go on remuxing my file:
gst-launch filesrc location=in.flv ! flvdemux avc-cts=false ! queue ! video/x-h264,width=640,height=360 ! qtmux ! filesink location=out.mp4

out.mp4 plays back fine on all players I have tested, including gst.

avc-cts defaults to TRUE so this change will not break playback of AVC videos but enables easy remuxing if set to false.
Comment 1 Jonas Larsson 2010-12-29 17:04:50 UTC
Created attachment 177200 [details]
Example of flv with AVC and B-frames
Comment 2 Mark Nauwelaerts 2010-12-29 19:09:44 UTC
The usual DTS/PTS problem again, though I am not quite sure where this would currently pose a concrete problem other than in qtmux.  That is, this feels like trying to fix something in qtmux by hacking a bit in flvdemux.

FWIW, I was shortly planning/needing to modify/fix some timestamp heuristics in qtmux (again) and might as well keep this in mind also.
Comment 3 Mark Nauwelaerts 2011-01-03 16:06:31 UTC
Since it is supposed to be normal (i.e. according to spec) for buffers to pass around being decorated with PTS (though possibly inconvenient), moving this to qtmux as the core/source of the problem (though hard to really blame it).
Comment 4 Mark Nauwelaerts 2011-01-03 16:46:24 UTC
And following commit should handle this case when using the "reorder" dts-method
(assuming qtmux is actually/really the only place where this is a problem, feel free to note otherwise). 

commit 38c93429784d10ddd4da0dbe390616b7e9196729
Author: Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Date:   Mon Jan 3 17:24:23 2011 +0100

    qtmux: adjust nasty case timestamp tracking
    
    That is, all sorts of problems arise with re-ordered input timestamps that
    tend to defy automagic handling for every case, so allow for a few variations
    that can be tried depending on circumstances.
    
    Also try to document accordingly.
    
    Also fixes #638288.
Comment 5 Jonas Larsson 2011-01-05 08:07:35 UTC
I can confirm that this solves my problem in a much more elegant way than my solution. There is no point in arguing with the gst masters on what problems should be solved in which component. You guys know the code way better than me.

I would however like to +1 on the inline comment
0.11 Phew, can we (pretty) please please sort out DTS/PTS on buffers ...


Thanks again!
Comment 6 Mark Nauwelaerts 2011-04-04 10:08:51 UTC
*** Bug 646012 has been marked as a duplicate of this bug. ***