Extract the MP3 Audio Portion of a Video

FAIL (the browser should render some flash content, not this).

How to use ffmpeg to separate an mp3 audio track from a video.


Comment viewing options

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

Thank you so much.. I was

Premkumar Masilamani's picture

Thank you so much.. I was looking for a tool in linux to do this stuff. I am pretty happy to be able to do it in command line :)

Worked for me

Anonymous's picture

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

Idiots are fun to watch...

Anonymous's picture

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.

Read the title: "Extract the

Anonymous's picture

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.

You showed us transcoding,

Anonymous's picture

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

Yes but be prepared

Mitch Frazier's picture

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.

Incompatible container

Anonymous's picture

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.

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState