Life Skills, Technology, Tutorial, Ubuntu

How to Convert YouTube Video into MP3 Audio

EDIT 24/10/04

The blog post that keeps living on (with edits) ha.

I discovered today that youtube-dl doesn’t work but yt-dlp might be a re-named version of the same thing.

I just did a sudo apt install yt-dlp and everything worked like it used to work below with the old commands.
Thanks whoever kept it going!


EDIT 20/12/22

Ever get this error?
YouTube said: Unable to extract video data

I guess you have to upgrade that pip package I explain below – keep that in mind as you follow this blog for later down the road in case it seems broken.  All I had to do was run the following command and update the package and everything was working again as usual after that:

pip install --upgrade youtube-dl
———-

EDIT – 20/06/22

It seems that the debian / ubuntu packages for this tool are ‘not in sync’ lately.  So, I recommend, at least for now removing the apt package and using pip (python tool) to get it going.  Here is the list of commands and it works really well for me:

remove apt package: sudo apt remove youtube-dl

install pip (if you don’t have it already).  Probably you should use version 3 to help future proof it: sudo apt install python3-pip

install youtube-dl:  pip3 install youtube-dl

Then to upgrade you should be able to just run this: pip install --upgrade youtube-dl

In fact… you may be able to just run that last command to install *and* upgrade to the latest as it seems to wipe old packages and upgrade and install.  In either case you are now setup for the very latest in Youtube-dl power in Ubuntu!


This is a useful tool and tutorial if you, for example, make a video on Youtube and then want to publish the audio quickly on Soundcloud (or somewhere else).

If you aren’t already running Ubuntu on your computer this will be a couple of steps more difficult for you but well worth the effort.

Step 1: Get Ubuntu on your computer

If you don’t know what this, look it up and get it done.  Apple and Microsoft are so restrictive, un-secure, and 1990….

Step 2: Open a terminal

If you don’t know what this is, go look that up too.

Step 3: Install Youtube-dl tool with Terminal

Make sure the youtube-dl app thing is installed on your machine by pasting this into your terminal.  Note, you cannot just ‘control c/control-v’ into a terminal but you need to hold down both control *and shift* before pressing V to paste…  ready?  Ok, control C this into your computers clipboard (if it runs the command upon pasting, you’ll have to type it out manually, sorry)

sudo apt install youtube-dl

Now press enter in Terminal.

This will complete the installation of the tool.  Say ‘yes’ if it asks you to do anything since it’s just hard to argue these days…

Step 4: Copy the ‘magic line’ into your clipboard

We say ‘magic’ in technology when we’re doing something that is harder than sending an email.

Copy this ‘magic line’ of whatever to your computer with control C

youtube-dl --extract-audio --audio-format mp3

Step 5: Paste the ‘magic line’ into your Terminal

Paste the ‘magic line’ into your terminal taking note of my notes in Step 3…  pay special attention that there is only one trailing space and no other stuff after the ‘3’ in mp3.  You are going to paste a URL here from the video in the next step so extra garbage before or after the ‘magic line’ could mess it up.

Step 6: Copy Video URL from Youtube to clipboard

Using the ‘share’ link from the Youtube video (I find this works better than the main video URL…) copy the URL to the computer clipboard.

Step 7: Paste video URL to Terminal

Paste the video URL at the end of the magic line in your terminal using again my notes from Step 3.

Step 8: Press ‘enter’ in Terminal and get some popcorn

Press ‘enter’ on your keyboard.  The thing should run and it will be dumping the mp3 audio into your ‘home’ folder on your computer.  It takes a bit of time for this step so let it go and have a coffee

Boom.  A nice MP3 of your video.

Thanks to all the folks who made the youtube-dl tool!

Thanks to all the efforts of the free software community who make all of this possible.

Extra note: If, for some reason everything looks like it was running fine and you can’t find your new MP3 file in the Home directory, it’s possible the defaults were changed by you or something else and the Terminal downloaded the video somewhere else.  Do a system wide search for your file and you’ll probably find it somewhere.  This happened to me a few times 🙁

Tagged , , , , ,

Leave a Reply

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