Skip to content

Instantly share code, notes, and snippets.

@seamonkey420
Created January 25, 2025 03:47
Show Gist options
  • Select an option

  • Save seamonkey420/467d7ffa44a816e76287946e571ba9cb to your computer and use it in GitHub Desktop.

Select an option

Save seamonkey420/467d7ffa44a816e76287946e571ba9cb to your computer and use it in GitHub Desktop.
Extract and Add AC3 audio stream
:: Extract main audio track as AC3 for mkvtoolnix adding
:: Opens mvktoolnix with original mkv file to then add ac3 manually
:: Recommended: create Scripts folder in your user folder and then copy MKVToolnix portable there
:: This will retain all original video/audio/subtitle streams and make ac3 versions of
:: all audiostreams in mka form and then open mkvtoolnix with said files to then multiplex.
:: seamonkey420
:: 1/14/2025
::------------
setlocal EnableExtensions DisableDelayedExpansion
:: set mkvtoolnix-gui.exe location: update to where you have yours installed
set _mkvtool=C:\Users\username\Scripts\MKVToolNix\mkvtoolnix-gui.exe
::get path filename and extensions as variables
set _path=%~dp1
set _name=%~n1
set _ext=%~x1
ffmpeg -i "%_name%%_ext%" -map 0:a -c:a ac3 -b:a 640k -center_mixlev 0.707 "%_name%".mka
:: launches mkvtoolnix-gui with original file and ac3 audio stream
:: setting in mkvtoolnix: When adding files via drag and drop/copy and paste:
:: create one new multiplex settings add all files there
start "" "%_mkvtool%" %1 "%_path%%_name%.mka"
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment