Download an audio track from a YouTube video in Linux

Linux is the system of freedoms. The terminal is the key to master a *nix system. youtube-dl is a terminal utility that brings you the ability to catch contents from Youtube.

Terminal and youtube-dl. That’s all

There are several posts and threads that explain how to download Youtube videos using the terminal through youtube-dl. This one can also be able to download a directly audio track from a Youtube video without converting and using ffmpeg or avconv. So, this command is the key.

youtube-dl download

youtube-dl is free and opensource, so you can download it from the official site and start playing with it. First of all, give a look at the help of the terminal or to the online documentation.

For the full options list, just type in terminal session: ~$ youtube-dl --help

cialu@andromeda:~$ youtube-dl --help
Usage: youtube-dl [OPTIONS] URL [URL...]

Options:
General Options:
-h, --help Print this help text and exit
--version Print program version and exit
Video Format Options:
-f, --format FORMAT Video format code, see the "FORMAT
SELECTION" for all the info
--all-formats Download all available video formats
--prefer-free-formats Prefer free video formats unless a specific
one is requested
Subtitle Options:
--write-sub Write subtitle file
--write-auto-sub Write automatically generated subtitle file
(YouTube only)
Post-processing Options:
-x, --extract-audio Convert video files to audio-only files
(requires ffmpeg or avconv and ffprobe or
avprobe)
--audio-format FORMAT Specify audio format: "best", "aac",
"vorbis", "mp3", "m4a", "opus", or "wav";
"best" by default
--audio-quality QUALITY Specify ffmpeg/avconv audio quality, insert
a value between 0 (better) and 9 (worse)
for VBR or a specific bitrate like 128K
(default 5)

How to download an audio track from a YouTube video

So, which is the fast way to download an mp3 track from a YouTube video?

***WARNINGS! HERE WE’RE TALKING ABOUT THE DOWNLOAD OF LEGAL TRACKS LIKE CREATIVE COMMONS LICENSED TRACKS OR FREE COPYRIGHT MUSIC. PAY ATTENTION TO DOWNLOAD COPYRIGHTED CONTENT BECAUSE IT’S ILLEGAL***

So, to download legal music tracks, easily, you need to just type in a terminal:


youtube-dl --extract-audio --audio-format mp3 <video URL from Youtube>

And to have a Vorbis track:


youtube-dl --extract-audio --audio-format vorbis <video URL from Youtube>