YouTube uses Dynamic Adaptive Streaming over HTTP ( DASH ) for delivering videos and along with that, it serves the audio and video in two separate streams for some resolutions/formats. For instance, resolutions like 1080p and 480p are available only with separate audio and video streams.





youtube-dl, a popular command line tool for downloading videos from YouTube and other similar websites, was updated recently with proper support for DASH and separate audio and video streams: the tool can now automatically combine / merge / multiplex the audio and video formats offered by YouTube.

Here's an example via cynic.cc for downloading separate audio and video streams from YouTube and combining them automatically using youtube-dl (which uses ffmpeg or avconv under the hood):

"Now, if you want a 480p video in H.264 format, High profile, with 128kbps AAC audio (this used to be Youtube's format 35), you can specify format -f 135+140 on the command-line and it will download both the audio, the video and multiplex it with ffmpeg (or avconv, depending on what you have installed)."

And that's not all, a lot of other improvements and fixes are added daily to this command line download tool.





For instance, since our previous article about youtube-dl , the downloader received support for many websites, including: Vevo, 9gag, discovery.com, vk.com, southpark.de, myspace.com, vube.com, vesti.ru, stream.cz, ndr.de, onf.ca, Dropbox and so on, along with many fixes and improvements.





For those not familiar with youtube-dl, this command line video downloader not only supports hundreds of websites, but it can also extract the audio automatically, download playlists, download and embed subtitles into videos and more.

Install youtube-dl in Ubuntu

The latest youtube-dl 2014.02.17 is available in the Ubuntu 14.04 Trusty Tahr repository but it wasn't backported for older Ubuntu versions. Install it via Ubuntu Software Center or by using the following command:

sudo apt-get install youtube-dl

For older Ubuntu versions (though I also recommend it for Ubuntu 14.04), you can install youtube-dl by using the main WebUpd8 PPA.





As a reminder, I update youtube-dl from the WebUpd8 PPA a few times a week, so if YouTube or another website make changes that break it, run an update and it's very likely that a new youtube-dl version will be available, which fixes the issues.





To add the main WebUpd8 PPA and install youtube-dl in Ubuntu and derivatives (Linux Mint, elementary OS and so on), use the following commands:

sudo add-apt-repository ppa:nilarimogard/webupd8 sudo apt-get update sudo apt-get install youtube-dl

Using youtube-dl to download videos

To download a video, simply use the following command:

youtube-dl http://VIDEO_URL

If you don't use any parameters, youtube-dl tries to download the best format. For YouTube, by default it downloads the best non-DASH format, which usually is 720p mp4 for YouTube.

How to download 1080p YouTube videos using youtube-dl

youtube-dl -F http://www.youtube.com/watch?v=3JZ_D3ELwOQ

youtube-dl -F http://www.youtube.com/watch?v=3JZ_D3ELwOQ [youtube] Setting language [youtube] 3JZ_D3ELwOQ: Downloading webpage [youtube] 3JZ_D3ELwOQ: Downloading video info webpage [youtube] 3JZ_D3ELwOQ: Extracting video information [info] Available formats for 3JZ_D3ELwOQ: format code extension resolution note 171 webm audio only DASH webm audio , audio@ 48k (worst) 140 m4a audio only DASH audio , audio@128k 160 mp4 192p DASH video 133 mp4 240p DASH video 134 mp4 360p DASH video 135 mp4 480p DASH video 136 mp4 720p DASH video 137 mp4 1080p DASH video 17 3gp 176x144 36 3gp 320x240 5 flv 400x240 43 webm 640x360 18 mp4 640x360 22 mp4 1280x720 (best)

2. To get the best video quality (1080p DASH - format "137") and best audio quality (DASH audio - format "140"), you must use the following command:

youtube-dl -f 137+140 http://www.youtube.com/watch?v=3JZ_D3ELwOQ

"-f 137+140" specifies the format: 137 (which means mp4 1080p as you can see above) for video and 140 (which means m4a audio@128k) for audio, as displayed by the command under step 1.

To see all the available options (extract audio, choose a different video quality, download a video playlist and many many other options), type the following commands in a terminal: "man youtube-dl" or "youtube-dl -h".

If you don't want to add our PPA, you can manually download the deb from the PPA by visiting THIS link.where "VIDEO_URL" is the url of the video you want to download.SoFirstly, get a list of formats. I'll use a random video link as an example below:This will list all the available formats:As you can see, for 1080p there's only a DASH video available (format 137) and two separate DASH audio files (formats 140 and 171).