How to use youtube-dl to download and convert music to mp3 from Youtube

Recently I wanted to download a video from YouTube and convert it to MP3, but the online tools seemed full of ads or really slow. Also it seems nearly impossible to download an entire playlist. So I’ve discovered youtube-dl, a CLI software that works great and does pretty much everything you’d need.

Installing youtube-dl is very easy, as it’s included even in Debian and Ubuntu repositories. So a simple apt install youtube-dl will do the trick. The only problem is that you’ll get a much older version.

In order to install the latest version, you’ll have to use the commands below:

curl -L -o /usr/local/bin/youtube-dl
chmod a+rx /usr/local/bin/youtube-dl

If you encounter any errors while trying to run it, you might want to also install libav-tools. For example, I’ve got the ERROR: ffprobe or avprobe not found. Please install one. error and this fixed it:

apt-get install -y libav-tools

Using youtube-dl to convert YouTube videos and playlists to MP3

The following command will work with whatever URL you offer it, being it a video or an entire playlist. Just make sure that the video or playlist is public.

youtube-dl --extract-audio --audio-format mp3 VIDEO-URL

If you want to save the video or playlist to a specific location, you can use a lot of options. For example:

youtube-dl --extract-audio --audio-format mp3 VIDEO-URL -o %(playlist)s/%(title)s.%(ext)s will save the videos in a folder named after the playlist

If you want a simple online tool to do all of this for you very easy, fast and without no ads, then there’s one for you here.

Leave a Reply

Your email address will not be published. Required fields are marked *