(FFmpeg) How to extract audio from a video?

At times, you may have a video that you wish to extract the audio from. This is easily done by simply converting the video into an audio format. For example:

 $ ffmpeg -i input.mp4 -vn -acodec copy output.mp3 

A new argument -vn (no video) is used to ensure the encoded mp3 is only an audio file. FFMPEG is smart enough that this argument is optional in most cases. Here we also copy the input audio codec and use the same one in the output mp3.

If for any reason a conversion of a video to audio format results in a broken mp3, setting the mp3 codec to libmp3lame may fix the issue.

 $ ffmpeg -i input.mp4 -vn -acodec libmp3lame output.mp3 

FFMPEG does support just about any audio format you required including WAV, AIFF, FLAC, ALAC, ACC, WMA, etc. For a full list check out these other articles:

Love FFmpeg? Grab a copy of FFmpeg For Beginners on Kindle or Paperback to learn over 120 ways to master FFmpeg!

buy now on amazon