
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 Solvetic 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-dlAs 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
Display YouTube-DL help
-h, --help
Show the print program version
-version
It is responsible for updating the program to the latest version
-U, --update
Lets continue downloading errors
-i, --ignore-errors
Abort the download of more videos if an error occurs
--abort-on-error
Shows the current identification of the browser used
--dump-user-agent
List of all compatible extractors
--list-extractors
Launch a description of the results of all compatible extractors
--extractor-descriptions
Create a force extraction to use the generic extractor
--force-generic-extractor
Do not read configuration files
--ignore-config
It refers to the location of the configuration file either to the configuration or its contents in the directory.
--config-location PAT
Order that videos are not extracted from a playlist, just list them
--flat-playlist
Mark watched videos (only applies to YouTube)
--mark-viewed
Do not mark the videos viewed (only on YouTube)
--no-mark-watched
It does not emit color codes at exit
--no-color
Additional we have additional options such as:
Use the specified HTTP / HTTPS / SOCKS proxy
--proxy URL
Indicates the time to wait before ending the wait, in seconds
--socket-timeout SECONDS
Refers to the client side IP address for the link
--source-address IP
Make all connections through IPv4
-4, --force-ipv4
Make all connections through IPv6
-6, --force-ipv6
Run the video from the playlist to start (default is 1)$config[ads_text5] not found
-playlist-start NUMBER
Play the video from the playlist to end in (the default is last)
--playlist-end NUMBER
Upload video items from the playlist to download
--playlist-items ITEM_SPEC
End the process after downloading a defined number of files
--max-downloads NUMBER
Do not download any video smaller than the indicated size
--min-filesize SIZE
Do not download any video larger than the indicated size
--max-filesize SIZE
Download only videos uploaded on this selected date
--date
Download only videos uploaded on or before this date$config[ads_text6] not found
--dateforefore DATE
Download only the video, if the URL refers to a video and a playlist.
--no-playlist
Download the playlist, if the URL refers to a video and a playlist
--yes-playlist
It is the maximum download speed in bytes per second
-r, --limit-rate RATE
Do not resume partially downloaded files
--no-continue
Do not use .part files, write directly to the output file
--no-part
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 https://www.youtube.com/watch?v=xxxxxxxxxxx
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 https://www.youtube.com/watch?v=xxxxxxxxxxx$config[ads_text5] not found
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)
$config[ads_text5] not foundFor 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=xxxxxxxxxxxxThis 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 $ ($config[ads_text6] not found
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.
Articles