Skip to content

Instantly share code, notes, and snippets.

@vanhecke
Created December 13, 2014 15:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanhecke/06d574594c1e5d26ae57 to your computer and use it in GitHub Desktop.
Save vanhecke/06d574594c1e5d26ae57 to your computer and use it in GitHub Desktop.
Converts all MKV's audio from ac3 to aac. For playing scene releases on iOS.
@echo off
rem
rem
rem
rem
rem
rem START CONFIGURATION
cd "C:\Users\Joris\Videos\Converted"
set mkvextract="C:\Program Files\MKVToolNix\mkvextract.exe"
set mplayer="C:\Tools\bin\mplayer.exe"
set neroAacEnc="C:\Tools\bin\neroAacEnc.exe"
set mkvmerge="C:\Program Files\MKVToolNix\mkvmerge.exe"
rem STOP CONFIGURATION
rem
rem
rem
rem
rem
rem
rem
rem You shouldn't edit below this line.
if not exist %mkvextract% (
echo ERROR: mkvextract not found!
exit /B
)
if not exist %mplayer% (
echo ERROR: mplayer not found!
exit /B
)
if not exist %neroAacEnc% (
echo ERROR: neroAacEnc not found!
exit /B
)
if not exist %mkvmerge% (
echo ERROR: mkvmerge not found!
exit /B
)
rem Create folders
if not exist original mkdir original
if not exist converted mkdir converted
if exist working_dir rd /S /Q working_dir
if not exist working_dir mkdir working_dir
echo %cd%
rem Move files to the original folder
echo Copying MKV files to folder original
for /f "delims=" %%i in ('dir *.mkv /b') do (move /Y %%i original\%%i 2>NUL >NUL)
rem Extract Track 0 (Video) and Track 1 (Audio) to working_dir
echo Splitting MKV files
for /f "delims=" %%i in ('dir original\*.mkv /b') do %mkvextract% tracks -q original\%%i 0:working_dir\%%i.h264 1:working_dir\%%i.ac3
rem Convert ac3 to wav
echo Dumping ac3 to wav
for /f "delims=" %%i in ('dir working_dir\*.ac3 /b') do (%mplayer% -really-quiet -nomsgcolor -benchmark -noautosub -nosub -channels 2 -af channels=2,format=s16le -vo null -ao pcm:waveheader:fast:file=working_dir\%%~ni.wav working_dir\%%i >NUL)
rem Convert wav to aac
echo Converting wav/ac3 to aac
for /f "delims=" %%i in ('dir working_dir\*.wav /b') do (%neroAacEnc% -lc -q 0.5 -ignorelength -if working_dir\%%i -of working_dir\%%~ni.aac >NUL)
rem Combine h264 with aac
echo Combining h264 with aac
for /f "delims=" %%i in ('dir working_dir\*.h264 /b') do (%mkvmerge% -q -o converted\%%~ni working_dir\%%i working_dir\%%~ni.aac >NUL)
rem Delete working_dir
echo Cleaning up
if exist working_dir rd /S /Q working_dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment