Convert AAC to AC3 with FFmpeg

This article provides a straightforward guide on how to convert a video’s audio track from AAC to AC3 using FFmpeg in the Linux terminal. You will learn the exact command-line syntax required for a basic conversion, how to maintain original video quality without re-encoding, and how to adjust advanced audio settings like bitrates and channel layouts.

The Basic Conversion Command

To convert the audio track of a video from AAC to AC3 while keeping the video track exactly the same, use the following terminal command:

ffmpeg -i input.mp4 -c:v copy -c:a ac3 output.mp4

Breakdown of the Command

Advanced Fine-Tuning Options

If you need more control over the audio output, you can customize the bitrate and the number of audio channels during the conversion process.

Customizing the Audio Bitrate

By default, FFmpeg will choose a standard bitrate for the AC3 export. To manually set a higher quality bitrate (such as 640 kbps for 5.1 surround sound), add the -b:a flag:

ffmpeg -i input.mp4 -c:v copy -c:a ac3 -b:a 640k output.mp4

Specifying Audio Channels

If you are converting a file to be played on a specific home theater setup, you can force the audio channel layout using the -ac option. For example, to ensure the output is mixed into 6 channels (5.1 surround sound), use:

ffmpeg -i input.mp4 -c:v copy -c:a ac3 -ac 6 output.mp4

Batch Converting Multiple Files

If you have an entire directory of videos that need their audio converted from AAC to AC3, you can automate the process using a simple Bash loop in your Linux terminal:

for f in *.mp4; do ffmpeg -i "$f" -c:v copy -c:a ac3 "${f%.mp4}_ac3.mp4"; done

This loop finds every .mp4 file in the current folder, converts the audio track to AC3, and saves a new version with _ac3 appended to the filename, leaving your original files untouched.