If you are looking for a tool to download videos from multiple platforms you may already know some popular options like jDownloader. But there is an application as powerful as the above – one of the most interesting is YouTube-dl. Following this guide, you will be able to use it to download Youtube audio straight from the Linux terminal.

Youtube-dl is a small Python-based command line tool that allows you to download videos from platforms like YouTube, Dailymotion, Google Video, Photobucket, Facebook, Yahoo, Metacafe, Depositfiles and some similar sites. The Python interpreter is required to run the program. This program is open source and should run smoothly on any Unix, Windows or Mac OS X based system.

Youtube-dl also allows you to choose the video quality format available to download or let the program automatically download the highest quality video from the indicated portal. It also has support for downloading playlists, options for adding custom or original titles to the downloaded video file. It also has support for using a proxy.

With this script you can only download the videos. Unlike other programs like mps-youtube you will not be able to play them from the terminal.

HowTo Install Youtube-dl

youtube-dl is a Python program, so you can also locally install the latest version of youtube-dl in a Python virtual environment. To install the latest version of youtube-dl open the terminal and type:

To upgrade youtube-dl to the latest version:

You should check for updates before every run as Google is changing the way videos are accessed pretty often.

HowTo use Youtube-dl to download videos

To download and save a video file, you only need to have the URL that interests you. Then you just have to open the terminal and execute the following command:

To list all the available formats of the video that we want to download we will have to use the option “-list-formats” as shown below:

The previous command will show a list like the one of the capture. When you decide which one you are interested in, you only have to add the ‘-f’ option followed by the video format code. For example, let’s say I’d like to download the video in mp4 format, which is also tagged as ‘best’, so we’ll have to use the format code ’22’ as shown below.

If you want to download a list of video files, you only have to create a text file with all the YouTube links you want to save on your computer. In this example the text file is called “youtube_links.txt”:

HowTo extract audio from a Youtube video

First, make sure you have avconv video converter installed:

For best results, run the youtube-dl command with the -F option to list all the available formats and chose the best audio. In the previous example, the best option had audio @ 192k so we get that:

Extract audio using avconv and keeping the 192k bit rate. If the best option you get for a video is lower (for example 160k or 128k), change the command accordingly:

That’s it, enjoy!

HowTo Download YouTube Audio Straight From Ubuntu Terminal
Tagged on: