Converting Youtube videos into mp3

| categories: howto

If you're using Linux or a Mac, then there are two neat commandline tools which you can use to download and convert Youtube videos into mp3 files. They are Youtube-dl and FFmpeg.


Installing youtube-dl

The download and install instructions for youtube-dl are here.

As a quick note, on Mac you can run:

brew install youtube-dl

And on GNU/Linux:

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

For NixOS fans, it's available via nix-env.

Installing FFmpeg

Many Linux distros come with FFmpeg installed I believe.

If not, you can use your distros package manager. For example, on Ubuntu:

sudo apt-get install ffmpeg


In some older versions of Ubuntu (and probably other distros), you should use avconv instead of ffmpeg. AVConv was simply a fork of FFmpeg and the two projects have subsequently been merged back into FFmpeg again.

On Mac you can use homebrew:

brew install ffmpeg

Downloading the video

To download a Youtube video, you simply run the following line (making sure to replace the URL with the one of the video you want to download):


Converting video to mp3

To now convert the mp4 video to mp3, you can use FFmpeg (comes standard with most Linux distros I believe).

ffmpeg -i Rick\ Astley\ -\ Never\ Gonna\ Give\ You\ Up\ \[HQ\]-DLzxrzFCyOs.mp4 Rick\ Astley\ -\ Never\ Gonna\ Give\ You\ Up.mp3