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 -o /usr/local/bin/yt-dlp
$ sudo chmod a+rx /usr/local/bin/yt-dlp
$ sudo wget -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
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
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
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

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.

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. Hi, Marin. Thanks for your considerate sharing. But I have to admit that commands are too complicated for me to understand. I usually use an online program called 2conv and offline software called Joyoshare Screen Recorder.

    2conv is more convenient, but when it comes to some YouTube videos that claim copyright protection, it won’t work. And it has few supported formats. Joyoshare program works with most formats and can record videos in 1080P with or without sound. Glad to share it for those beginners.

  2. Didn’t work for me, no matter which links I pasted, it returns “YouTube said: This video is unavailable.”

    • Hello there. Don’t lose faith in Youtube-dl :)

      You probably just need to update the program itself. try youtube-dl -U and if that doesn’t work, delete your current installation and reinstall it.

  3. youtube-dl doesn’t work when the video has age restriction, it doesn’t matter if you put your credentials, not a good tool

  4. You can use the --batch-file FILE option or -a for short if you want to use the text file with multiple links. It is very much simpler than the loop.

  5. Hi! I started using youtube-dl for my raspberry pi. It was working fine yesterday (Dec 26th) but every attempt to download a video today returns “Error: YouTube said: This video is unavailable“.

  6. Thank you. I have been using AudFree software to download and convert music to MP3 and other common formats. It is compatible with almost all kinds of music resources from Apple Music, Spotify, Tidal, YouTube, which completely fulfill my needs.


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.