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 741104 - dashdemux: add support for I frame based trick play
dashdemux: add support for I frame based trick play
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other All
: Normal enhancement
: 1.9.2
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on: 769553
Blocks:
 
 
Reported: 2014-12-04 11:14 UTC by A Ashley
Modified: 2016-08-18 10:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Make dashdemux fetch initial I frame from each segment (1.16 KB, patch)
2014-12-08 11:16 UTC, Chris Bass
needs-work Details | Review
Make qtdemux output only first sample from received segments (3.49 KB, patch)
2014-12-08 11:22 UTC, Chris Bass
needs-work Details | Review
dash: Add helper for parsing box headers (4.67 KB, patch)
2016-08-02 11:06 UTC, Sebastian Dröge (slomo)
committed Details | Review
dashdemux: Implement parsing of ISOBMFF boxes (13.52 KB, patch)
2016-08-02 11:06 UTC, Sebastian Dröge (slomo)
none Details | Review
dashdemux: Store box fourccs in the header at a central place (2.34 KB, patch)
2016-08-02 11:06 UTC, Sebastian Dröge (slomo)
none Details | Review
dashdemux: Move code around to keep all sidx related functions together (2.51 KB, patch)
2016-08-02 11:06 UTC, Sebastian Dröge (slomo)
none Details | Review
dashdemux: Implement parsing of moof box (26.03 KB, patch)
2016-08-02 11:06 UTC, Sebastian Dröge (slomo)
none Details | Review
dash: Add unit test for ISOBFF box header parsing (5.12 KB, patch)
2016-08-02 11:06 UTC, Sebastian Dröge (slomo)
none Details | Review
dash: Add test for parsing a moof box (12.35 KB, patch)
2016-08-02 11:06 UTC, Sebastian Dröge (slomo)
none Details | Review
dashdemux: Store parsed moof and extract offsets of sync samples in it (12.90 KB, patch)
2016-08-02 11:06 UTC, Sebastian Dröge (slomo)
none Details | Review
dashdemux: Implement downloading of only sync samples (13.10 KB, patch)
2016-08-02 11:06 UTC, Sebastian Dröge (slomo)
none Details | Review
dashdemux: Only do keyframe-only playback if the corresponding seek flag is given (6.30 KB, patch)
2016-08-02 11:06 UTC, Sebastian Dröge (slomo)
none Details | Review
dashdemux: Only enable key-unit trick mode for video streams (1.75 KB, patch)
2016-08-02 11:07 UTC, Sebastian Dröge (slomo)
none Details | Review
dashdemux: Mark every first buffer of moov, sidx, moof and mdat as DISCONT in keyframe-only mode (2.65 KB, patch)
2016-08-02 11:07 UTC, Sebastian Dröge (slomo)
none Details | Review
adaptivedemux: Add API for allowing subclasses to download URLs in chunks (7.60 KB, patch)
2016-08-02 11:07 UTC, Sebastian Dröge (slomo)
none Details | Review
dashdemux: Use chunked downloading for the moof in KEY_UNITS mode (6.01 KB, patch)
2016-08-02 11:07 UTC, Sebastian Dröge (slomo)
none Details | Review
dashdemux: Also allow key-unit only mode if (some) sample flags are given by trex but we can still find sync frames (1.99 KB, patch)
2016-08-02 11:07 UTC, Sebastian Dröge (slomo)
none Details | Review
dashdemux: Remember if for a stream we could do key-units only mode (5.86 KB, patch)
2016-08-02 11:07 UTC, Sebastian Dröge (slomo)
none Details | Review
dashdemux: If a fragment contains no sync samples, disable key-unit mode (978 bytes, patch)
2016-08-02 11:07 UTC, Sebastian Dröge (slomo)
none Details | Review
dashdemux: Download any sync-sample following the moof directly in key-units only mode (15.57 KB, patch)
2016-08-02 11:07 UTC, Sebastian Dröge (slomo)
none Details | Review
dashdemux: Collect average moof and first sync sample sizes (4.65 KB, patch)
2016-08-02 11:07 UTC, Sebastian Dröge (slomo)
none Details | Review
adaptivedemux: Add API for allowing subclasses to download URLs in chunks (7.46 KB, patch)
2016-08-02 12:36 UTC, Sebastian Dröge (slomo)
none Details | Review
dashdemux: Download any sync-sample following the moof directly in key-units only mode (15.96 KB, patch)
2016-08-02 15:42 UTC, Sebastian Dröge (slomo)
none Details | Review
dashdemux: Collect average moof and first sync sample sizes (4.51 KB, patch)
2016-08-02 15:42 UTC, Sebastian Dröge (slomo)
none Details | Review
dashdemux: Download any sync-sample following the moof directly in key-units only mode (15.93 KB, patch)
2016-08-03 06:16 UTC, Sebastian Dröge (slomo)
none Details | Review
dashdemux: Remember if for a stream we could do key-units only mode (5.89 KB, patch)
2016-08-03 12:08 UTC, Sebastian Dröge (slomo)
none Details | Review
dashdemux: Implement parsing of ISOBMFF boxes (13.52 KB, patch)
2016-08-04 12:21 UTC, Sebastian Dröge (slomo)
committed Details | Review
dashdemux: Store box fourccs in the header at a central place (2.34 KB, patch)
2016-08-04 12:21 UTC, Sebastian Dröge (slomo)
committed Details | Review
dashdemux: Move code around to keep all sidx related functions together (2.51 KB, patch)
2016-08-04 12:21 UTC, Sebastian Dröge (slomo)
committed Details | Review
dashdemux: Implement parsing of moof box (26.12 KB, patch)
2016-08-04 12:21 UTC, Sebastian Dröge (slomo)
committed Details | Review
dash: Add unit test for ISOBFF box header parsing (5.12 KB, patch)
2016-08-04 12:21 UTC, Sebastian Dröge (slomo)
committed Details | Review
dash: Add test for parsing a moof box (12.35 KB, patch)
2016-08-04 12:21 UTC, Sebastian Dröge (slomo)
committed Details | Review
dashdemux: Store parsed moof and extract offsets of sync samples in it (12.90 KB, patch)
2016-08-04 12:22 UTC, Sebastian Dröge (slomo)
committed Details | Review
dashdemux: Implement downloading of only sync samples (13.07 KB, patch)
2016-08-04 12:22 UTC, Sebastian Dröge (slomo)
committed Details | Review
dashdemux: Only do keyframe-only playback if the corresponding seek flag is given (6.27 KB, patch)
2016-08-04 12:22 UTC, Sebastian Dröge (slomo)
committed Details | Review
dashdemux: Only enable key-unit trick mode for video streams (1.75 KB, patch)
2016-08-04 12:22 UTC, Sebastian Dröge (slomo)
committed Details | Review
dashdemux: Mark every first buffer of moov, sidx, moof and mdat as DISCONT in keyframe-only mode (3.10 KB, patch)
2016-08-04 12:22 UTC, Sebastian Dröge (slomo)
committed Details | Review
adaptivedemux: Add API for allowing subclasses to download URLs in chunks (7.72 KB, patch)
2016-08-04 12:22 UTC, Sebastian Dröge (slomo)
committed Details | Review
dashdemux: Use chunked downloading for the moof in KEY_UNITS mode (6.01 KB, patch)
2016-08-04 12:22 UTC, Sebastian Dröge (slomo)
committed Details | Review
dashdemux: Also allow key-unit only mode if (some) sample flags are given by trex but we can still find sync frames (1.99 KB, patch)
2016-08-04 12:22 UTC, Sebastian Dröge (slomo)
committed Details | Review
dashdemux: Remember if for a stream we could do key-units only mode (5.89 KB, patch)
2016-08-04 12:22 UTC, Sebastian Dröge (slomo)
committed Details | Review
dashdemux: If a fragment contains no sync samples, disable key-unit mode (978 bytes, patch)
2016-08-04 12:23 UTC, Sebastian Dröge (slomo)
committed Details | Review
dashdemux: Download any sync-sample following the moof directly in key-units only mode (18.47 KB, patch)
2016-08-04 12:23 UTC, Sebastian Dröge (slomo)
none Details | Review
dashdemux: Collect average moof and first sync sample sizes (4.51 KB, patch)
2016-08-04 12:23 UTC, Sebastian Dröge (slomo)
committed Details | Review
dashdemux: When doing chunked downloading on SIDX, clip requests on the SIDX entry boundaries (2.58 KB, patch)
2016-08-04 12:23 UTC, Sebastian Dröge (slomo)
none Details | Review
dashdemux: When doing chunked downloading on SIDX, clip requests on the SIDX entry boundaries (2.68 KB, patch)
2016-08-04 12:53 UTC, Sebastian Dröge (slomo)
committed Details | Review
Debug log (667.49 KB, text/plain)
2016-08-04 14:33 UTC, Chris Bass
  Details
dashdemux: Download any sync-sample following the moof directly in key-units only mode (18.70 KB, patch)
2016-08-04 14:54 UTC, Sebastian Dröge (slomo)
committed Details | Review
Debug log (3.34 MB, text/plain)
2016-08-04 15:04 UTC, Chris Bass
  Details

Description A Ashley 2014-12-04 11:14:45 UTC
Dashdemux has support for "trick play" (playback at rates other than 1) that is implemented by downloading fragments more rapidly than when rate==1.

In some situations this approach does not work very well, due to the demands it places upon the bandwidth of the network and the performance of the downstream demux/decode/display elements. For example trick play at rate==32 requires 32x the network bandwidth and the "qtdemux ! h264parse ! avdec-h264" pipeline to cope with 32x the amount of compressed data. A lower bitrate Representation might be able to reduce the demands, but typically there are a limited range of available bitrates. It is unlikely for there to be a suitable Representation for every trickplay rate.

It would be beneficial to enable an I-frame only mode of trick play, whereby only the I-frames from segments are downloaded. This can be used to reduce the burden on the network and also reduces the demands on the downstream elements.

This feature has been enabled for HLS streams. Perhaps as part of the move to the GstAdaptiveDemux base class, this behaviour could be harmonised in the base class? Obviously the method of finding the I-frames is very different between DASH and HLS, but the rate adaptation logic could be common.

Downloading the first I-frame from each segment should be fairly straightforward, as the DASH spec mandates that the first frame in each segment is an IDR. Finding the other I-frames within the segment is more complex, as it would require parsing a box (such as the trun) to find their location.
Comment 1 Chris Bass 2014-12-08 11:16:05 UTC
Created attachment 292295 [details] [review]
Make dashdemux fetch initial I frame from each segment

Attached is a proof-of-concept of I-frame based trickplay for dashdemux. 

The patch modifies dashdemux so that only the first 0.5 seconds (approximately) of each segment is fetched when |rate| > 1.0.

Note that this patch was made before dashdemux was rebased on top of the new adaptivedemux base class; but, as you'll see from the patch, the changes are very small and self-contained.
Comment 2 Chris Bass 2014-12-08 11:22:43 UTC
Created attachment 292297 [details] [review]
Make qtdemux output only first sample from received segments

Attached is a proof-of-concept patch for qtdemux that adds support for I-frame based trickplay.

The patch modifies qtdemux so that when |rate| > 1.0 it extracts and pushes downstream only the first sample from each fragment that it receives, throwing away any remaining data from the fragment that comes after this first sample.

Together with the patch to dashdemux, (patch 292295), this allows I-frame only trickplay for DASH to be demonstrated.
Comment 3 Sebastian Dröge (slomo) 2016-08-02 11:06:04 UTC
Created attachment 332521 [details] [review]
dash: Add helper for parsing box headers
Comment 4 Sebastian Dröge (slomo) 2016-08-02 11:06:09 UTC
Created attachment 332522 [details] [review]
dashdemux: Implement parsing of ISOBMFF boxes
Comment 5 Sebastian Dröge (slomo) 2016-08-02 11:06:15 UTC
Created attachment 332523 [details] [review]
dashdemux: Store box fourccs in the header at a central place
Comment 6 Sebastian Dröge (slomo) 2016-08-02 11:06:21 UTC
Created attachment 332524 [details] [review]
dashdemux: Move code around to keep all sidx related functions together
Comment 7 Sebastian Dröge (slomo) 2016-08-02 11:06:27 UTC
Created attachment 332525 [details] [review]
dashdemux: Implement parsing of moof box
Comment 8 Sebastian Dröge (slomo) 2016-08-02 11:06:33 UTC
Created attachment 332526 [details] [review]
dash: Add unit test for ISOBFF box header parsing
Comment 9 Sebastian Dröge (slomo) 2016-08-02 11:06:40 UTC
Created attachment 332527 [details] [review]
dash: Add test for parsing a moof box
Comment 10 Sebastian Dröge (slomo) 2016-08-02 11:06:45 UTC
Created attachment 332528 [details] [review]
dashdemux: Store parsed moof and extract offsets of sync samples in it
Comment 11 Sebastian Dröge (slomo) 2016-08-02 11:06:52 UTC
Created attachment 332529 [details] [review]
dashdemux: Implement downloading of only sync samples
Comment 12 Sebastian Dröge (slomo) 2016-08-02 11:06:58 UTC
Created attachment 332530 [details] [review]
dashdemux: Only do keyframe-only playback if the corresponding seek flag is given
Comment 13 Sebastian Dröge (slomo) 2016-08-02 11:07:04 UTC
Created attachment 332531 [details] [review]
dashdemux: Only enable key-unit trick mode for video streams
Comment 14 Sebastian Dröge (slomo) 2016-08-02 11:07:10 UTC
Created attachment 332532 [details] [review]
dashdemux: Mark every first buffer of moov, sidx, moof and mdat as DISCONT in keyframe-only mode

We need to mark every first buffer of a key unit as discont, and also every
first buffer of a moov and moof. This ensures that qtdemux takes note of our
buffer offsets for each of those buffers instead of keeping track of them
itself from the first buffer. We need offsets to be consistent between moof
and mdat
Comment 15 Sebastian Dröge (slomo) 2016-08-02 11:07:17 UTC
Created attachment 332533 [details] [review]
adaptivedemux: Add API for allowing subclasses to download URLs in chunks

This allows to gradually download part of a fragment when the final size is
not known and only a part of it should be downloaded. For example when only
the moof should be parsed and/or a single keyframe should be downloaded.
Comment 16 Sebastian Dröge (slomo) 2016-08-02 11:07:23 UTC
Created attachment 332534 [details] [review]
dashdemux: Use chunked downloading for the moof in KEY_UNITS mode

Allows us to reuse the HTTP connection and reduce latencies a lot.
Comment 17 Sebastian Dröge (slomo) 2016-08-02 11:07:30 UTC
Created attachment 332535 [details] [review]
dashdemux: Also allow key-unit only mode if (some) sample flags are given by trex but we can still find sync frames
Comment 18 Sebastian Dröge (slomo) 2016-08-02 11:07:36 UTC
Created attachment 332536 [details] [review]
dashdemux: Remember if for a stream we could do key-units only mode

This makes sure we don't even try going into that mode if we previously saw
that the stream does not have the suitable metadata.
Comment 19 Sebastian Dröge (slomo) 2016-08-02 11:07:42 UTC
Created attachment 332537 [details] [review]
dashdemux: If a fragment contains no sync samples, disable key-unit mode
Comment 20 Sebastian Dröge (slomo) 2016-08-02 11:07:48 UTC
Created attachment 332538 [details] [review]
dashdemux: Download any sync-sample following the moof directly in key-units only mode

We don't have to do yet another additional request but can just download the
data directly.

Also unify the key-unit only mode buffer pushing and extract it into its own
function now that it became more complicated.
Comment 21 Sebastian Dröge (slomo) 2016-08-02 11:07:54 UTC
Created attachment 332539 [details] [review]
dashdemux: Collect average moof and first sync sample sizes

And always request those in the beginning so that ideally we get the moof and
the first sync sample all together with the first HTTP request.
Comment 22 Sebastian Dröge (slomo) 2016-08-02 11:09:21 UTC
On top of this, a few optimizations are still pending. Namely deciding to jump ahead a few fragments/keyframes if the rate is high enough and/or we can't keep up due to network/CPU reasons, but apart from that this (together with latest GIT of everything which also contains relevant changes) works on many DASH streams.
Comment 23 Sebastian Dröge (slomo) 2016-08-02 12:36:03 UTC
Created attachment 332548 [details] [review]
adaptivedemux: Add API for allowing subclasses to download URLs in chunks

This allows to gradually download part of a fragment when the final size is
not known and only a part of it should be downloaded. For example when only
the moof should be parsed and/or a single keyframe should be downloaded.
Comment 24 Sebastian Dröge (slomo) 2016-08-02 15:42:02 UTC
Created attachment 332576 [details] [review]
dashdemux: Download any sync-sample following the moof directly in key-units only mode

We don't have to do yet another additional request but can just download the
data directly.

Also unify the key-unit only mode buffer pushing and extract it into its own
function now that it became more complicated.
Comment 25 Sebastian Dröge (slomo) 2016-08-02 15:42:19 UTC
Created attachment 332577 [details] [review]
dashdemux: Collect average moof and first sync sample sizes

And always request those in the beginning so that ideally we get the moof and
the first sync sample all together with the first HTTP request.
Comment 26 Sebastian Dröge (slomo) 2016-08-03 06:16:52 UTC
Created attachment 332603 [details] [review]
dashdemux: Download any sync-sample following the moof directly in key-units only mode

We don't have to do yet another additional request but can just download the
data directly.

Also unify the key-unit only mode buffer pushing and extract it into its own
function now that it became more complicated.
Comment 27 Sebastian Dröge (slomo) 2016-08-03 12:08:47 UTC
Created attachment 332608 [details] [review]
dashdemux: Remember if for a stream we could do key-units only mode

This makes sure we don't even try going into that mode if we previously saw
that the stream does not have the suitable metadata.
Comment 28 Chris Bass 2016-08-04 09:52:24 UTC
It crashes for me soon after selecting a fast-forward speed:

[...]
0:00:05.220959076 25082  0x89cbd50 WARN           adaptivedemux gstadaptivedemux.c:2194:_src_chain:<dashdemux0> Bitrate for fragment not available
0:00:05.221459957 25082  0x8c15890 WARN                 qtdemux qtdemux.c:6422:gst_qtdemux_process_adapter:<qtdemux0> Unknown fourcc while parsing header : gd. 
0:00:05.221503952 25082  0x8c15890 WARN                 qtdemux qtdemux.c:6235:gst_qtdemux_process_adapter:<qtdemux0> error: This file is invalid and cannot be played.
0:00:05.221513928 25082  0x8c15890 WARN                 qtdemux qtdemux.c:6235:gst_qtdemux_process_adapter:<qtdemux0> error: atom ...j has bogus size 3808834240
0:00:05.221755729 25082  0x89cbd50 WARN           adaptivedemux gstadaptivedemux.c:2228:_src_chain:<dashdemux0> error: stream stopped, reason error
0:00:05.222964724 25082  0x8c157b0 WARN           adaptivedemux gstadaptivedemux.c:3291:gst_adaptive_demux_stream_download_loop:<dashdemux0> Error while downloading fragment
**
GStreamer:ERROR:gstpoll.c:1361:gst_poll_wait: assertion failed: ("Value of time " "timeout" " is out of timespec's range" && ((timeout) / GST_SECOND) < G_MAXLONG)
Aborted


(That was using GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_TRICKMODE_KEY_UNITS as seek flags.)
Comment 29 Sebastian Dröge (slomo) 2016-08-04 09:57:15 UTC
On which stream, and are you using GIT master of everything?
Comment 30 Chris Bass 2016-08-04 10:04:56 UTC
http://test-media.youview.co.uk/ondemand/bbb/trickplay/client_manifest.mpd

I applied the patches on top of commit dc6e4ccb of plugins-bad (i.e., from 12:54 yesterday). Everything else was the git master as of Monday morning. But I'll try updating everything to see if it makes a difference.
Comment 31 Sebastian Dröge (slomo) 2016-08-04 12:21:26 UTC
Created attachment 332710 [details] [review]
dashdemux: Implement parsing of ISOBMFF boxes
Comment 32 Sebastian Dröge (slomo) 2016-08-04 12:21:32 UTC
Created attachment 332711 [details] [review]
dashdemux: Store box fourccs in the header at a central place
Comment 33 Sebastian Dröge (slomo) 2016-08-04 12:21:38 UTC
Created attachment 332712 [details] [review]
dashdemux: Move code around to keep all sidx related functions together
Comment 34 Sebastian Dröge (slomo) 2016-08-04 12:21:45 UTC
Created attachment 332713 [details] [review]
dashdemux: Implement parsing of moof box
Comment 35 Sebastian Dröge (slomo) 2016-08-04 12:21:51 UTC
Created attachment 332714 [details] [review]
dash: Add unit test for ISOBFF box header parsing
Comment 36 Sebastian Dröge (slomo) 2016-08-04 12:21:58 UTC
Created attachment 332715 [details] [review]
dash: Add test for parsing a moof box
Comment 37 Sebastian Dröge (slomo) 2016-08-04 12:22:05 UTC
Created attachment 332716 [details] [review]
dashdemux: Store parsed moof and extract offsets of sync samples in it
Comment 38 Sebastian Dröge (slomo) 2016-08-04 12:22:12 UTC
Created attachment 332717 [details] [review]
dashdemux: Implement downloading of only sync samples
Comment 39 Sebastian Dröge (slomo) 2016-08-04 12:22:17 UTC
Created attachment 332718 [details] [review]
dashdemux: Only do keyframe-only playback if the corresponding seek flag is given
Comment 40 Sebastian Dröge (slomo) 2016-08-04 12:22:25 UTC
Created attachment 332719 [details] [review]
dashdemux: Only enable key-unit trick mode for video streams
Comment 41 Sebastian Dröge (slomo) 2016-08-04 12:22:32 UTC
Created attachment 332720 [details] [review]
dashdemux: Mark every first buffer of moov, sidx, moof and mdat as DISCONT in keyframe-only mode

We need to mark every first buffer of a key unit as discont, and also every
first buffer of a moov and moof. This ensures that qtdemux takes note of our
buffer offsets for each of those buffers instead of keeping track of them
itself from the first buffer. We need offsets to be consistent between moof
and mdat
Comment 42 Sebastian Dröge (slomo) 2016-08-04 12:22:38 UTC
Created attachment 332721 [details] [review]
adaptivedemux: Add API for allowing subclasses to download URLs in chunks

This allows to gradually download part of a fragment when the final size is
not known and only a part of it should be downloaded. For example when only
the moof should be parsed and/or a single keyframe should be downloaded.
Comment 43 Sebastian Dröge (slomo) 2016-08-04 12:22:44 UTC
Created attachment 332722 [details] [review]
dashdemux: Use chunked downloading for the moof in KEY_UNITS mode

Allows us to reuse the HTTP connection and reduce latencies a lot.
Comment 44 Sebastian Dröge (slomo) 2016-08-04 12:22:51 UTC
Created attachment 332723 [details] [review]
dashdemux: Also allow key-unit only mode if (some) sample flags are given by trex but we can still find sync frames
Comment 45 Sebastian Dröge (slomo) 2016-08-04 12:22:58 UTC
Created attachment 332724 [details] [review]
dashdemux: Remember if for a stream we could do key-units only mode

This makes sure we don't even try going into that mode if we previously saw
that the stream does not have the suitable metadata.
Comment 46 Sebastian Dröge (slomo) 2016-08-04 12:23:04 UTC
Created attachment 332725 [details] [review]
dashdemux: If a fragment contains no sync samples, disable key-unit mode
Comment 47 Sebastian Dröge (slomo) 2016-08-04 12:23:11 UTC
Created attachment 332726 [details] [review]
dashdemux: Download any sync-sample following the moof directly in key-units only mode

We don't have to do yet another additional request but can just download the
data directly.

Also unify the key-unit only mode buffer pushing and extract it into its own
function now that it became more complicated.
Comment 48 Sebastian Dröge (slomo) 2016-08-04 12:23:18 UTC
Created attachment 332727 [details] [review]
dashdemux: Collect average moof and first sync sample sizes

And always request those in the beginning so that ideally we get the moof and
the first sync sample all together with the first HTTP request.
Comment 49 Sebastian Dröge (slomo) 2016-08-04 12:23:25 UTC
Created attachment 332728 [details] [review]
dashdemux: When doing chunked downloading on SIDX, clip requests on the SIDX entry boundaries
Comment 50 Sebastian Dröge (slomo) 2016-08-04 12:30:43 UTC
(In reply to Chris Bass from comment #30)
> http://test-media.youview.co.uk/ondemand/bbb/trickplay/client_manifest.mpd
> 
> I applied the patches on top of commit dc6e4ccb of plugins-bad (i.e., from
> 12:54 yesterday). Everything else was the git master as of Monday morning.
> But I'll try updating everything to see if it makes a difference.

It's important that you have the latest of everything at the time I created the patches. Edward and I added various other commits to other elements which were pushed already.
Comment 51 Chris Bass 2016-08-04 12:42:11 UTC
(In reply to Sebastian Dröge (slomo) from comment #50)
[...]
> 
> It's important that you have the latest of everything at the time I created
> the patches. Edward and I added various other commits to other elements
> which were pushed already.

It didn't make a difference, unfortunately. And getting the same problem with your latest patches.
Comment 52 Sebastian Dröge (slomo) 2016-08-04 12:53:55 UTC
Created attachment 332730 [details] [review]
dashdemux: When doing chunked downloading on SIDX, clip requests on the SIDX entry boundaries
Comment 53 Sebastian Dröge (slomo) 2016-08-04 12:55:48 UTC
(In reply to Chris Bass from comment #51)
> (In reply to Sebastian Dröge (slomo) from comment #50)
> [...]
> > 
> > It's important that you have the latest of everything at the time I created
> > the patches. Edward and I added various other commits to other elements
> > which were pushed already.
> 
> It didn't make a difference, unfortunately. And getting the same problem
> with your latest patches.

That's curious. Are you testing with gst-plugins-base/tests/examples/playback ? If not, please use that so we have the same base and then get me a debug log with GST_DEBUG=3,adaptive*:6,dash*:6

The error you get looks like you use qtdemux without the gap support though.
Comment 54 Chris Bass 2016-08-04 14:33:07 UTC
Created attachment 332732 [details]
Debug log

Debug log from gst-plugins-base/tests/examples/playback.
Comment 55 Sebastian Dröge (slomo) 2016-08-04 14:45:43 UTC
That's missing this debug output for example: https://cgit.freedesktop.org/gstreamer/gst-plugins-good/tree/gst/isomp4/qtdemux.c#n6036
Comment 56 Sebastian Dröge (slomo) 2016-08-04 14:54:48 UTC
Created attachment 332734 [details] [review]
dashdemux: Download any sync-sample following the moof directly in key-units only mode

We don't have to do yet another additional request but can just download the
data directly.

Also unify the key-unit only mode buffer pushing and extract it into its own
function now that it became more complicated.
Comment 57 Chris Bass 2016-08-04 15:04:31 UTC
Created attachment 332736 [details]
Debug log

Debug log from gst-plugins-base/tests/examples/playback.

...now featuring qtdemux:6, too :)
Comment 58 Sebastian Dröge (slomo) 2016-08-04 15:07:57 UTC
I think that one is fixed as part for attachment 332734 [details] [review] (which I just attached).
Comment 59 Chris Bass 2016-08-05 08:34:36 UTC
(In reply to Sebastian Dröge (slomo) from comment #58)
> I think that one is fixed as part for attachment 332734 [details] [review] [review]
> (which I just attached).

Yes, that's fixed the crashing - thanks.
Comment 60 Sebastian Dröge (slomo) 2016-08-05 08:54:59 UTC
For streams using sidx, you also have to revert this revert: https://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=aea2c13fc1672a7260679d706d0a084a34ba7531

Other than what the commit message says, the commit is correct from my current understanding. Just the unit test is wrong: it claims to pass dash with mp4 and sidx to the demuxer, but the actual media is random bytes. As such when we use the fragment info from the sidx (which we should as the manifest might not contain anything at all, always sending us back to 0 on seeks) we would have no info and go to the inaccurate fallback case.
IMHO these unit tests should be disabled until they produce valid data, or completely replaced with validate tests on real streams. As they're now they make no sense and only work because of how the demuxer currently works exactly.
Comment 61 Chris Bass 2016-08-09 10:30:08 UTC
Review of attachment 332716 [details] [review]:

::: ext/dash/gstdashdemux.c
@@ +2021,3 @@
+
+        /* Non-non-sync sample aka sync sample */
+        if (!GST_ISOFF_SAMPLE_FLAGS_SAMPLE_IS_NON_SYNC_SAMPLE (sample_flags)) {

The code is only looking for sync samples, so when it runs it only extracts the IDR frame at the beginning of the segments, and not the other I-frames in the segment. It needs also to add frames whose sample_flags include sample_depends_on == 2.

I tried adding the following here:

if (!GST_ISOFF_SAMPLE_FLAGS_SAMPLE_IS_NON_SYNC_SAMPLE (sample_flags)
       || (GST_ISOFF_SAMPLE_FLAGS_SAMPLE_DEPENDS_ON (sample_flags)
           == 0x2)) {

...and that worked well for fast-forward speeds up to about 10x, beyond which there wasn't enough network throughput to download all the I-frames from each segment. It didn't appear to work so well for fast-reverse - it definitely didn't look like all the I-frames were being displayed in that case.

If the intention for this code is to assemble a table of all IDR & I-frames in a segment, then the use of *sync_samples in the names here is a bit misleading - it would probably be better to rename things (e.g., *independent_samples, or something like that).
Comment 62 Sebastian Dröge (slomo) 2016-08-11 10:02:58 UTC
Attachment 332521 [details] pushed as 37ff8ab - dash: Add helper for parsing box headers
Attachment 332710 [details] pushed as 0b0a1a5 - dashdemux: Implement parsing of ISOBMFF boxes
Attachment 332711 [details] pushed as c4ad30d - dashdemux: Store box fourccs in the header at a central place
Attachment 332712 [details] pushed as 7d4f6ca - dashdemux: Move code around to keep all sidx related functions together
Attachment 332713 [details] pushed as fff814b - dashdemux: Implement parsing of moof box
Attachment 332714 [details] pushed as e3805e4 - dash: Add unit test for ISOBFF box header parsing
Attachment 332715 [details] pushed as 6dbfb11 - dash: Add test for parsing a moof box
Attachment 332716 [details] pushed as 5b94313 - dashdemux: Store parsed moof and extract offsets of sync samples in it
Attachment 332717 [details] pushed as 70bc183 - dashdemux: Implement downloading of only sync samples
Attachment 332718 [details] pushed as 9dd8789 - dashdemux: Only do keyframe-only playback if the corresponding seek flag is given
Attachment 332719 [details] pushed as 12c2415 - dashdemux: Only enable key-unit trick mode for video streams
Attachment 332720 [details] pushed as 7b4fe1e - dashdemux: Mark every first buffer of moov, sidx, moof and mdat as DISCONT in keyframe-only mode
Attachment 332721 [details] pushed as a9e38d3 - adaptivedemux: Add API for allowing subclasses to download URLs in chunks
Attachment 332722 [details] pushed as 47ef88f - dashdemux: Use chunked downloading for the moof in KEY_UNITS mode
Attachment 332723 [details] pushed as b936c00 - dashdemux: Also allow key-unit only mode if (some) sample flags are given by trex but we can still find sync frames
Attachment 332724 [details] pushed as cfad48c - dashdemux: Remember if for a stream we could do key-units only mode
Attachment 332725 [details] pushed as f8eddab - dashdemux: If a fragment contains no sync samples, disable key-unit mode
Attachment 332727 [details] pushed as 9c04d1e - dashdemux: Collect average moof and first sync sample sizes
Attachment 332730 [details] pushed as 18e5e64 - dashdemux: When doing chunked downloading on SIDX, clip requests on the SIDX entry boundaries
Attachment 332734 [details] pushed as 7f1f777 - dashdemux: Download any sync-sample following the moof directly in key-units only mode
Comment 63 Sebastian Dröge (slomo) 2016-08-18 10:30:11 UTC
(In reply to Chris Bass from comment #61)
> Review of attachment 332716 [details] [review] [review]:
> 
> ::: ext/dash/gstdashdemux.c
> @@ +2021,3 @@
> +
> +        /* Non-non-sync sample aka sync sample */
> +        if (!GST_ISOFF_SAMPLE_FLAGS_SAMPLE_IS_NON_SYNC_SAMPLE
> (sample_flags)) {
> 
> The code is only looking for sync samples, so when it runs it only extracts
> the IDR frame at the beginning of the segments, and not the other I-frames
> in the segment. It needs also to add frames whose sample_flags include
> sample_depends_on == 2.
> 
> I tried adding the following here:
> 
> if (!GST_ISOFF_SAMPLE_FLAGS_SAMPLE_IS_NON_SYNC_SAMPLE (sample_flags)
>        || (GST_ISOFF_SAMPLE_FLAGS_SAMPLE_DEPENDS_ON (sample_flags)
>            == 0x2)) {
> 
> ...and that worked well for fast-forward speeds up to about 10x, beyond
> which there wasn't enough network throughput to download all the I-frames
> from each segment. It didn't appear to work so well for fast-reverse - it
> definitely didn't look like all the I-frames were being displayed in that
> case.

That's also solved now:

http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=e786f737ae83fb009ffcf599c3e0dce6ecab67a7