YouTube is one of the most used platforms worldwide thanks to its extensive database of videos of all kinds, there are videos of learning, entertainment, science and millions of other options. One of the most frequent uses we make on YouTube is listening to music. Recall that on YouTube we find virtually all the artists that have existed and exist with both single songs and full albums..
Now, there is an option to download the MP3 audio from these videos since by Google rights it is not possible to download these videos directly from YouTube . Additionally, by downloading only the MP3, we can upload it to our mobile devices to listen to them anytime and anywhere even without an internet connection. The process to download Mp3 audio from a YouTube video is made possible by a tool called YouTube-DL and today TechnoWikis will explain how to use it for this download process.
What is YouTube-DL
YouTube-DL is a command line application that has been developed to download videos from YouTube and various other sites in a complete and simple way, the Python interpreter (2.6, 2.7 or 3.2+) is required for use and is not platform specific
YouTube-DL is completely free as it is open source and its use is available for all existing Linux distributions today.
Its basic use is as follows:
youtube-dl [OPTIONS] URL [URL ...]
Now we will see how to install YouTube-DL on Linux and thus enjoy this tool for MP3 audio management, in this case we will use Ubuntu 18.04.
1. How to install YouTube-DL on Linux
To start this process we will execute the following commands:
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O / usr / local / bin / youtube-dl
Now, we are going to grant the necessary permissions to this directory:
sudo chmod a + rx / usr / local / bin / youtube-dl
As you can see we execute that command.
2. YouTube-DL usage options
There are a number of parameters to use with this application, these are:
Step 1
Show the print program version
It is responsible for updating the program to the latest version
Lets continue downloading errors
Abort the download of more videos if an error occurs
Shows the current identification of the browser used
List of all compatible extractors
Launch a description of the results of all compatible extractors
Create a force extraction to use the generic extractor
--force-generic-extractor
Do not read configuration files
It refers to the location of the configuration file either to the configuration or its contents in the directory.
Order that videos are not extracted from a playlist, just list them
Mark watched videos (only applies to YouTube)
Do not mark the videos viewed (only on YouTube)
It does not emit color codes at exit
Additional we have additional options such as:
Use the specified HTTP / HTTPS / SOCKS proxy
Indicates the time to wait before ending the wait, in seconds
Refers to the client side IP address for the link
Make all connections through IPv4
Make all connections through IPv6
Run the video from the playlist to start (default is 1)
Play the video from the playlist to end in (the default is last)
Upload video items from the playlist to download
--playlist-items ITEM_SPEC
End the process after downloading a defined number of files
Do not download any video smaller than the indicated size
Do not download any video larger than the indicated size
Download only videos uploaded on this selected date
Download only videos uploaded on or before this date
Download only the video, if the URL refers to a video and a playlist.
Download the playlist, if the URL refers to a video and a playlist
It is the maximum download speed in bytes per second
Do not resume partially downloaded files
Do not use .part files, write directly to the output file
In case of searching for a specific option, we can use the "grep" utility and search for specific words as follows:
youtube-dl --help | grep extract-audio
Step 2
To download a video as an mp3 track on YouTube-DL, you will need to use the following two options:
--extract-audio
This option converts video files to audio-only files.
--audio-format
Indicates the audio format in which the selected video file will be downloaded, the compatible audio formats are "best", "aac", "vorbis", "mp3", "m4a", "opus" or "wav"; The best format is set by default.
The syntax for downloading a YouTube video as Mp3 is as follows:
youtube-dl -x --audio-format mp3
Step 3
If we want to add a cover for the mp3 file, we can add the --embed-thumbnail option like this:
youtube-dl -x --embed-thumbnail --audio-format mp3
3. How to download multiple audio videos from YouTube on Linux
YouTube has playlists which host various videos that will be played automatically, with YouTube-dl it will be possible to download a complete playlist or just a group of songs within it.
The options to use are:
--playlist-start NUMBER
Indicates the video number of the playlist to start (default is 1)
--playlist-end NUMBER
Refers to the video in the playlist to end in (the default is the last available)
For example, to download only the first 3 videos of a list we will execute the following:
youtube-dl -x --audio-format mp3 --playlist-start 1 --playlist-end 3 https://www.youtube.com/playlist?list=xxxxxxxxxxxx
This download the indicated videos and we can see the order of each video (Video 1 of 3, video 2 of 3, etc):
4. How to download audio from different Linux playlists
It is also possible that we have multiple playlists and want to extract the video in MP3 format, for this, we must create a file with each URL of the playlist, one URL per line, and after this we execute the following command:
for i in $ (<File); do youtube-dl -x --audio-format mp3 $ i; done
This will download the videos from the different playlists in MP3 format..
In this way we have managed to know how this utility becomes practical to download MP3 from YouTube in a simple but fully functional way.