@echo off

REM Rate factor is the encoding quality, 0 being lossless, 51 being worse possible.
REM The sane range is 18 to 28, 18 being visually lossless, 23 being default.
SET RATE_FACTOR=21

REM Set the audio bitrate here, 128k should be more than enough.
SET AUDIO_BITRATE=192k

CD /d "%~dp0"

ffmpeg -i "%~1" -c:v libx264 -preset slow -crf %RATE_FACTOR% -profile:v high -level 4.1 -movflags +faststart -pix_fmt yuv420p -tune zerolatency -c:a libfdk_aac -b:a %AUDIO_BITRATE% -f mp4 "%~1-out.mp4"

pause
