@echo off
if "" == "%1" goto _help
if "" == "%2" goto _help
if "" == "%3" goto _help
if "" == "%4" goto _help
if "" == "%5" goto _help
goto _main
:_help
echo.
echo AudioChangeFPS
echo.
echo Usage:
echo.
echo AudioChangeFPS.bat ^<Input File^> ^<Output File^> ^<Input FPS^> ^<Output FPS^> ^<Bitrate^>
echo.
echo FPS constants available:
echo.
echo 30.000 fps = ntsc, NTSC, 30, 30000
echo 25.000 fps = pal, PAL, 25, 25000
echo 23.976 fps = bd, BD, bluray, BLURAY, 23.976, 23,976, 23976
echo.
echo If you want to use a custom none listed above fps rate, then don't forget to
echo multiply by 1000. E.g. if you want to get 25 fps you have to use 25000 as
echo value or to get 23.976 fps you have to use 23976.
echo.
echo Examples:
echo.
echo AudioChangeFPS.bat "v:\de-25fps.ac3" "v:\de-23.976fps.ac3" 25000 23976 448
echo AudioChangeFPS.bat "v:\de-30fps.ac3" "v:\de-23.976fps.ac3" ntsc bd 640
echo AudioChangeFPS.bat "v:\de-23.976fps.ac3" "v:\de-30fps.ac3" 23,976 30 640
goto _end
:_main
rem Setting global params
set besweet=P:\Program Files (x86)\.encoding\BeSweet\besweet.exe
set infile=%1
set inext=%~x1
set outfile=%2
set outext=%~x2
set infps=%3
set outfps=%4
set bitrate=%5
rem Setting FPS constants
set ntscfps=30000
set palfps=25000
set bdfps=23976
rem Setting FPS by alias
if "ntsc" == "%3" set infps=%ntscfps%
if "NTSC" == "%3" set infps=%ntscfps%
if "pal" == "%3" set infps=%palfps%
if "PAL" == "%3" set infps=%palfps%
if "bd" == "%3" set infps=%bdfps%
if "BD" == "%3" set infps=%bdfps%
if "bluray" == "%3" set infps=%bdfps%
if "BLURAY" == "%3" set infps=%bdfps%
if "30" == "%3" set infps=%ntscfps%
if "25" == "%3" set infps=%palfps%
if "23.976" == "%3" set infps=%bdfps%
if "23,976" == "%3" set infps=%bdfps%
if "ntsc" == "%4" set outfps=%ntscfps%
if "NTSC" == "%4" set outfps=%ntscfps%
if "pal" == "%4" set outfps=%palfps%
if "PAL" == "%4" set outfps=%palfps%
if "bd" == "%4" set outfps=%bdfps%
if "BD" == "%4" set outfps=%bdfps%
if "bluray" == "%4" set outfps=%bdfps%
if "BLURAY" == "%4" set outfps=%bdfps%
if "30" == "%4" set outfps=%ntscfps%
if "25" == "%4" set outfps=%palfps%
if "23.976" == "%4" set outfps=%bdfps%
if "23,976" == "%4" set outfps=%bdfps%
rem Preparing commandline
set cmdline="%besweet%" -core( -input %infile% -output %outfile% ) -ota( -r %infps% %outfps% )
rem Add bitrate
if "%outext%" == ".mp2" set cmdline=%cmdline% -toolame( -m s -e -b %bitrate% )
if "%outext%" == ".MP2" set cmdline=%cmdline% -toolame( -m s -e -b %bitrate% )
if "%outext%" == ".mp3" set cmdline=%cmdline% -lame( --scale 1 -p --alt-preset %bitrate% )
if "%outext%" == ".MP3" set cmdline=%cmdline% -lame( --scale 1 -p --alt-preset %bitrate% )
if "%outext%" == ".ac3" set cmdline=%cmdline% -ac3enc( -b %bitrate% )
if "%outext%" == ".AC3" set cmdline=%cmdline% -ac3enc( -b %bitrate% )
if "%outext%" == ".dts" set cmdline=%cmdline% -surcd( -b %bitrate% )
if "%outext%" == ".DTS" set cmdline=%cmdline% -surcd( -b %bitrate% )
if "%outext%" == ".ogg" set cmdline=%cmdline% -ogg( -q %bitrate% )
if "%outext%" == ".OGG" set cmdline=%cmdline% -ogg( -q %bitrate% )
rem Converting
echo.
echo Executing...
echo.
echo %cmdline%
echo.
%cmdline%
goto _end
:_end