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
-i input.mp4: Specifies the path to your source video file.-c:v copy: Tells FFmpeg to stream-copy the video track. This skips the re-encoding process for the video, saving time and preserving the original video quality.-c:a ac3: Instructs FFmpeg to encode the audio track into AC3 (Dolby Digital) format.output.mp4: The name and format of your newly generated file.
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.