Convert YouTube Videos Into MP3s

Author: Stephan Jau
Revision: v1.0
Last Change: October 8 2008

Introduction

I do have a few songs that are broken and that I can't get somewhere else and can't buy however they are on YouTube.

I know, quality is not the best on YouTube but for some stuff you have it might be better. Question is, how could I put those flash videos onto my music player?

It's actually very simple but the legality of it depends on where you live. Better check out first if you are allowed to convert YouTube videos into mp3s.

 

Step 1: Download the video

At first, we have to get the video. The normal flash version is a reduced quality of the actual uploaded one. So we get the mp4 version instead. In order to do that, go to the YouTube video that you want to download.

Then copy the URL of that video (for example this here: http://uk.youtube.com/watch?v=xB8W2EPUmII ) and paste it into the URL box of this the KeepVid website: http://keepvid.com/

Then click on download and you will be presented two download links. One as flash and one as mp4. Use the mp4 version for better quality.

 

Step 2: Convert the video to mp3

Make sure you have ffmpeg and libmp3lame installed. Depending on your distro you have to find out yourself which libs you need.

I assume now that you downloaded the video as gratitude.mp4 and want to rip it to gratitude.mp3. In order to do so, run this command:

ffmpeg -i gratitude.mp4 -ab 128000 -ar 44100 nodame_gratitude.mp3

That's it. I know, audiophiles will say the quality is really bad but I'm no audiophile and for me it works fine.

Share this page:

17 Comment(s)

Add comment

Comments

From: nomasteryoda

Why not create a bash script to simplify the process?

put the following into a file, copy it to your /usr/local/bin/ then chmod 755 to the file.

_______________________

#!/bin/bash

# Convert the flv files to mpg and mp3 files
for i in *.flv
do

# convert them to mpg if you like by removing the # on the 2 lines below this section
#  ffmpeg -i $i $i.mpg
    # ffmpeg -i $i -ab 128 -ar 44100 $i.mp3
      mplayer -dumpaudio $i -dumpfile $i.mp3

# use this line below to remove the flv files you downloaded.

# rm $i

 done

________________________

From: Mohan R

dumpaudio is what I do to convert into mp3. But not from youtube, from imeem.

From: Ragnar

@nomasteryoda

 Nice Script to but your script produces files called "dummy.flv.mp3" use this one to get files called "dummy.mp3".

for i in *.flv; do ffmpeg -i $i -ab 128000 -ar 44100 `basename $i .flv`.mp3; done

 cheers

From: Kelly

Stephan, That is a good way of doing it. You can also use the clive utility to both download and invoke ffmpeg in one step. Here is a line from a small php script I wrote to parse an youtube rss feed and then download the videos in mp3 format.

exec('clive --ffmpeg="/usr/bin/ffmpeg -y -i %i %o" -o --output-fmt=%t.%i.%e --prefix=' . $filePath . ' ' . $url);

From: Valente Espinosa

Why mp3? would'nt be wise to support more and more open formats?

From:

changing it to .ogg is not a big problem. It's basically the same HOWEVER as you don't get any real quality sound and because mp3 is just the most-spread/most popular format I wonder if it's worth making .oggs out of it... IMHO it's not :)

From: mhymn

"mplayer -ao pcm youtube.flv; lame aud* -o your-file.mp3"

or

"mplayer -ao pcm youtube.flv; oggenc -q 6 aud* -o your-file.ogg"

you can use the same trick for .mp4

From: Anonymous

You can always use PyTube which already has this capability

From: Manpreet Kaur

Hi! 

The procedural downloading information did a lot of help but still want to enquire that can anything else work in place of ffmpeg and libmp3lame?

Manpreet Kaur
Financial Researcher
News Desk
http://www.economynews.in/
 

From: popo

Good.

But the online converter is not good. The output files is bad.

Mac users can use safari to download the youtube videos.

And here is a tutorial for Mac users to convert youtube videos to MP3.

From: Lynn LU

Yes ,a nice guide

But if you have a Mac,I think another sool guide will help you convert YouTube Videos to MP3s on Mac easily.

How to convert FLV videos to MP3,MP4, AVI, MPEG, MOV, 3GP,etc on Mac OS X?

From:

I'd like to recommend this youtube downloader, it can extract audio from youtube video to mp3 audio, it works pretty well for me.

 

From: shenuna

You also can Free Download YouTube videos, then Burn YouTube video to DVD to play on your home DVD Player ~

From: Rahul

Hi, I was lloking for an laternative but after trying three options the easiest Youtube video downloader ever would be "Easy YouTube Video Downloader" offering single click non-intrusive direct download buttons for FLV, 3GP, MP3, MP4, 720p HD and 1080p Full-HD qualities right from the Youtube page on Mozilla Firefox browser : https://addons.mozilla.org/en-US/firefox/addon/10137/

From: Timbers

You can also use Real's media player and their convert video option. Another free choice.

From:

If you want to convert youtube video to mp3 with high quality, I suggest you to use some youtube converter to help you. The one I used can not only help me download mp3 from youtube, but also can rip mp3 from downloaded FLV videos.

From:

Yeah, most of the time, we can find some YouTube converters to convert YouTube video URL to mp3 files. Not only than this, you could also try to use other methods to rip mp3 from video on YouTube.com directly.