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.
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”.
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.
Open CMD (Inside the search field from your taskbar, enter command or cmd. Then, click or tap on the Command Prompt result.)
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:
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>
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:
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
youtube-dl -f "best" -o "%(title)s.f%(format_id)s.%(ext)s" https://youtu.be/2kkKK_kexIQ
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”.
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"
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.
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.
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.
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.
Looking for something?
You probably know the Sonoff brand for smart home electronics like the POW R2 or the Sonoff Basic switches, but they also released a security camera, the Sonoff GK-200MP2-B. I decided to try it out and made an in-depth review so you can make the right decision. Considering this is Sonoff, a well-known brand for robust electronics. I expect a good working, premium product that just works especially since to use the Sonoff GK200MP2-B, you need the eWeLink application which integrates very well with other Sonoff devices.Read Article
Transcribe a video to text using AWS. In this tutorial we will create a Word Document from a YouTube Video using the automatic speech recognition service from Amazon called, AWS Transcribe. Amazon Transcribe is an automatic speech recognition (ASR) service that makes it easy for developers to add speech to text capability to their applications.Read Article
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. In this tutorial I will show you how you can convert videos to audio in a matter of seconds, it does not cost a cent and requires very little effort.Read Article