Last active
August 20, 2025 17:41
-
-
Save seamonkey420/81102b2c3ba61766ed43da41b3bb11d6 to your computer and use it in GitHub Desktop.
OLD - FFMPEG - Add AC3 audio stream while keeping original video, audio, subtitles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :: below command will retain original audio stream and then create 2nd stream encoded in ac3 | |
| :: move ffmpmeg to c:\windows\system32 | |
| :: -vf "crop=trunc(iw/2)*2:trunc(ih/2)*2" command added to avoid errors with cropping | |
| :: this will retain all prev audio streams and just add a new ac3 stream (converts first audio stream to ac3) | |
| :: | |
| :: THIS does take a LONG TIME and would not recommend this method, use my extract audio as ac3 for fastest way! | |
| :: Also my mapping may be messed up on this one too, def test on test files first! | |
| ::---------------------------------------- | |
| setlocal EnableExtensions DisableDelayedExpansion | |
| ::get filename and extensions as variables | |
| set _name=%~n1 | |
| set _ext=%~x1 | |
| ::add ac3 audio track | |
| ffmpeg -i "%_name%%_ext%" -vf pad="width=ceil(iw/2)*2:height=ceil(ih/2)*2" -map 0:v -map 0:a -map 0:s? -c:a copy -map 0:a:0 -c:a:0 ac3 -b:a 640k -center_mixlev 0.707 -c:s copy "%_name%.NEW%_ext%" |
Author
Author
updated: this will now work with aac files, does take a while to process. eac3 streams still need to use above workaround with eac3to and mkvtoolnix.
Author
this method is WAY TOO time consuming, i have created a new gist that uses ffmpeg and mkvtoolnix, avg time to extrac ac3 file and then multiplex is around 3 mins vs this one that takes up to 30 mins!!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FYI: eac audio streams do not convert to ac3, remain eac. as a workaround here is what i do:
use eac3to to extract EAC file as ff-ac3, then use mkvtoolnix to add ac3 file back to original file (be sure to set compress = no so it will copy streams as is)