Convert YouTube Videos Into MP3s

Want to support HowtoForge? Become a subscriber!
 
Submitted by sjau (Contact Author) (Forums) on Fri, 2008-10-17 15:52. :: Linux | Other

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.


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by clement52 (registered user) on Fri, 2011-06-24 10:01.
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.
Submitted by Zachary4 (registered user) on Mon, 2011-11-07 02:03.
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.
Submitted by Timbers (not registered) on Fri, 2011-04-15 21:36.
You can also use Real's media player and their convert video option. Another free choice.
Submitted by Rahul (not registered) on Sun, 2010-07-18 11:01.
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/
Submitted by shenuna (not registered) on Wed, 2009-10-28 08:53.
You also can Free Download YouTube videos, then Burn YouTube video to DVD to play on your home DVD Player ~
Submitted by maccolar (registered user) on Mon, 2009-03-16 16:35.

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

 

Submitted by Lynn LU (not registered) on Tue, 2009-01-06 02:41.

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?

Submitted by popo (not registered) on Tue, 2008-12-09 12:14.

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.

Submitted by Manpreet Kaur (not registered) on Tue, 2008-10-21 13:41.

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/
 

Submitted by Anonymous (not registered) on Mon, 2008-10-20 19:56.
You can always use PyTube which already has this capability
Submitted by mhymn (not registered) on Mon, 2008-10-20 11:37.

"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

Submitted by Valente Espinosa (not registered) on Fri, 2008-10-17 16:03.
Why mp3? would'nt be wise to support more and more open formats?
Submitted by sjau (registered user) on Fri, 2008-10-17 17:42.
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 :)
Submitted by Kelly (not registered) on Fri, 2008-10-17 15:42.
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);

Submitted by nomasteryoda (not registered) on Sat, 2008-10-18 04:44.

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

________________________

Submitted by Ragnar (not registered) on Sun, 2010-11-28 01:04.

@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

Submitted by Mohan R (not registered) on Tue, 2008-10-21 07:42.
dumpaudio is what I do to convert into mp3. But not from youtube, from imeem.