Pages

Thursday, October 23, 2014

Tutorial: Using FFMPEG To Rip Audio From A Video

I know a lot of people like running YouTube music videos through one of the various online conversion sites to get an MP3. Personally, I think this is a terrible method. For one, by re-encoding the already lossy audio of the YouTube video again, you're getting an even lower quality copy.

I used to download the YouTube video, then convert it to .wav in VLC. Then I'd convert it to MP3 or AAC (M4A). That's pretty much what the various sites out there do, except this method was offline and required a few extra steps.

There's a better way.

First you'll need a userscript for your browser. (For those of you unfamiliar with userscripts, I provided a Google link for you.) That script is: Download YouTube Videos as MP4. Once it's installed, when you go to a YouTube video, you should see something like this...


That will allow you to download the video. It should be pointed out that 360p and below will have audio encoded at 96kbps, while the HD videos (720p+) will have higher bitrate, 192kbps audio. Higher is better, but sometimes you don't have the better audio option.

So, now you've got the video, but now what?

Now you'll need a copy of FFMPEG, which you can get here.

It's a command line program. Since I'm using windows, my instructions will be for windows.


Once you've done that, you're ready to encode.

You can open your command line and navigate manually to whatever you downloaded the video to with the CD command. That's a lot of work though. I prefer a neat little Windows trick. Open the folder you downloaded the video to in Explorer. Then click in the address bar in Explorer...



Type in cmd and hit enter. There's your command prompt and it's open to the directory we want.



If you setup FFMPEG correctly, then you need to enter in the following command...

FFMPEG -i input-filename.mp4 -vn -acodec copy output-filename.mp4

(input-filename.mp4 should be renamed to whatever the name of the original file you're trying to convert is. output-filename.m4a should be renamed to whatever you want to call your new file.)

Another important thing to remember is that if the names of the files you're converting have any spaces, then you should be quotation marks around them. For example the file I'm going to convert is called: Morning in the forest.mp4

So my command line should look like this...

ffmpeg -i "Morning in the forest.mp4" -vn -acodec copy "Morning in the forest.m4a"


I hit enter and FFMPEG does it's thing really quickly...


... and now I've extracted the original audio track without further compression into a .m4a container, which pretty much any music player program is capable of playing.

I also use FFMPEG to make animated WEBM files...


... but that's a whole other tutorial.

No comments:

Post a Comment