How to Download MPEG-DASH Video Streams
You may have used DASH today to watch a video, however turning that streamed video into a watchable file can be difficult. Here, we show you how to save it to be watched later.
Like HLS (HTTP Live Streaming), MPEG-DASH (Dynamic Adaptive Streaming over HTTP) is one of the most popular methods to transmit video streams over the internet. Both streaming protocols slice a media file into segments, encode them into different qualities, and delivers them to a user's video player without having to load a large media file. So, what's the difference? Well, not much for the viewer of the video! HLS is considered slightly more widely adopted since it was built by Apple first but, both standards share much of the same features. Since both streaming protocols are used extensively by large media companies and served by CDNs, it is beneficial to understand how to download both.
How to find MPEG-DASH Streams
Unlike HLS which uses .m3u8 files to deliver a stream, DASH uses .mpd files as manifest files. These manifest files are used as maps to where the stream's video segments are located. If you have the manifest, you can rewatch the stream or even download the video. If you read our previous post on how to download HLS streams, you'll be familiar with this search process. First, go to a video you want to watch and then use the keyboard shortcut, "CTRL+SHIFT+I", to pop open your browser's developer tools. This shortcut works for both Google Chrome and Firefox. Then, click on the Network tab. This displays all the resources that are requested by your browser when a page loads and even afterwards. If you play the video, you will see that your browser will request video segments.
Since DASH manifests use .mpd files, we want to filter the resources by that file extension. Enter .mpd in the filter input at the top left of the network tab. Manifest files are often named "master" or "index" and may even be converted to JSON files. So, searching for "master.json" might work as well and then we change the link to "master.mpd" once it is found. Make sure the video is paused before so that we don't fill the resources list with unneeded files and if needed, refresh the page. If a .mpd file is not visible, it is likely that another streaming protocol such as HLS is being used. However, if the manifest file is located, right click it and copy the URL.
Just for educational purposes, download and open the manifest in a text editor such as Sublime Text or Notepad++. Once the file is opened, you will notice that the .mpd manifest is specially formatted XML file. Instead of breaking the variants into separate manifests like HLS does, DASH stores all the metadata pertaining to every stream and their video segments in one file. Convenient!
<BaseURL>https://vod-gcs-cedexis.cbsaavideo.com/intl_vms/2022/11/03/2098871363505/1771255_cenc_precon_dash/</BaseURL> <Period id="pre-roll-1-ad-1" duration="PT30.03S"> <BaseURL>https://dai.google.com/segments/redirect/c/</BaseURL> <AdaptationSet id="0" contentType="audio"> <Representation audioSamplingRate="48000" mimeType="audio/mp4" codecs="mp4a.40.2" id="6" bandwidth="129000"> <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/> <SegmentTemplate timescale="48000" startNumber="1" media="$Number$.mp4"> <SegmentTimeline> <S d="479232" r="2"/> <S d="6144"/> </SegmentTimeline> </SegmentTemplate> </Representation> </AdaptationSet> <AdaptationSet startWithSAP="1" id="1" contentType="video" minFrameRate="25" maxFrameRate="30000/1001" segmentAlignment="true"> <Representation width="1920" height="1080" frameRate="30000/1001" mimeType="video/mp4" codecs="avc1.640028" id="4" bandwidth="4004000"> <SegmentTemplate timescale="90000" startNumber="1" media="$Number$.mp4?"> <SegmentTimeline> <S d="450450" r="5"/> </SegmentTimeline> </SegmentTemplate> </Representation> </AdaptationSet> </Period>
Downloading the DASH Stream without Command Line
If you want to avoid the command line, downloading programs, and computer code, signup for Sorcerer account. We suggest starting the basic plan to get acclimated with the tool. Then, head over to the processes page and click the plus icon at the top right. Fill out the form with our copied URL and select the cloud connection you want to download the video into. Click on the create button at the bottom right to fetch the manifest's variants.
Once the manifest is extracted, Sorcerer presents the variants ordered by their length, resolution, and bitrate. You can select the video, audio, and subtitles that you want to include in the .mp4 file. Although Sorcerer can download most manifests and variants, there are some limitations. The first one is that we cannot download encrypted streams. If you use a streaming service such as HBO Max, Apple TV+, or Netflix, they encrypt their streams so we cannot download them and Sorcerer will return an error message. Additionally, we can only mix stream components that are designed to go together. We cannot select a 13:51 minute video variant and a 8:41 audio stream. Third, if the stream is locked behind a login, Sorcerer will not be able to access it. Next, Sorcerer cannot download livestreams. Lastly, we can add a maximum of ten subtitles to the output file.
Go ahead and select the components that you need and click the create button at the bottom right. Afterwards, click on the newly created process to track its status.
It's that simple when using Sorcerer. If you want a more hands-on approach, let's run through how to download streams using the command line.
Getting the Tools Necessary for Downloading DASH Streams
First, lets download the programming language Python. A ton of tools used to scrape data and manipulate files are built using the language so, it is beneficial to acquaint ourselves with it. Download the latest version here. Once we have installed the language, we have to download libraries that expand its out-of-the-box capabilities. The primary library we will be using is yt-dlp which is used to download videos from a wide variety of sources. To install the library, go to your command line and run the command below:
pip install yt-dlp
Once that the package is installed, we will have to download FFmpeg. FFmpeg is a library used to manipulate video and audio files and it is necessary because we will have to merge the video and audio stream components together. You can download the "essentials" 7zip archive here. Extract the ffmpeg 7zip into the root C:/ as a folder named "ffmpeg". Make sure that this ffmpeg folder contains the folder "bin". Once you have done that, we will have to edit the PATH environmental variable so that yt-dlp is aware of ffmpeg's location. Open your command line as an administrator and paste in the below command:
setx /m PATH "C:\ffmpeg\bin;%PATH%"
After that is run, we can verify that ffmpeg is properly installed by restarting the command line and requesting ffmpeg's version. It should return metadata related to the ffmpeg currently installed on your computer.
Downloading the DASH Stream with Python and the Command Line
Now that all the essentials tool have been acquired, we can now properly start downloading some videos using yt-dlp. In your command line, paste in the below command with your manifest's URL replacing "YOUR_MANIFEST_URL". The program will then list out every stream contained in the manifest so we can choose the ones we need.
yt-dlp -F YOUR_MANIFEST_URL
Like Sorcerer, yt-dlp will list out the metadata pertaining to each stream. For a more expert experience, we can read the list of formats and select the specific audio and video IDs we want to include in the merged file. To download your chosen audio and video streams and merge them into file, the command is below. You want to join the IDs together with "+". By default, yt-dlp downloads the new file into the folder where the program is being run from. If you want to change the download location, include the --output/-o argument with your preferred folder path in the command.
yt-dlp -f THE_AUDIO_FORMAT_ID+THE_VIDEO_FORMAT_ID --output "C:/THE/DOWNLOAD/LOCATION/FILENAME.mp4" "YOUR_MANIFEST_URL"
yt-dlp will download the formats, merge them into one file, and place it in the specified output location. By default, yt-dlp will download the best formats however, if you want to know the command to seem like a pro, it is below.
yt-dlp -f bestvideo+bestaudio --output "C:/THE/DOWNLOAD/LOCATION/FILENAME.mp4" "YOUR_MANIFEST_URL"
To download the best audio as a .mp3 file, use the below command. The -x flag extracts the audio from the stream if it contains audio and the --audio-format flag determines what the audio file type will be.
yt-dlp -f 'bestaudio' -x --audio-format mp3 -o "C:/THE/DOWNLOAD/LOCATION/FILENAME.mp3" "YOUR_MANIFEST_URL"
You have now learned the dark arts. yt-dlp is also compatible with HLS streams, so the steps above are exactly the same with .m3u8 manifests. We hope your needs have been met even if Sorcerer is not the tool you will using in the future. If you want to continue to receive news and tutorials related to our file transferring exploits and addons, please sign up for our newsletter.