Search code examples
downloadmpeg-dashyoutube-dl

Given a MPEG DASH .mpd URL, is that possible to down all media segments through youtube_dl?


I'm looking for a MPEG DASH downloader and youtube_dl just hit on me.

Given a .mpd URL, is that possible to use youtube_dl to download all media segments then?


Solution

  • To download all video and audio segments and mux them into a single file, call youtube-dl thus:

    youtube-dl -f bestvideo+bestaudio http://URL/TO/manifest.mpd
    

    The option -f <id1>[,<id2>]... is used to select which stream (or streams) of segments to save. The -f bestvideo+bestaudio in this example makes youtube-dl save only the best video and audio streams. See format selection syntax for details and more advanced format selectors. In order to discover the available streams, use youtube-dl -F http://URL/TO/manifest.mpd.

    In order to mux (merge) video and audio streams into a single file, you must have FFmpeg or libav installed in your system. Otherwise, youtube-dl will produce a separate file for each stream (in my example, one for audio and one for video).

    Without explicit format selection, the default is -f bestvideo+bestaudio/best. Youtube-dl will automatically select the best video and audio, and if there are no separate video-only or audio-only streams, the best stream that contains both video and audio is selected.

    youtube-dl http://URL/TO/manifest.mpd
    

    This default is used since version 2015.04.26. Before that (or if -o - is specified, making youtube-dl write output to stdout), the default was -f best, ignoring the video-only and audio-only streams. You may want to specify -f best explicitly when separate video and audio have worse quality than a stream that has both.