In this tutorial I will show you how you can download Youtube videos in your desired format, batch download videos from a file, or extract the audio only from the downloaded video in Linux (Ubuntu, Fedora Arch Linux etc).
As everyone knows Youtube is the largest source of online videos in the world. There are many Youtube Video downloaders available in Windows platform, but most of them don’t work or are slow or require you to pay for downloading videos. Today I will show how you can download a Youtube video in your Linux machine for free also in desired format using a open source software known as youtube-dl. This will work on all popular Linux distros such as Ubuntu, Fedora, Arch Linux, Linux Mint etc.
Check your distro’s repositories if youtube-dl is available there. For Debian based distros such as Ubuntu or Linux Mint, you can use the following command.
sudo apt-get install youtube-dl
sudo yum install youtube-dl
sudo pacman -S youtube-dl
You can also compile from source by downloading it from this page.
Using youtube-dl : Downloading videos, Pausing and Resuming downloads
To download a video, go to youtube.com and search the video you want to download. Open the video page and copy the URL from the address bar as shown below.
|Copying Youtube URL|
Make sure you have installed youtube-dl using the above steps. Issue the following command to start downloading the video
eg. if the video URL is http://www.youtube.com/watch?v=Yc0CVEuUvRs, type
You will see some information as shown in the screenshot below, after which the video will start downloading and you will see the current speed and time remaining.
|Downloading Youtube videos using youtube-dl|
To pause or cancel the download, use Control-C. You can resume downloading the video using the following command
Batch Downloading Youtube Videos from a file
You can also write URLs of the videos in a file to be downloaded and issue a single command to download it at once. To do that, search all the videos you want to download and copy paste the URLs in a text file, each URL in a separate line. Then issue this command to download all the videos at once. This is especially useful if you want to download a lot of videos and don’t have time enough to issue the command separately.
youtube-dl -a filename.txt
Where filename.txt is the file where the video URLs are saved.
|Batch Download Youtube videos from a file -youtube-dl|
Downloading Youtube videos in Preferred format
Often it may happen that you may want to download a video in a format different from the default one, or in a different resolution. To know what format a video is availiable, use the following command.
Make sure you typed capital F. It will display the formats and resolutions the video is available in and their specific code in the first column.
|Download video in a different format – youtube-dl|
Eg. I want to download the file in .flv format with resolution 240×400, so I use this command
youtube-dl -f 5 http://www.youtube.com/watch?v=Yc0CVEuUvRs
The lower the resolution, the smaller will be the size of the file hence will save your data usage. By default, youtube-dl downloads the file in the best quality format.
Extracting Audio of Youtube Videos
If you just want the audio of the youtube video, you can issue this command to get it. The default is 128kbps. If you want to keep the video file too after the audio has been extracted, you can use the -k option. Hence all together to download my video http://www.youtube.com/watch?v=Yc0CVEuUvRs and extract the audio in mp3 format with a bitrate of 176kbps and keep the video, I use:
youtube-dl http://www.youtube.com/watch?v=Yc0CVEuUvRs –audio-format mp3 –audio-quality 176 -k
For more options, type