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 704272 - qtdemux: invalid seek offset used because of chapters
qtdemux: invalid seek offset used because of chapters
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
1.1.2
Other Linux
: Normal blocker
: 1.1.3
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2013-07-15 16:48 UTC by Arnaud Vrac
Modified: 2013-07-18 09:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
advertise subtitle streams as sparse (2.41 KB, patch)
2013-07-17 16:51 UTC, Arnaud Vrac
committed Details | Review
do not use indexes from sparse stream when seeking in push mode (2.74 KB, patch)
2013-07-17 16:55 UTC, Arnaud Vrac
committed Details | Review
send gap event for sparse streams in push mode (1.16 KB, patch)
2013-07-17 16:57 UTC, Arnaud Vrac
committed Details | Review
remove chapter stream (2.55 KB, patch)
2013-07-17 17:02 UTC, Arnaud Vrac
committed Details | Review

Description Arnaud Vrac 2013-07-15 16:48:03 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
Comment 1 Sebastian Dröge (slomo) 2013-07-16 09:01:59 UTC
Is this a duplicate of #704007 ? After that patch, seeking seems to work fine for me.
Comment 2 Arnaud Vrac 2013-07-17 16:49:45 UTC
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.
Comment 3 Arnaud Vrac 2013-07-17 16:51:46 UTC
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
Comment 4 Arnaud Vrac 2013-07-17 16:55:26 UTC
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.
Comment 5 Arnaud Vrac 2013-07-17 16:57:20 UTC
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.
Comment 6 Arnaud Vrac 2013-07-17 17:02:04 UTC
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).
Comment 7 Arnaud Vrac 2013-07-17 17:07:05 UTC
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
Comment 8 Sebastian Dröge (slomo) 2013-07-18 09:48:27 UTC
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