KnightDanila / BAT_FFMPEG

Batch script files for FFMPEG (Microsoft Windows and DOS, OS/2 :unicorn:)
https://github.com/KnightDanila/BAT_FFMPEG
123 stars 28 forks source link

ffmpeg IF .bat condition on channel count and language #5

Open geextahslex opened 5 months ago

geextahslex commented 5 months ago

Hi I have a .bat file to convert and change channel volume levels(with ffmpeg) from 5.1 Audio to Stereo, and a different .bat for Stereo/Mono Audio that doesn't change loudness. Now I have to manually look if a movie is 5.1 or Mono/Stereo and decide which .bat to run. I would like to make one .bat with a condition so it looks what the channel layout is and then decide which profile to run. I hope this makes sense. It has to check also the language tag, because sometimes (in my case) german is 2.0 but English is 5.1 or vice versa.

Thank you for any advice

5.1

ffmpeg ^
    -i "%~1" ^
    -af "pan=stereo|c0=c2+0.6*c0+0.6*c4+c3|c1=c2+0.6*c1+0.6*c5+c3" -map 0:v:0 -c:v copy -map 0:a:m:language:ger -codec:a ac3 -b:a 160k -ar 44100 -sn -dn ^
    "G:\%~n1.mkv"

2.0/Mono

ffmpeg ^
    -i "%~1" ^
    -map 0:v:0 -c:v copy -map 0:a:m:language:ger -codec:a ac3 -b:a 160k -ar 44100 -sn -dn ^
    "G:\%~n1.mkv"

This is the whole .bat

@echo off
:again

ffmpeg ^
    -i "%~1" ^
    -map 0:v:0 -c:v copy -map 0:a:m:language:ger -codec:a ac3 -b:a 160k -ar 44100 -sn -dn ^
    "G:\%~n1.mkv"
if NOT ["%errorlevel%"]==["0"] goto:error
echo %~n1 Done!

shift
if "%~1" == "" goto:end
goto:again

:error

echo There was an error. Please check your input file or report an issue on github.com/L0Lock/FFmpeg-bat-collection/issues.
pause
exit 0

:end

cls
echo Encoding succesful. This window will close after 10 seconds.
timeout /t 1