YTP-DL: The Easiest Way to Download Songs from YouTube Videos

We all love listening to music whether it’s in the gym, at work, or outside, music is part of our life. Everyone has their own music collection and undoubtedly everyone likes to expand it.

While there are streaming services such as Spotify, many people still like downloading their own music and organizing their albums and playlists.

Today we are going to show you how to easily download mp3 songs from YouTube videos. To complete this, we will be using yt-dlp – a command line video download tool for Linux.

yt-dlp is an improved fork of youtube-dl, which is a popular command-line tool for downloading videos from various websites, including YouTube. yt-dlp offers the same functionality as youtube-dl, along with additional features and bug fixes.

youtube-dl is dead, the project was discontinued in December 2022 after receiving a DMCA takedown notice from Google.

In this tutorial, you will learn how to download mp3 tracks from Youtube using the yt-dlp tool. Of course, first, you will need to have it installed on your system.

If you haven’t checked the above article yet, here is how to install it:

Install yt-dlp – A Youtube Video Downloader for Linux

The package yt-dlp is available for RHEL-based and Debian-based distributions and it can be easily installed by using your favorite package manager.

$ sudo apt install yt-dlp         [On Debian, Ubuntu and Mint]
$ sudo yum install yt-dlp         [On RHEL/CentOS/Fedora and Rocky/AlmaLinux]
$ sudo emerge -a sys-apps/yt-dlp  [On Gentoo Linux]
$ sudo apk add yt-dlp             [On Alpine Linux]
$ sudo pacman -S yt-dlp           [On Arch Linux]
$ sudo zypper install yt-dlp      [On OpenSUSE]    

Alternatively, to install the most latest version of yt-dlp, use the following curl or wget to download the official binary file for your operating system.

$ sudo curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp
$ sudo chmod a+rx /usr/local/bin/yt-dlp
$ sudo wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -O /usr/local/bin/yt-dlp
$ sudo chmod a+rx /usr/local/bin/yt-dlp  # Make executable

Download MP3 (Songs) from YouTube Video on Linux

The yt-dlp command has quite an extensive "help" page and if you want to review it, simply type:

$ yt-dlp --help
yt-dlp Help and Usage
yt-dlp Help and Usage

If you are looking for a specific option, I recommend using the grep command and searching for a specific word as shown.

$ yt-dlp --help | grep extract-audio
Use Grep to Search a Word in File
Use Grep to Search a Word in a File

Now to download a video as an mp3 track, we need the following two options:

  • --extract-audio (short option -x) – Convert video files to audio-only files.
  • --audio-format  – specifies the audio format in which the file will be downloaded.

The supported audio formats are “best“, “aac“, “vorbis“, “mp3“, “m4a“, “opus“, or “wav“; “best” is set by default.

Download YouTube Video as a Song

To download a video as a song file, you can use one of the following commands:

$ yt-dlp -x --audio-format mp3 https://www.youtube.com/watch?v=wp43OdtAAkM
Save YouTube Video as Song
Save YouTube Video as Song

If you want to have cover art for the song file, you can add the --embed-thumbnail option:

In that case, the command will look like this:

$ yt-dlp -x --embed-thumbnail --audio-format mp3 https://www.youtube.com/watch?v=MwpMEbgC7DA
Save YouTube Video as Song with Thumbnail
Save YouTube Video as Song with Thumbnail

Download All Songs from a YouTube Playlist

As you probably noticed, youtube playlists are getting more and more popular lately. So the chances are that you will want to download more than one track from a playlist. Luckily yt-dlp provides an option to download a whole playlist or just a range of songs within it.

For that purpose, you will need to use the following options:

  • --playlist-start NUMBER – Playlist video to start at (default is 1).
  • --playlist-end NUMBER – Playlist video to end at (default is last).

Where "NUMBER" is the starting and ending point of the playlist. The command below will download the first 5 songs from the given playlist:

$ yt-dlp -x --audio-format mp3 --playlist-start 1 --playlist-end 5 https://www.youtube.com/playlist?list=PL9LUD5Kp855InMnKTaRy3LH3kTIYJyBzs
Download Multiple MP3 from Youtube Playlist
Download Multiple MP3s from Youtube Playlist

If you prefer to download the whole playlist, don’t use the playlist-start and playlist-end parameters. Instead, simply pass the playlist URL.

Download All Songs from Multiple YouTube Playlists

First, you need to create a text file (e.g., playlists.txt) and paste the URLs of the YouTube playlists that contain the songs you want to download.

Open a terminal and run the following command to download all songs from the playlists:

$ yt-dlp -x --audio-format mp3 -i --batch-file='path/to/playlists.txt'

The above is a simple solution to download multiple songs from different Youtube URLs.

Update YTP-DL

ytp-dl itself can be updated to the latest version using the following command.

$ yt-dlp -U
Conclusion

yt-dlp is a simple, yet powerful tool that can help you to download music on your devices. You are now ready to expand your music libraries to a whole new level.

If you have any questions or comments, please do not hesitate to submit them in the comment section below.

If you read this far, tweet to the author to show them you care. Tweet a thanks
Marin Todorov
I am a bachelor in computer science and a Linux Foundation Certified System Administrator. Currently working as a Senior Technical support in the hosting industry. In my free time I like testing new software and inline skating.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

101 thoughts on “YTP-DL: The Easiest Way to Download Songs from YouTube Videos”

  1. I have a lot of high-quality music videos. You may extract and save music for later use using download. To entertain yourself or to share with others, it’s up to you. When there is no 4G or 5G signal, you can use it without a problem.

    You can refer to it at: https://kostenloseklingeltone.de/

    Reply
  2. Have you tried the NoteBurner YouTube Video Downloader? It could be the best free YouTube to MP3 Downloader for those who want to export audio from YouTube videos. The sound quality also sounds the same as the original songs.

    Reply
  3. Attempting to download the mp3 files, I find your instructions are incomplete:

    $ youtube-dl --extract-audio --audio-format mp3 -f18 https://www.youtube.com/watch?v=3bUTcy6w2Rw
    

    `ERROR: ffprobe/avprobe and ffmpeg/avconv not found. Please install one.`

    Reply

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.