Since there are so many tools (Minitube, youtube-dl) which allows you to download video files from YouTube or other video sharing sites, let’s go one step further and extract the sound from the downloaded video file to a mp3 file.
The FFmpeg tool will do the trick just fine. Thus assuming that you have the video file “My Video File.mp4” and you want to extract the sound into “My Sound File.mp3 ” use the following command:
ffmpeg -i "My Video File.mp4" -ab 128 "My Video File.mp3"
With the “-ab 128” parameter you specify that the audio bitrate should be 128k. Additionally the “-ar” parameter may be used for the audio sampling frequency but by default it is set to 44100, which should be ok.
On Ubuntu it may be necessary to add the Medibuntu repository and install the libmp3lame codec. For FFmpeg the audio codec can be specified using the parameter “-acodec”.