2008-01-13

How to extract audio from any video file in Linux

by Anoop Engineer 17 comments





Want to extract the audio of your favorite musical video, but stuck because you use Linux? Just fire up the terminal and hit shmooze:


ffmpeg -i my_video_file.avi extracted_audio.mp3



Well, in the linux world, it's a pity if you don't give an alternate way to do stuff. So here it is:
mplayer -dumpaudio my_video_file.avi -dumpfile extracted_audio.mp3


This technique can be used to extract audio from AVI, MPG and FLV files.

Photo by Peter Fuchs

Comments 17 comments
Anonymous said...

Totally worked. All avi files converted within a few seconds with mplayer. Thanks

Anonymous said...

Thanks :)

zsuffad said...

Thanks too. cool, short, nice

koszi

Ben & Efrat, Touching Love with a Loving Touch said...

Thanks a bunch!!!

Short and precise. Just what we needed.

Anonymous said...

Excelent! Thanks

Anonymous said...

A beautiful, simple, elegant solution that I'd expect to find only in Linux. Thanks! :)

phani said...

simple solution but i didnt get the result when i did with mp3 but when i created ogg file it worked it said that codec not ound wats wrong

Anonymous said...

Great solution without any techno babble!! Thank you!

Anonymous said...

Very good, but can we specify the bit rate of the extracted mp3? I got 64 kbps. I would like 256 kbps.

Anonymous said...

ffmpeg -i yourvideo.mp4 -ab 256 extracted_audio.mp3

Wyler replica watches said...

Your post is really informative for me. I liked it very much.

Davo said...

Disastrous. Degrades the audio, and makes sure it is proprietary.

ffmpeg -i Input.mkv -acodec copy -vn Output.oga

This will actually extract the audio, instead of transcoding it. Give the output filename whatever extension is appropriate.

Anonymous said...

"but stuck because you use Linux" is that a digg at linux punk. lol

Anonymous said...

Worked nicely. Thanks !

Oleksandr said...

If there are several audio tracks then one should first find the ID of the needed track:
mplayer -v my_video_file.avi | grep audio
there should be something like:
ADDED AUDIO PID 304, type: 50 stream n. 0
ADDED AUDIO PID 560, type: 50 stream n. 1
ADDED AUDIO PID 562, type: 50 stream n. 2
or
Auto-selected AVI audio ID = 1
then

mplayer -aid AudioPID -dumpaudio my_video_file.avi -dumpfile extracted_audio.mp3

Max Kanat-Alexander said...

For the ffmpeg comamnd line, it's best to also add:

-acodec copy

That way you get the exact audio track from the file with no re-encoding.

Anonymous said...

Just use VLC to Convert and extract audio to mp3

Post a Comment

Subscribe feeds via e-mail
Subscribe in your preferred RSS reader

Advertise on this site Sponsored links

Subscribe feeds rss Recent Entries

Categories

Subscribe feed rss Popular posts

Subscribe comments rss Recent Comments

Technorati

Technorati
My authority on technorati
Add this blog to your faves