Install youtube-dl from the official repository in Ubuntu:
sudo apt-get install youtube-dlTo download a video execute the following:
youtube-dl <url>E.g
youtube-dl http://www.youtube.com/watch?v=_z-hEyVQDRAYou can also specify other options
-b Best quality-m Mobile version-d High Definition-g Don’t download, just show the url-c Resume download of a video which was interrupted before-w Don’t overwrite existing fileFor complete list of switches execute man youtube-dl in terminal.
Information from http://www.absolutelytech.com/2010/06/26/howto-download-youtube-video-from-command-line-ubuntu/
Now install ffmpeg from the official repo.
sudo apt-get install ffmpegNext have a look to make sure the flv file has downloaded from youtube by typing
ls *flvThis will list all the flv files you have. What you should see is a flv file with the same name as the 'v' component of the youtube url you downloaded.
E.g if you downloaded http://www.youtube.com/watch?v=_z-hEyVQDRA then you should have a file called _z-hEyVQDRA.flv
Next you need to copy that file name and then put it in an ffmpg command like
ffmpeg -i <file name>.flv -acodec libmp3lame <song name>.mp3So for this example you would type
ffmpeg -i _z-hEyVQDRA.flv -acodec libmp3lame MasterOfPuppets.mp3Once this has successfully completed you will now have the mp3 file you were after.
Note For cleanup you may want to type rm _z-hEyVQDRA.flv to get rid of the flv file that you no longer need.
Information from http://ubuntuforums.org/showthread.php?t=855433
REF: https://askubuntu.com/questions/178481/how-to-download-an-mp3-track-from-a-youtube-video
youtube-dl --extract-audio --audio-format mp3 <video URL>From the online help:
-x, --extract-audio convert video files to audio-only files (requires ffmpeg or avconv and ffprobe or avprobe)Bear in mind as well that youtube-dl defaults to using avconv so you should consider specifying either avconv or FFmpeg at the commandline . From the online help :
--prefer-avconv Prefer avconv over ffmpeg for running the postprocessors (default)--prefer-ffmpeg Prefer ffmpeg over avconv for running the postprocessors