Extract AC3 from MP4 without Re-encoding using FFmpeg
This article provides a quick, step-by-step guide on how to extract a raw AC3 audio bitstream from an MP4 video container without re-encoding using FFmpeg. By utilizing stream copying, you can preserve the original audio quality and complete the extraction process almost instantly.
The FFmpeg Command
To extract the AC3 audio track without re-encoding, use the following FFmpeg command in your terminal or command prompt:
ffmpeg -i input.mp4 -vn -c:a copy output.ac3Command Breakdown
-i input.mp4: Specifies the path to your input MP4 video file.-vn: Blocks the video stream from being processed or included in the output file.-c:a copy: Instructs FFmpeg to copy the audio stream bit-for-bit. This bypasses the decoding and re-encoding process, preserving 100% of the original audio quality and completing the task in seconds.output.ac3: Mentions the output file name with the.ac3extension, which formats the copied stream as a raw Dolby Digital bitstream.
Extracting a Specific Audio Stream
If your MP4 file contains multiple audio tracks and you want to extract a specific AC3 stream, you must map the correct stream. First, inspect the file’s streams:
ffmpeg -i input.mp4Identify the index of the AC3 stream (for example,
Stream #0:2). You can then target and extract only that
stream using the -map option:
ffmpeg -i input.mp4 -map 0:2 -c:a copy output.ac3Using this method ensures you get the exact raw AC3 file you need without losing quality or wasting CPU cycles on re-encoding.