Extract mp3 audio from streaming videos
- February 6th, 2010
- Posted in IT . Random stuffs
- Write comment
Sometimes you may just want to get the soundtrack of a video. And you know, today most videos are available in streaming on the web. There are several ways to download those videos, depending on the service that hosts them, but there are also many websites that explains how to do that. To give an example, youtube player retrieve videos requesting an URL with parameters that include the ID of the video and a signature it got when it’s loaded. To emulate this behaviour and get yourself the video to download, you can eg. use one of the appropriate firefox plugins , rather than getting the url from one of the many websites that build it for you. Anyway, streaming videos are in .flv or .mp4 formats. If you want to get the audio from an .flv video, you just need ffmpeg, running
ffmpeg -i "video.flv" -f mp3 -vn -acodec copy "audio.mp3"
If you want to get the .mp3 audio from an .mp4 video instead, you may use faad2 and lame to just decode the .mp4 audio to .wav e reencode it to an .mp3 .
faad -o - "video.mp4" | lame - "audio.mp3"
You can get both faad2 and lame as well as ffmpeg via apt or whatever package manager you use in Linux, and via MacPorts of Fink in Mac Os X.



As a small addon, if you somehow extracted the .ogg track and want to encode that into an mp3, just use oggdec instead of faad. Oggdec is part of the vorbis-tools package (available on MacPorts).
$ oggdec -o – track.ogg | lame – “The Track Name.mp3″
cheers,
n0on3