What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. 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.

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.

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:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags



Extract audio stream from an AVI file using mencoder

Terminal - Extract audio stream from an AVI file using mencoder
mencoder "${file}" -of rawaudio -oac mp3lame -ovc copy -o audio/"${file/%avi/mp3}"
2009-02-15 14:57:54
User: fulat2k
Extract audio stream from an AVI file using mencoder

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.


There are 7 alternatives - vote for the best!

Terminal - Alternatives
mencoder "${file}" -of rawaudio -oac mp3lame -ovc copy -o "${file%.*}.mp3"
2012-12-14 03:49:52
User: Tungmar

This command extracts the audio stream of the video in $file and stores it in a file where the original suffix is changed to .mp3

Know a better way?

If you can do better, submit your command here.

What others think

If you want it without being mp3 compressed try this

mplayer $avi -vc null -vo null -ao pcm:fast:file=$wav

Comment by maht 457 weeks and 3 days 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!

Comment by xCrucialDudex 363 weeks 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

Comment by edutiao 329 weeks 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

Comment by grahambuddhenry 252 weeks ago

Follow the step by step guide how to extract audio from video at http://www.idealshare.net/extract-audio-from-video-mp4-avi-flv-mov-wmv-mkv-vob.html

This guide helps to:

Extract audio in MP3, AAC, AC3, WAV, WMA, Apple Lossless, M4A, DTS, AIFF, MP2, AU, RA, FLAC, OGG and etc from video files.

Extract audio from all kinds of video files like extract audio from MP4, extract audio from FLV, extract audio from AVI, extract audio from MOV, extract audio from MKV, extract audio from WMV, ASF, SWF, VOB, OGV, WTV, RMVB, WebM, MVI, MXF, AVCHD, MPEG, 3GP, and etc.

Comment by teamsuccessta 183 weeks and 6 days ago

I've had good luck with http://www.convertmxffiles.com

It lets you select preset options for converting audio/video formats

Comment by mxffiles 29 weeks and 2 days ago

Your point of view

You must be signed in to comment.