Extract audio stream from an AVI file using mencoder

mencoder "${file}" -of rawaudio -oac mp3lame -ovc copy -o audio/"${file/%avi/mp3}"
This commands saves the output in the audio directory. The portion ${file/%avi/mp3} uses bash string replacement to replace the avi to mp3 within the ${file} variable.

By: fulat2k
2009-02-15 14:57:54

1 Alternatives + Submit Alt

What Others Think

If you want it without being mp3 compressed try this mplayer $avi -vc null -vo null -ao pcm:fast:file=$wav
maht · 649 weeks and 1 day ago
I did a batch operation on multiple files with for file in `ls -1`;do mencoder "${file}" -of rawaudio -oac mp3lame -ovc copy -o audio/"${file/%avi/mp3}";done assuming audio/ directory has been created beforehand. This is simply an awesome one-liner. Thank you for sharing this!
xCrucialDudex · 554 weeks and 5 days ago
Two things i've learned using this: 1) using mencoder is faster than "mplayer -audiodump"; the latter will play the entire video in normal speed as it dumps the audio. 2) If your files have spaces on their names use: $ for file in *; do mencoder "${file}" -of rawaudio -oac lavc -ovc copy -o audio/"{file/%avi/}mp2";done
edutiao · 520 weeks and 5 days ago
i also have this kinds of needs recently, and after long google search, i accidentally find a step by step guide on how to extract audio from MKV, MOV, MP4, WMV, AVI, MPG, VOB, 3GP, FLV, WebM, SWF, F4V, DivX, Xvid, ASF, RMVB, MVI, WTV, DVR, H.264, DV, MXF, AVCHD, MOD, TOD, MTS and etc at http://www.bigasoft.com/articles/audio-extractor-extract-audio-from-mp4-flv-avi-mkv-mov-wmv.html It did help me to extract audio from mkv files and then allow me to save them as mp3, wmv, or wav hope it also helps you
grahambuddhenry · 443 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: