Hello,
In my last post I highlighted how you can download youtube videos using a great tool called youtube-dl
In this post we will be covering a few things.
- Downloading youtube videos and later converting them to mp3
- Downloading videos directly as mp3
We will be making use of ffmpeg and youtube-dl for our case.
Lets go
Preperation
Just so that you know that you will need to install youtube-dl first on your Ubuntu box. If you haven’t read my previous article please read that from here
http://jaspreetchahal.org/ubuntu-12-04-download-youtube-videos-using-youtube-dl/
You will also need to install ffmpeg. You can install it using the command below
sudo apt-get install ffmpeg x264 libav-tools libvpx-dev libx264-dev
Downloading video from youtube and converting them to mp3 using ffmpeg
Lets download a video from youtube now. Considering that you are in /home/user/videos directory and you have write permissions to this folder, run this command
# youtube-dl "http://www.youtube.com/watch?v=C-2MmguSO4w"
Your video will now be stored under /home/user/videos as C-2MmguSO4w.mp4
You can also specify a file name when using youtube-dl as shown below
# youtube-dl -o myvideo.mp4 "http://www.youtube.com/watch?v=C-2MmguSO4w"
Depending on your download speed it can take a while to download this video.
Just in case if you got error saying “Unable to download” then you would like to read my previous post.
Now we have C-2MmguSO4w.mp4 to work with. Lets convert it to mp3
The command
# ffmpeg -i C-2MmguSO4w.mp4 -f mp3 -ab 192000 -vn C-2MmguSO4w.mp4.mp3
The above command will convert our mp4 file to a mp3
-ab 192000 in above command means that our mp3 should be encoded at 192Kbps for great quality
-vn means that do not include video
-i means input file name
To know more about ffmpeg command read more here
http://linux.die.net/man/1/ffmpeg
Downloading videos as mp3 using youtube-dl
Now that we have seen how to mix ffmpeg and youtube-dl together to convert to desired format. We can do pretty much the same stuff with youtube-dl by itself.
Allow me to show you how this is done
Use this command
# youtube-dl --extract-audio --audio-format=mp3 "http://www.youtube.com/watch?v=C-2MmguSO4w"
And that’s it your video will be downloaded as mp3 now.
I hope that this helps. If you found any error in any of the commands above please let me know as I am also riding on a learning curve and it will be great help if you can offer any improvement to whatever I came up with above.
Cheers





JC WordPress Coupon Revealer Plugin Pro License
Australian Street Names with City, State and Display Names only, Single Server License
Related to your topic of converting youtube videos to mp3, I found this of interest and thought I’d share this resource http://www.real.com/resources/youtube-to-mp3-converter Apparently, google has shut down several sites due to copyright violations. There are still plenty of legal youtube to mp3 converters available just best to do your homework first!