@echo off setlocal EnableExtensions if "%~1"=="" goto usage if "%~2"=="" goto usage where ffmpeg >nul 2>nul if errorlevel 1 ( echo ffmpeg not found in PATH. exit /b 1 ) if not exist "%~1" ( echo Input file not found: %~1 exit /b 1 ) if /I "%~1"=="%~2" ( echo Output must differ from input. exit /b 1 ) if exist "%~2" ( echo Output already exists: %~2 exit /b 1 ) if /I not "%~x2"==".mp4" ( echo Output file must have .mp4 extension. exit /b 1 ) ffmpeg -hide_banner -nostdin -i "%~1" -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -c:v libx264 -crf 20 -pix_fmt yuv420p -an -movflags +faststart "%~2" if errorlevel 1 ( echo ffmpeg failed. exit /b 1 ) echo Done: %~2 exit /b 0 :usage echo Usage: gif_to_mp4.bat animation.gif animation.mp4 exit /b 2