How To Download Youtube Videos As MP3 Files.


To convert a Youtube video or any video for that matter requires just one step, in essence, you will transcode the video file (normally an MP4) to MP3 using ffmpeg.

However, in the case of Youtube there is an extra step, you need to actually download a video from Youtube first. Let us start there.

How to download a Youtube Video

To download a video from youtube will need to use the software called youtube-dl, it’s very straight forward, in essence, you will use the command line (CMD on Windows) to tell it the URL of the video you want to download and then the program will download the video and store the file in the folder you specify.

Step 1: Download the libraries required for the process

Download “youtube-dl” from here, then save this to a folder on your desktop. Call the folder “YT-to-MP3”.

In other words, create a folder on your desktop and call it “YT-to-MP3”.

youtube to mp3 folder on windows 10 desktop

Now download “youtube-dl”, by default it will sit in your downloads folder, go there and then copy it from there to the folder on your desktop.

youtube-dl inside the youtube to mp3 folder on the desktop
Step 2: Use command prompt on Windows 10

Open CMD (Inside the search field from your taskbar, enter command or cmd. Then, click or tap on the Command Prompt result.)

Open up CMD in windows 10
Step 3: Use the Windows command prompt to access the folder

Navigate to the folder on your desktop through CMD, the one we called “YT-to-MP3”. You can do that by typing the following command:

cd C:\Users\%username%\Desktop\YT-to-MP3

Type it exactly like that (copy it), do not change anything, that \%username%\ part is intentional, it will essentially resolve to whatever your username is, which I won’t know since I sitting in Cape Town and don’t your PC name.

If you did it correctly then you will see you are successfully inside that folder.


    Microsoft Windows [Version 10.0.18363.1016]
    (c) 2019 Microsoft Corporation. All rights reserved.

    C:\Users\erikthiart>cd C:\Users\%username%\Desktop\YT-to-MP3

    C:\Users\erikthiart\Desktop\YT-to-MP3>
    
Step 4: Download the Youtube Video through the command prompt

If you remember in Step 1 you copied the youtube-dl.exe file to this folder; so now you can talk to the youtube-dl program through the command line like so:

youtube-dl https://youtu.be/2kkKK_kexIQ

You are telling youtube-dl to download that URL to this folder, but let us make the downloaded file unique just in case you intend to go wild and download a lot of videos.

Change it to:

youtube-dl -f "best" -o "%(title)s.f%(format_id)s.%(ext)s" URL-of-The-Video

IE

youtube-dl -f "best" -o "%(title)s.f%(format_id)s.%(ext)s" https://youtu.be/2kkKK_kexIQ
Step 5: Download and install ffmpeg on windows 10

You will now notice that the file is in that folder. Now we are going to convert this video file to MP3 using a program called ffmpeg, the process is very similar to what you just did with youtube-dl.

Download ffmpeg.exe from here: Click here, then do the same as you did in step 1. Save this program to the folder on your desktop called “YT-to-MP3”. If it downloaded a zip file, open it and copy the .exe file over to the folder on your desktop. Now inside that folder, you should have “youtube-dl.exe”, the file you downloaded and “file.something” and “ffmpeg.exe”.

Convert Youtube videos to MP3 files
Step 6: Convert the youtube video to an MP3 file using ffmpeg

Using CMD again run the following command to convert the video file to an mp3 file. This time you will use ffmpeg instead of youtube-dl, but it is the same idea, in essence, you are now telling ffmpeg to take the video file and transcode it to an audio file (that is why we have .mp3 there.)

ffmpeg -i "the-name-of-the-video-you-downloaded.mp4" "give-this-a-name-of-your-choice.mp3"

IE

ffmpeg -i "Digital Council Africa and Why All Local Municipalities Need Good Connectivity.f22.mp4" "Digital Council Africa and Why All Local Municipalities Need Good Connectivity.f22.mp3"

Done. Congratulations you have done something awesome that you probably think you could not do when you landed on this page. Truth is, so many things only seem complex until you sit back and just try to break it down into little pieces. Elon Musk has a great way of solving problems that he calls “First Principles”. In our case, we knew we want an audio version of a Youtube video, but that sounds daunting – however as you saw it really only becomes a two-part issue. Part one, you need to download the file from youtube and Part two, you now need to convert that video file to audio. We found that youtube-dl solves the first part and ffmpeg solves the second part, easy stuff.

Bonus: Getting to know youtube-dl

Youtube-dl has a ton more options, to skip the ffmpeg part you could modify your command like this:

youtube-dl -f " bestaudio" -o "%(title)s.f%(format_id)s.%(ext)s" URL-of-The-Video

That will create an m4a audio file, which will be fine in most cases, but just figured let me show you the long way first so that you understand the process better.

If you have a specific task that you would like to solve, but don’t know how to do it, then send me a tweet @ErikThiart and I will see if I can create a tutorial for you. It’s free, basically, you suggest what I can write about and if it’s within my domain of understanding then I will write about it.

Why is this Guide of mine better to download and convert Youtube Videos to MP3 than the online services?

Safe and Virus Free

Well for starters, these free youtube to mp3 sites and software are filled with viruses and malware, normally. This way, however, by doing it yourself, you are in complete control of every step of the process – no malicious stuff is happening behind your back, you can see what you are doing.

Unlimited Conversions

Then the other benefit, is that this way it is free and unlimited, you can download as many videos as you want without any restrictions.

What is FFmpeg?

FFmpeg is the leading multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created. It supports the most obscure ancient formats up to the cutting edge. No matter if they were designed by some standards committee, the community or a corporation. It is also highly portable: FFmpeg compiles, runs, and passes our testing infrastructure FATE across Linux, Mac OS X, Microsoft Windows, the BSDs, Solaris, etc. under a wide variety of build environments, machine architectures, and configurations.

What is Youtube-DL?

youtube-dl is a command-line program to download videos from YouTube.com and a few more sites. It requires the Python interpreter, version 2.6, 2.7, or 3.2+, and it is not platform-specific. It should work on your Unix box, on Windows or on macOS.

Disclaimer:

Please do not download videos from Youtube that you do not own. This guide is for educational purposes only, I just want to teach you how to solve problems and how to think. So, use this knowledge accordingly and not in nefarious ways.

If you found this guide to be useful and would like to make a donation, please head over to my donations page, the money gets split between beer and hosting costs. I need the hosting account to keep this content alive and I need the beer in order to keep myself alive.

Popular Categories

Ad Blockers AWS Bitcoin CMD cPanel crypto Dark web Google IoT MikroTik Python Reviews SmartDNS Sonoff Tor VPN Windows WordPress Xiaomi Youtube

Subscribe (It's Free)


Featured Articles

How to block ads on your network using Pi-Hole and a Raspberry Pi
How to block ads on your network using Pi-Hole and a Raspberry Pi

With Pi-Hole you can block in-app advertisements. Network-level blocking allows you to block ads in non-traditional places such as mobile apps and smart TVs, regardless of your hardware or OS and since advertisements are blocked before they are downloaded, network performance is improved and will feel faster. Pi-hole is a black hole for Internet advertisements.

Read The Article
A smart bulb that works with the eWelink app
A smart bulb that works with the eWelink app

The Sonoff lightbulbs are very affordable and provide you with the basic functionality that a smart home needs. If the budget is tight and you don’t need all bells and whistles of the more expensive lights, Sonoff lightbulbs will do the job just fine. The prices start from $9.90 for the (plastic, White + color temperature) B02 B A60 and $12.90 for the fancy, pear-shaped B02-F-ST64 (glass, retro look, White + color temperature). As far as connected lights go, the prices are very attractive and Sonoff lightbulbs indeed are as inexpensive as you can get.

Read The Article
Sonoff SNZB-02 Zigbee Temperature & Humidity Sensor
Sonoff SNZB-02 Zigbee Temperature & Humidity Sensor

Enclosed in the same shell, SNZB-02 Zigbee temperature & Humidity sensor reports back every couple of minutes. The sensor is powered by CR2450 3V battery. The extra capacity means that the sensor will last a really long time. I have a heater connected to eWeLink app and, once I added a hub (absolutely required) this thing has performed well. The heater is controlled within +- 1°C. That's another thing, eWeLink only provides temperature readings in °C with no option for °F. I'm thinking about placing another sensor on the outside of the window so that I can control based on outdoor temperature as well.

Read The Article


Some articles you might also be interested in...

How to choose the right web hosting company for your business
How to choose the right web hosting company for your business

There are plenty of web hosting providers out there, and it may seem difficult to decipher the good from the bad. So I have put together a guide on how to find the right web hosting provider for your business and my personal recommendation of who to use depending on where you are in the world. Teaming up with the right web hosting service is more important than you think. It’s a partnership. Opt for the wrong one and you could find yourself struggling to get support, suffering downtime, or worse.

Read The Article
How to access BBC iPlayer outside of the UK
How to access BBC iPlayer outside of the UK

You might have found that Hulu is limited to US viewers and the BBC iPlayer is likewise limited to UK IP addresses, however using a very easy to set up proxy server you can access BBC Iplayer, Hulu and many others from any country on all of your internet capable devices such as your Laptop, PC, Mobile Device, Kindle Fire TV, Apple TV, Google Chromecast etc. In this guide you get the ultimate viewing experience when streaming/downloading any type of regional or geo-blocked content online.

Read The Article
An affordable VPN that also comes with a Geo Blocker
An affordable VPN that also comes with a Geo Blocker

The internet is full of restrictions, censorship, privacy invasions, security breaches, and a host of unwanted entities trafficking in your personal data. Using a VPN is a great first step toward protecting your privacy online. Privacy is fundamental to a well-functioning society because it allows norms, ethics, and laws to be safely discussed and challenged. Without privacy, a free and open society can neither flourish nor exist.

Read The Article