Extract Audio from Video

To extract the audio from a video file using FFmpeg, you can copy the existing audio track without re-encoding it. This process is fast and preserves the original audio quality.

The Command

Here is the most common command to extract audio:

ffmpeg -i input.mp4 -vn -c:a copy output.aac

Command Breakdown

  • ffmpeg: This starts the FFmpeg program.
  • -i input.mp4: This specifies the input file you want to extract the audio from (replace input.mp4 with your video file’s name).
  • -vn: This is a key part of the command. It stands for Video No, telling FFmpeg to completely ignore the video track.
  • -c:a copy: This tells FFmpeg to use the audio codec named copy. This means it directly copies the audio stream from the video file to the new audio file without changing it.
  • output.aac: This is the name of your new audio file. The .aac extension is used here because it is a very common audio format in modern video files. If the original audio was in a different format (like MP3), you could use output.mp3.

Converting Audio While Extracting

If you want to save the audio in a specific format like MP3, instead of just copying the stream, you would tell FFmpeg to encode it.

Example: Convert to MP3

ffmpeg -i input.mp4 -vn -c:a libmp3lame output.mp3

In this case, -c:a libmp3lame tells FFmpeg to encode the audio using the popular libmp3lame MP3 encoder. This is useful if your goal is to have the final file in a specific format, not just to extract the original audio track.

Guides