This patch adds multithreading support to DASH initialization. Initializing 
DASH streams is currently slow, because each individual stream is opened and 
probed sequentially. With DASH streams often having somewhere between 10-20 
substreams, this can easily take up to half a minute on slow connections. This 
patch adds an "init-threads" option, specifying the max number of threads to 
use for parallel probing and initialization of substreams. If "init-threads" is 
set to a value larger than 1, multiple worker threads are spun up to massively 
bring down init times.

Here is a free DASH stream for testing:

http://www.bok.net/dash/tears_of_steel/cleartext/stream.mpd

It has 7 substreams. I currently get init times of 3.5 seconds without patch. 
The patch brings it down to about 0.5 seconds, so using 7 threads nearly cut 
down init times by factor 7. On a slower connection (100mbit), the same stream 
took 7-8 seconds to initialize, the patch brought it down to just over 1 second.

In the current patch, the behavior is disabled by default (init-threads = 0). 
But I think it could make sense to enable it by default, maybe with a 
reasonable value of 8? Not sure though, open for discussion.

Some notes on the actual implementation:
- DASH streams sometimes share a common init section. If this is the case, a 
mutex and condition is used, to make sure that the first stream reads the 
common section before the following streams start initialization.
- Only the init and probing part is done in parallel. After all threads are 
joined, I collect the results and add the AVStreams to the parent 
AVFormatContext. That is why I split open_demux_for_component() into 
begin_open_demux_for_component() and end_open_demux_for_component().
- I tried to do this as clean as possible and added multiple comments.
- Multithreading is never simple, so a proper review is needed.

If this gets merged, I might try to do the same for HLS.

This is my first PR by the way, so please be nice :)

Lukas

Attachment: 0001-lavf-dashdec-Multithreaded-DASH-initialization.patch
Description: Binary data

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to