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.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts 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 Comments

Leave a Reply
  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
  4. 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.

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

    Reply
    • 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.

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

    Reply
  7. 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.

    Reply
  8. 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“.

    Reply
  9. 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.

    Reply
  10. ERROR: This video contains content from UMG, who has blocked it on copyright grounds.

    How do you remove errors like the one above mentioned?

    This appears in case i try to download a playlist and a song is deleted, the program stops abruptly and I need to edit the start playlist command in order to skip the song manually but if it finds another one it needs to be done again and again

    Do I need to build a script similar to the one you showcased so that in case of error it skips song or is there a pre built skip to next in this useful tool?

    Reply
  11. This is perfect for what I was looking for. Thanks for the sharing. I used to download mp3 song from Youtube video with acethinker video keeper, free and works fairly well. Share it here as an alternative to YouTube-DL.

    Reply
  12. Oh yes, thank you!

    I’m taking my first steps with Slackware distro and I’m having fun doing many things on the terminal. So getting mp3 from youtube using command line is also great!

    Reply
  13. Today I used the following command:

    # youtube-dl --embed- thumbnail --write-- thumbnail -x audio -format mp3 ((URL)- | youtube-dl --write-sub (URL)

    youtube-dl downloaded two files one audio & one video file is this wrong?

    Reply
  14. The WonderFox free hd I am using is a very good YouTube downloader and converter that makes it easy to download the music we want from YouTube and convert it to MP3 format. You can have a try!

    Reply
  15. Great article and great tool! I use it almost every day. A pair of things that would be nice to add to your article would be how to provide a proxy to youtube-dl and youtube-dl taking links to download from a text file. Thx!

    Reply
  16. Is there a way to get the current image from a live stream using youtube-dl? If not can you direct me to a command line application that can do this in Linux.

    I am trying to capture an image from a live feed every 60 seconds so I can create a timelapse of the day.

    Thanks

    Reply
  17. I believe you are not allowed to save the soundtracks from songs as you won’t have a legal license and thus are infringing the content owners copyright.

    You should at least mention that in the article.

    You wouldn’t like it if someone ripped all your website content and posted it online so they could read it without the adverts as you would say you are losing income.

    Reply
  18. youtube-dl is pretty slow to start downloading or getting video title only (about 10s) on seagate dockstar, even after decompress.
    What should I do to speed it up?

    Reply
    • @Skyrail,

      I use Youtube-DL everyday to download some videos or extract mp3 songs, but I never seen any slowness, it always fast…

      Reply
  19. Hi, I’m using Linux Mint for an operating System ! recently I have not been able to download Youtube Video ?? I have tries everything My small brain could come up with & no results ?? Anyone out there have any ideas ? Thanks in advance, Mike

    Reply
  20. You may try use Allavsoft to download 3sat TV programs, movies and other video clips in batch to your computer, laptop, tablet, mobile phone, iPad, PSP, Zune, X360, Smart TV, etc.

    Reply
  21. Do we have a limit call when using youtube-dl to request to Youtube. I’m afraid that Google might block me since I request many times.

    Reply
    • @Trung,

      No any limits applied by YouTube or Google, you can download as many as videos, like I do regularly download videos or mp3 tracks from Youtube without any trouble or issues..

      Reply
    • @Gilvan,

      Yes, you can download list of videos from specific playlist, just check out the man pages of Youtube-DL here:

      # youtube-dl --help
      
      Reply
    • Thank you for your suggestion Alfredo. Actually since there was quite an interest towards this article, I am thinking about either updating this one or writing a new one with a script that will allow you to easily manage your downloads, without passing this many parameters each time you download a track.

      Reply
  22. There are lot of Firefox extensions available. You can install one of them and download video and mp3, while you are watching them in Firefox. So No need to use YouTube.dl

    Reply
  23. Hello Jeff,

    You don’t need to put the binary file in /usr/local/bin/. You can download it as regular user on your machine and place it in a directory by your choice from where you will access the file later. For example you can do:

    wget https://yt-dl.org/downloads/latest/youtube-dl -O /home/tecmint/

    And then run the file from /home/tecmint/

    If you are interested in reviewing the documentation about youtube-dl, you can check the following link:

    https://rg3.github.io/youtube-dl/

    Reply
  24. You’re ask us to use our root privileges to install a binary in a system executable directory without the source code? How do we know that this isn’t malware of some kind, or a social engineering attack?

    I would really love to be able to do what you are doing, but without the source code, I’m not going to put it in a system directory.

    Maybe on a virtual machine or on a chroot’d machine.

    Reply
    • @Jeff Silverman

      Great security concern there, may be you can check the source code out, i have used this program and i do not think from my assessment that it has any security concerns yet.

      But who knows, issues such as the one you have raised have to be put into great consideration.

      @Marin Todorov
      Thanks for the great article

      Reply
    • Apologies I didn’t have the time to provide the link to the source code of the application. I see that Josh already did that for me :)

      Still, I haven’t heard for any problems with youtube-dl, but you may always download it to a different location if you don’t like the one provided in the article.

      Reply
  25. Hi there,

    I downloaded the file (successfully, I guess, since I didn’t get any error response), but I can’t find it anywhere. Is there a default destination where the files are saved after download?

    Reply
    • @Nem,
      By default youtube-dl downloads files in the current working directory i.e from where you run the command. If you want to download files to specific location then specify -o switch with location to place download files with youtube url as shown

      # youtube-dl -o path-to-download-location youtube-url
      
      Reply
  26. “youtube-dl –all-formats ” don’t work anymore as stated! Instead it starts downloading all the formats. Hence, use “youtube-dl –list-formats ” or “youtube-dl -F “. Then choose the format.

    Reply
    • @Nitin,
      We already mentioned about the same in the article, to download a list of video files, create a file with all YouTube links and run the following command to download them.

      # youtube-dl -a youtube_links.txt
      
      Reply
  27. Thanks ravi your screenshot screenshot explainationation of how to download youtube-dl was spot on.
    Thanks and appreciate you effort being an open source fan myself.

    Reply
  28. I had a problem for update:
    youtube-dl -U
    It looks like you installed youtube-dl with a package manager, pip, setup.py or a tarball. Please use that to update.
    ….
    Ubuntu 14.04 LTS
    Memori ram 15,5 GiB
    Procer Intel Core i5-4430 CPU @ 3.00GHz x 4
    Graphic Gallium 0.4 on NVD9
    SO type 64 bits
    hard disck 696,5 GB
    dual partition with windows 8.1

    Reply
    • @ere,
      To download a series of videos, create a file and add all the video links that you wish to download.

      # youtube-dl -a youtube_links.txt
      
      Reply
  29. I have a downlaod that ended up zero sized. When I try to dewnload it again, youtube-dl tells me it’s aready dwonlaoded and gives up. How do I force a download? And where does youtube-dl save it’s setting etc. (I’m using Ububtu 12.04)?
    Any thoughts? Thanks.

    Reply
  30. has this just recently stopped working? Did google/youtube changed something?
    All of my old download tools have suddenly stopped working, anyone got any ideas, happened about 1-2weeks ago i think??

    Reply
  31. A couple of Question –
    1. Is there a GUI Client for Windows
    2. Can I change the location of stored files , config file.

    Reply
  32. Between this publication and 12 July 2013, the command-line options have changed. For example, the dash-capital-F “-F” option is no longer present. To fetch all formats for the named URL you now use “–all-formats”. I leave other details to the student.

    Also, after you install from the PPA, I had to run the program twice using ‘sudo’ permissions (to enable write into the install location) and with the “–update” option. The program reported as follows:
    ==========
    Hi! We changed distribution method and now youtube-dl needs to update itself one more time.

    This will only happen once. Simply press enter to go on. Sorry for the trouble!
    From now on, get the binaries from http://rg3.github.io/youtube-dl/download.html, not from the git repository.
    ==========

    I hope these notes save others some confusion.
    ~~~ 0;-Dan

    Reply
  33. It does the trick, but there are loads of options available as extensions / plugins to Firefox / Chrome if you use one of those. The extensions allow you to download video in a couple of clicks – some with format conversion options at the same time if you want. Much quicker and less hassle to use than firing up the terminal and pasting in the url. Just have a browse through the extensions and pick one of those instead…

    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.