Extract Audio from Video Files to WAV using Mplayer

Posted by admin on October 11, 2009 under Tech Tips | 4 Comments to Read

You can extract the audio from a video file using mplayer and save the result to a WAV file, which you can then manipulate to your hearts content. For example, you may want to compress the audio to a stereo MP3 or OGG.

The following command instruct that the audio output (-ao) should be redirected out to a PCM WAV file as fast as possible, while suppressing all video output.

mplayer -ao pcm:fast:file=audio.wav -vo null -vc null video.avi

Convert the resulting WAV to MP3. The following is a great way to convert your WAV files to a high quality Variable Bitrate MP3. See the man page for a decent tutorial on the available options.

lame -V0 -q0 --vbr-new audio.wav audio.mp3

Be Sociable, Share!

Comments

  • Vyvyan said,

    I wonder why would you specify minimum bitrate to be used by using -b 128. It will only waste space with NO quality gain. If you don’t use -b switch whatever is best will be used. That’s the whole point of using vbr which you invoked by -V2. I would also prefer -V0 above -V2 for best vbr results and use –vbr-new to invoke vbr algo.

    My command would be:
    lame -V 0 -q 0 –vbr-new –noreplaygain audio.wav audio.mp3

  • gmendoza said,

    Agreed! Your preferred options are well balanced, and produce excellent results, although it’s still a matter of preference either way. I’ve edited the post to include some of the proposed modifications.

    -V 0 and -q 0 result in higher quality at the cost of increased file size.

    An audio file at 1.2G was converted to mp3 using both methods. The higher quality file was 180M, while the other was about 142M.

    Using a minimum bitrate (-b 128) typically isn’t a problem when the source doesn’t have many bits below that range. But as you mentioned, if you are going to use VBR, why limit how low you can go? It kind of defeats the purpose.

    I had actually never used the newer VBR algorithm, so this was nice to learn more about. For fun, I decided to run a couple tests for comparison in speed. I noted a slight increase in speed from the old algorithm (5m51.525s) to the new (5m36.424s) using the two different quality settings. But there was no difference at all when quality settings were identical. But hey, little things ought to count for something.

    I still haven’t found any benefits to removing replay gain computation. I found the referenced information within the LAME man page interesting. http://www.replaygain.org

    If anything, I think using –replaygain-accurate seems better for it’s purpose, while disabling I assume can only speed up the process. Thanks for the comments.

  • Sergio said,

    10 thousand diferent versions and nobody knows how can he know which is the best way to do things. Year pass by and the same problem continues and continues. !00000 lives, 100000000 hours lost, and lost again,…… Linux information system.Too many distros and too many desktops but nobody cares about doing, well done, what people want.

  • alfredbobes said,

    I use iDealshare VideoGo to extract audio from video like AVI, MPEG, FLV, WMV, MP4, MOV etc.

    It can directly convert video to MP3, WAV, WMA, AAC, M4A etc audio format

Add A Comment