Tuesday, July 22, 2008

Extracting audio stream from an AVI file using mencoder

If you ever need to extract the audio stream from an XVID/MP3 encoded file and save the audio stream back into MP3 format, here's the command to do it 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.

No comments: