GNOME Bugzilla – Bug 704272
qtdemux: invalid seek offset used because of chapters
Last modified: 2013-07-18 09:48:54 UTC
With the recent chapter/text related patches in qtdemux, I got a regression on this file when seeking: http://absolut.zogzog.org/share/samples/mp4/Escargot.mp4 The problem is that the text stream (which is in fact a chapter entry) is used when resolving the seek offset in the file. Since the chapter track has very sparse entries, the seek offset is not accurate at all. For example, if I want to seek at 2min46, the keyframe matching in the chapter track is at 25sec, so the seek offset is at 25sec instead of 2min46: <qtdemux0> align segment 0 <qtdemux0> sample for 0:02:46.260000000 at 4156 at offset 16358453 <qtdemux0> searching for keyframe index before index 4156 gave 4074 <qtdemux0> keyframe at 4074 with time 0:02:42.960000000 at offset 16190718 <qtdemux0> align segment 0 <qtdemux0> sample for 0:02:46.260000000 at 7793 at offset 16355509 <qtdemux0> searching for keyframe index before index 7793 gave 7793 <qtdemux0> align segment 0 <qtdemux0> sample for 0:02:46.260000000 at 1 at offset 31545768 <qtdemux0> searching for keyframe index before index 1 gave 1 <qtdemux0> Pushing BYTE seek rate 1, start 16190718, stop -1 <qtdemux0> stream : avc1 <qtdemux0> Resetting demux <qtdemux0> received newsegment bytes segment start=16190718, stop=-1, rate=1.000000, applied_rate=1.000000, flags=0x01, time=16190718, base=0, position 16190718, duration 31734295 <qtdemux0> Not storing upstream newsegment, not in time format <qtdemux0> Pushing newseg time segment start=0:00:25.080000000, stop=99:99:99.999999999, rate=1.000000, applied_rate=1.000000, flags=0x01, time=0:00:25.080000000, base=0:00:00.000000000, position 0:00:25.080000000, duration 0:05:32.520000000
Is this a duplicate of #704007 ? After that patch, seeking seems to work fine for me.
Ok, I've implemented a few patches that fix the issue. Subtitle / sparse streams support is pretty flaky in the current code in push mode, so these should help.
Created attachment 249421 [details] [review] advertise subtitle streams as sparse Although the SPARSE flag in stream-start is not used, it should still be set on subtitle streams
Created attachment 249422 [details] [review] do not use indexes from sparse stream when seeking in push mode When seeking in push mode in qtdemux, the seek offset is computed by finding the nearest previous keyframe in all streams, and using the one furthest away. For sparse stream this can be pretty far so ignore them in this case.
Created attachment 249423 [details] [review] send gap event for sparse streams in push mode Send gap event on first buffer on sparse streams, to allow prerolling. Unfortunately we can't compute the timestamp of the next entry of the sparse stream in push mode, so the duration is set to GST_CLOCK_TIME_NONE.
Created attachment 249424 [details] [review] remove chapter stream The 'text' tracks that are actually chapters should be removed from the stream list, since we will never use them afterwards. This also makes sure we don't use this track index to resolve seek offsets (which is avoided by the previous patch, but still there could be other hidden issues).
Here are some videos you can use for testing: mp4 video with chapter track, with only 2 entries in the text track index: http://absolut.zogzog.org/share/samples/mp4/Escargot.mp4 mov file with subtitles: http://absolut.zogzog.org/share/samples/mov/subtitlemovie.mov
commit 5def061d205867430b4acf490884f67456274242 Author: Arnaud Vrac <avrac@freebox.fr> Date: Tue Jul 16 22:17:17 2013 +0200 qtdemux: remove chapter stream Remove all streams that are actually table of contents, since we will never need the data after parsing them. commit ae67c13416f8ae9b04915ebc0646fa05cd1892fa Author: Arnaud Vrac <avrac@freebox.fr> Date: Tue Jul 16 21:59:37 2013 +0200 qtdemux: send gap event for sparse streams in push mode This allows to pre-roll at least if the next subtitle buffer is far away. commit 12378983511de3de023f6faaccbcf9aa4756ec20 Author: Arnaud Vrac <avrac@freebox.fr> Date: Tue Jul 16 21:56:07 2013 +0200 qtdemux: do not use indexes from sparse stream when seeking in push mode This makes seeking more accurate in push mode, since the previous keyframe on a sparse stream might be far away. commit e561d126558b43b1095121f07bfa4613646a5468 Author: Arnaud Vrac <avrac@freebox.fr> Date: Tue Jul 16 21:04:07 2013 +0200 qtdemux: advertise subtitle streams as sparse