How To Download Youtube Videos in Linux in Desired Format

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.

Sesmoweb.com offers relaible hostins solutions starting at $4.95 per month. With it you will get 99.9% uptime gurantee, great customer support and more. Great offer for our readers. Get a semoweb coupon and with semoweb coupon code and semoweb promo code, you will get great discounts at sesmoweb hosting.

Installing youtube-dl

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
 
For RPM based
sudo yum install youtube-dl
 
Arch Linux users can use pacman to install it as follows
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

youtube-dl

eg. if the video URL is http://www.youtube.com/watch?v=Yc0CVEuUvRs, type

youtube-dl http://www.youtube.com/watch?v=Yc0CVEuUvRs

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

youtube-dl -c

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.

youtube-dl -F

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
To download the file in your preferred format, type
youtube-dl -f


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

youtube-dl -h

 

Disclaimer: This is an affiliate post. Learn why?

Saurav Modak
Liked it? Please consider +1 it below.
Help Freedom Grow. Subscribe to our RSS Feeds and Like Us in Facebook. Also you can leave a comment below.

17 thoughts on “How To Download Youtube Videos in Linux in Desired Format

  1. Lee

    Thanks! Works great. FYI: as of right now (01-28-2013) there is a problem. Youtube changed something to make it incompatible with youtube-dl, it’s been fixed in the latest version. According to this post http://leeunderwood.org/r/07 you will need to do the following to update youtube-dl until the package system gets the updated version (i.e., you will need to do it a few times):

    sudo youtube-dl -U

    Reply
  2. Faiz d Badshah

    Not Working :
    [youtube] Setting language
    [youtube] Yc0CVEuUvRs: Downloading video info webpage
    [youtube] Yc0CVEuUvRs: Extracting video information
    ERROR: format not available for video

    Reply
  3. satya

    Though downloading youtube videos is not legal and it’s not permitted by youtube but if you and i were producers ,we can follow youtube downloading only if intended for fair use also you gona find many videos which is under creative common license and reuse is permitted.So you can download those kind of videos and also reuse it.You can follow the above method for downloading videos or here is the youtube downloader which i use.

    Reply
  4. Alex Jones

    hey,

    Though downloading YouTube videos is not legal & it’s not permitted by YouTube but If you and I were producers,we can allow YouTube downloading only if intended for fair use. Also you gonna find many youtube videos which is under creative common license and reuse is permitted. So you can download those kind of videos and also reuse it.
    You can follow the above method for downloading videos or here is the youtube downloader which I follow

    Reply
  5. Anuj

    To download youtube videos is very simple, all you need id type in “ss” just after leaving www. in the url of the video and then click enter and doing this will redirect you to savefrom.net where you can choose the format of the video and your video will start downloading. Know here How to download youtube videos

    Reply
  6. Pingback: برنامج youtube-dl لتنزيل الفيديوهات من يوتيوب | تلميحات تقنية

Leave a Reply