Extract the MP3 Audio Portion of a Video

February 18th, 2009 by Mitch Frazier in

Your rating: None Average: 4.8 (16 votes)

How to use ffmpeg to separate an mp3 audio track from a video.
__________________________
Mitch Frazier is an Associate Editor for Linux Journal and the Web Editor for linuxjournal.com.


Special Magazine Offer -- Free Gift with Subscription
Receive a free digital copy of Linux Journal's System Administration Special Edition as well as instant online access to current and past issues. CLICK HERE for offer

Linux Journal: delivering readers the advice and inspiration they need to get the most out of their Linux systems since 1994.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anonymous's picture

Worked for me

On November 18th, 2009 Anonymous (not verified) says:

Very useful, much appreciated. MP4 to MP3, sweet as a nut.

Anonymous's picture

Idiots are fun to watch...

On February 20th, 2009 Anonymous (not verified) says:

Are you guys morons? He didn't say "extract", he said "separate", as if to bit-bucket the video and save the audio...in other words, transcoding...which is what you know-it-alls accuse him of doing...

That's like saying "You're not drinking, you're imbibing!".

Get a thesaurus, sheesh.

Anonymous's picture

Read the title: "Extract the

On February 21st, 2009 Anonymous (not verified) says:

Read the title: "Extract the MP3 Audio Portion of a Video" moron ... sheesh.

In any case it is very stupid to decode something encoded with lossy codec and encode it again with the same lossy codec, also compare how much CPU cycles takes unnecessary transcoding
vs. simple extracting on for example 2 hour video.

Anonymous's picture

You showed us transcoding,

On February 20th, 2009 Anonymous (not verified) says:

You showed us transcoding, not extracting. Proper way to extract audio (without transcoding and therefore without further loss of quality) is:

ffmpeg -i bd.flv -vn -acodec copy bd.mp3

Mitch Frazier's picture

Yes but be prepared

On February 21st, 2009 Mitch Frazier says:

That probably is a better solution except when it doesn't work. I have some videos which produce unplayable mp3 files when using "-acodec copy" whereas if I don't specify the argument they will play.

__________________________

Mitch Frazier is an Associate Editor for Linux Journal and the Web Editor for linuxjournal.com.

Anonymous's picture

Incompatible container

On February 21st, 2009 Anonymous (not verified) says:

That happens because ffmpeg blindly tries to copy audio stream into incompatible container, here's an example of copying vorbis audio stream from ogg container into mp3 container (and mp3 cannot hold vorbis):

ffmpeg -i in.ogg -acodec copy out.mp3

ffmpeg will do this without complaints, but mplayer cannot play this:

mplayer out.mp3

gives error. On the other hand matroska container is able to hold vorbis audio:

ffmpeg -i in.ogg -acodec copy out.mkv

and mplayer plays this with no error. So, "-acodec copy" should be used only if destination container can hold source codec.

Post new comment

Please note that comments may not appear immediately, so there is no need to repost your comment.
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <pre> <ul> <ol> <li> <dl> <dt> <dd> <i> <b>
  • Lines and paragraphs break automatically.

More information about formatting options

Newsletter

Each week Linux Journal editors will tell you what's hot in the world of Linux. You will receive late breaking news, technical tips and tricks, and links to in-depth stories featured on www.linuxjournal.com.
Sign up for our Email Newsletter

Tech Tip Videos

From the Magazine

December 2009, #188

If last month's Infrastrucuture issue was too "big" for you then try on this month's Embedded issue. Find out how to use Player for programming mobile robots, build a humidity controller for your root cellar, find out how to reduce the boot time of your embedded system, and if you're new to embedded systems find out the basics that go into one. You can also read about the Beagle Board, the Mesh Potato and a spate of other interestingly named items. And along with our regular columns don't miss our new monthly column: Economy Size Geek.


Read this issue