YouTube is the gold mine of audio and video content, the opium of millennials, the concentration of thought of future generations. With the videos on YouTube, we can do, say and be anything. Learning to play an instrument, transmitting our thoughts to the world, let us read a good book, learning to taste a refined wine and so on, we can always learn new things and never let someone’s company be missing.
There are billions of hours of video on YouTube. Literally, billions and numbers are increasingly growing and it is also a growth that knows no slowdowns. YouTube is the ideal destination for uploading and watching videos from your PC, smartphone or tablet. This site is unmatched and the countless imitations have done nothing but take the crumbs left behind by the Google video platform.
Having said that, even though we live in a hyper-connected world, we are not always online and, at times, it could be useful to have that particular video downloaded on our device. Or, that song that we like so much and that we don’t find anywhere, not even on Spotify, but only as a soundtrack of a YouTube video. We would like to have it to make it our default ringtone on our smartphone. How can we do in these cases?
Thanks to Linux and Opensource software, nothing could be simpler!
Download audio and video tracks from a YouTube video with youtube-dl
In this article, we will see the procedure for downloading a video or just the audio track from YouTube, through some terminal commands on an openSUSE Linux system. The procedure is practically universal and we will add the relevant instructions also for Fedora and Ubuntu distributions, also you can also consult the previous article Download an audio track from a YouTube video in Linux.
End of the preambles and let’s move on. We used both an openSUSE Tumbleweed system and an openSUSE Leap one, no differences at all. First, you need to access a terminal from the Application Button in KDE (or Applications in GNOME or similar in other Linux desktop environments) or by pressing the Super Key and typing Terminal. Once the terminal window is open, type the commands to install YouTube-DL:
$ sudo zypper install youtube-dl
To download and install YouTube-DL on Fedora or Ubuntu, you can use the following commands:
$ sudo dnf install youtube-dl #Fedora install
$ sudo apt install youtube-dl #Ubuntu install
Then you can use YouTube-DL to download a full video from YouTube or to download it and get only the audio track from the video.
$ youtube-dl https://youtu.be/TENZY57bgQ0 #simple download the video in the published format
You can also check the available video format to download.
$ youtube-dl -F https://youtu.be/TENZY57bgQ0
With the command above, you’ll get the list of all the available video formats to download that video. Here, the result:
[youtube] TENZY57bgQ0: Downloading webpage
[info] Available formats for TENZY57bgQ0:
format code extension resolution note
249 webm audio only tiny 51k , opus @ 50k (48000Hz), 19.38MiB
250 webm audio only tiny 66k , opus @ 70k (48000Hz), 25.62MiB
251 webm audio only tiny 125k , opus @160k (48000Hz), 51.38MiB
140 m4a audio only tiny 133k , m4a_dash container, mp4a.40.2@128k (44100Hz), 57.46MiB
278 webm 256x144 144p 113k , webm container, vp9, 30fps, video only, 21.42MiB
160 mp4 256x144 144p 118k , avc1.4d400c, 30fps, video only, 22.74MiB
133 mp4 426x240 240p 242k , avc1.4d4015, 30fps, video only, 49.83MiB
242 webm 426x240 240p 252k , vp9, 30fps, video only, 25.60MiB
243 webm 640x360 360p 443k , vp9, 30fps, video only, 45.27MiB
134 mp4 640x360 360p 554k , avc1.4d401e, 30fps, video only, 94.99MiB
244 webm 854x480 480p 719k , vp9, 30fps, video only, 60.51MiB
135 mp4 854x480 480p 1056k , avc1.4d401f, 30fps, video only, 163.70MiB
247 webm 1280x720 720p 1584k , vp9, 30fps, video only, 134.78MiB
136 mp4 1280x720 720p 2166k , avc1.4d401f, 30fps, video only, 284.10MiB
248 webm 1920x1080 1080p 2314k , vp9, 30fps, video only, 137.48MiB
137 mp4 1920x1080 1080p 4586k , avc1.640028, 30fps, video only, 778.18MiB
271 webm 2560x1440 1440p 6231k , vp9, 30fps, video only, 1.14GiB
313 webm 3840x2160 2160p 10637k , vp9, 30fps, video only, 2.98GiB
18 mp4 640x360 360p 320k , avc1.42001E, mp4a.40.2@ 96k (44100Hz), 142.07MiB
22 mp4 1280x720 720p 768k , avc1.64001F, mp4a.40.2@192k (44100Hz) (best)
Now, you can use the format number with the -f option to download the video in that specific format:
$ youtube-dl -f 313 https://youtu.be/TENZY57bgQ0 #to download the video in the 4K resolution
We can also download the video and extract the audio track from it with YouTube-DL. Here, the commands:
$ youtube-dl --extract-audio --audio-format mp3 https://youtu.be/TENZY57bgQ0 #to extract the audio track from the video in the MP3 audio format
$ youtube-dl --extract-audio --audio-format vorbis https://youtu.be/TENZY57bgQ0 #to extract the audio track from the video in the VORBIS audio format
In the official documentation of YouTube-DL, you can find billions of options to do everything with this super useful utility. You can download playlists, save them in particular folders, decode them, extract from them and many more things. The only limit is your fantasy, but remember to do these things only with content not protected from copyright.
***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, remember to download only free content with free licenses like the Creative Commons or similar.
References
- The official youtube-dl downloads website – https://youtube-dl.org/
- The official youtube-dl downloads mirror – https://ytdl-org.github.io/youtube-dl/download.html
- The official youtube-dl downloads documentation – https://github.com/ytdl-org/youtube-dl/blob/master/README.md
Image: “State Public Health Laboratory in Exton Tests for COVID-19” by Governor Tom Wolfe (CC BY)