pub struct DashDownloader {
    pub mpd_url: String,
    pub output_path: Option<PathBuf>,
    pub ffmpeg_location: String,
    pub vlc_location: String,
    pub mkvmerge_location: String,
    /* private fields */
}
Expand description

The DashDownloader allows the download of streaming media content from a DASH MPD manifest. This involves fetching the manifest file, parsing it, identifying the relevant audio and video representations, downloading all the segments, concatenating them then muxing the audio and video streams to produce a single video file including audio. This should work with both MPEG-DASH MPD manifests (where the media segments are typically placed in MPEG-2 TS containers) and for WebM-DASH.

Fields§

§mpd_url: String§output_path: Option<PathBuf>§ffmpeg_location: String§vlc_location: String§mkvmerge_location: String

Implementations§

The DashDownloader follows the builder pattern to allow various optional arguments concerning the download of DASH media content (preferences concerning bitrate/quality, specifying an HTTP proxy, etc.).

Example

use dash_mpd::fetch::DashDownloader;

let url = "https://storage.googleapis.com/shaka-demo-assets/heliocentrism/heliocentrism.mpd";
match DashDownloader::new(url)
       .worst_quality()
       .download()
{
   Ok(path) => println!("Downloaded to {path:?}"),
   Err(e) => eprintln!("Download failed: {e}"),
}

Create a DashDownloader for the specified DASH manifest URL mpd_url.

Specify the reqwest Client to be used for HTTP requests that download the DASH streaming media content. Allows you to specify a proxy, the user agent, custom request headers, request timeouts, etc.

Example

use dash_mpd::fetch::DashDownloader;

let client = reqwest::blocking::Client::builder()
     .user_agent("Mozilla/5.0")
     .timeout(Duration::new(10, 0))
     .gzip(true)
     .build()
     .expect("creating reqwest HTTP client");
 let url = "https://cloudflarestream.com/31c9291ab41fac05471db4e73aa11717/manifest/video.mpd";
 let out = PathBuf::from(env::temp_dir()).join("cloudflarestream.mp4");
 DashDownloader::new(url)
     .with_http_client(client)
     .download_to(out)

Add a observer implementing the ProgressObserver trait, that will receive updates concerning the progression of the download (allows implementation of a progress bar, for example).

If the DASH manifest specifies several Adaptations with different bitrates (levels of quality), prefer the Adaptation with the highest bitrate (largest output file).

If the DASH manifest specifies several Adaptations with different bitrates (levels of quality), prefer the Adaptation with the lowest bitrate (smallest output file).

Preferred language when multiple audio streams with different languages are available. Must be in RFC 5646 format (eg. “fr” or “en-AU”). If a preference is not specified and multiple audio streams are present, the first one listed in the DASH manifest will be downloaded.

If the media stream has separate audio and video streams, only download the video stream.

If the media stream has separate audio and video streams, only download the audio stream.

Don’t delete the file containing video once muxing is complete.

Don’t delete the file containing audio once muxing is complete.

Don’t check that the content-type of downloaded segments corresponds to audio or video content (may be necessary with poorly configured HTTP servers).

Specify a number of seconds to sleep between network requests (default 0). This provides a primitive mechanism for throttling bandwidth consumption.

Set the verbosity level of the download process. Possible values for level:

  • 0: no information is printed
  • 1: basic information on the number of Periods and bandwidth of selected representations
  • 2: information above + segment addressing mode
  • 3 or larger: information above + size of each downloaded segment

If record is true, record metainformation concerning the media content (origin URL, title, source and copyright metainformation) if present in the manifest as extended attributes in the output file.

Specify the location of the ffmpeg application, if not located in PATH.

Example

#[cfg(target_os = "unix")]
let ddl = ddl.with_ffmpeg("/opt/ffmpeg-next/bin/ffmpeg");

Specify the location of the VLC application, if not located in PATH.

Example

#[cfg(target_os = "windows")]
let ddl = ddl.with_vlc("C:/Program Files/VideoLAN/VLC/vlc.exe");

Specify the location of the mkvmerge application, if not located in PATH.

Download DASH streaming media content to the file named by out. If the output file out already exists, its content will be overwritten.

Note that the media container format used when muxing audio and video streams depends on the filename extension of the path out. If the filename extension is .mp4, an MPEG-4 container will be used; if it is .mkv a Matroska container will be used, and otherwise the heuristics implemented by ffmpeg will apply (e.g. an .avi extension will generate an AVI container).

Download DASH streaming media content to a file in the current working directory and return the corresponding PathBuf. The name of the output file is derived from the manifest URL. The output file will be overwritten if it already exists.

The downloaded media will be placed in an MPEG-4 container. To select another media container, see the download_to function.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more