GNOME Bugzilla – Bug 743578
qtdemux: Parse 'sidx' atom (for duration and indexing in fragmented files)
Last modified: 2015-02-12 21:02:03 UTC
When playing car-audio-1MB-trunc.mp4[1] using gst-play-1.0, the stream duration is computed as "10s" in the begining and is updated later up to "60s" as qtdemux gets more data. For reference, the real stream duration when played using Chromium is ~65s. As a curiosity, gst-play-1.0 stops at 10s, unaffected by the updated duration. But the real problem this bug wants to highlight is the need of a way for qtdemux to process all the available data while it's still in the pause state. In my use case, the actual 1MB data buffer is fed to GStreamer by a browser, all in a row. In theory, GStreamer would be in conditions to compute the whole duration of the fed data when it reaches the pause state. However, due to the way qtdemux is implemented, the duration reaches the actual value only when GStreamer changes to play state, data starts to flow and the right data reaches qtdemux. Needing the real duration of all the fed buffer is critical for the Media Source Extensions algorithms we're helping to implement in WebKit. [1] http://yt-dash-mse-test.commondatastorage.googleapis.com/unit-tests/media/car-audio-1MB-trunc.mp4
Looks like the proper solution is to parse the 'sidx' atom (which is between the 'moov' and first 'moof') which describes all following fragments (along with duration).
dashdemux already has code on a separate file for that
Thanks for the hint Thiago! Would it be worth moving the isoff parser in -good at some point? It could easily be used by qtdemux.
Created attachment 296604 [details] [review] patch
Created attachment 296605 [details] [review] patch Now with the isoff parser :)
Review of attachment 296605 [details] [review]: Looks good, but I guess it also needs to be done for push-mode operation, right? So it also needs to parse the sidx in the process_adapter() function.
Created attachment 296694 [details] [review] updated patch Now working in push-mode too :)
Thanks, the code is ok now. But did you notice that the sidx points to 19 entries of ~10s while the file only has 7 moof entries. Meaning that this is a file cut from another one and the sidx wasn't updated. So, duration is now reported as 3min, while it only contains about 1min of audio.
Yes indeed, I think this file was produced from another one which had a (longer) video stream.
commit 3a9b0188cd6efa03daa05190ccabebe5211ed4a5 Author: Philippe Normand <philn@igalia.com> Date: Wed Feb 11 15:30:44 2015 +0100 qtdemux: Initial 'sidx' atom parsing support Parse the 'sidx' atom and update the total duration according to the parser result. The isoff parser code is imported from gst-plugins-bad's dashdemux and a gst_isoff_sidx_parser_add_data() function was factored out of the gst_isoff_sidx_parser_add_buffer() function. https://bugzilla.gnome.org/show_bug.cgi?id=743578