Extract audio from video with FFmpeg

Pulls the audio track out of a video, copying it without re-encoding when the format allows.

ffmpeg -i https://cdn.rendobar.com/assets/examples/sample.mp4 -vn -c:a copy out.m4a
Encode
44 ms
Output
60.5 KB
Cost
$0.0014
Result
m4a

job_02d6b802c13b4e53

The part everyone gets wrong

-c:a copy extracts the existing audio stream byte for byte, so it is lossless and near-instant. It only works if the container you are writing to accepts that codec: AAC goes into .m4a, not .mp3. Reaching for MP3 forces a re-encode you did not need.

What the common version does

Re-encoding to MP3 loses quality and takes longer, when the source audio could have been copied out untouched.

ffmpeg -i https://cdn.rendobar.com/assets/examples/sample.mp4 -vn -c:a libmp3lame -b:a 192k out.mp3
It succeeds, and that is the problem

It did not error. It produced 118.7 KB against the correct command's 60.5 KB, a 2.0x larger file. A pipeline would accept this silently.

job_8937fd28df5342d6

Frequently asked questions

How do I extract audio from video?

Pulls the audio track out of a video, copying it without re-encoding when the format allows.

What goes wrong most often?

-c:a copy extracts the existing audio stream byte for byte, so it is lossless and near-instant. It only works if the container you are writing to accepts that codec: AAC goes into .m4a, not .mp3. Reaching for MP3 forces a re-encode you did not need.

What happens if I get it wrong?

We ran the naive version too. It did not error. It produced 118.7 KB against the correct command's 60.5 KB, a 2.0x larger file. A pipeline would accept this silently.

Do I need FFmpeg installed?

Not with Rendobar. The command on this page ran through the API against a URL, with no local FFmpeg and no server. The job id below it is the job that produced these numbers.

Run this without installing FFmpeg

This exact command ran through the API against a URL.