Skip to content

Instantly share code, notes, and snippets.

@anzz1
Created March 15, 2023 21:25
Show Gist options
  • Save anzz1/e99fbce668ea72018ac967a3dc3ba9e9 to your computer and use it in GitHub Desktop.
Save anzz1/e99fbce668ea72018ac967a3dc3ba9e9 to your computer and use it in GitHub Desktop.
gif.bat
@echo off
if [%~1]==[] echo gif: No input file specified.&exit /b 1
:loop
if [%~x1]==[.gif] (set "_outfile=%~n1_1.gif") else (set "_outfile=%~n1.gif")
ffmpeg -hide_banner -vsync 0 -i "%~1" -vf "fps=20,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 -final_delay 300 -f gif "%_outfile%" || call :chksz "%_outfile%"
shift
if not [%~1]==[] goto loop
goto :eof
:chksz
if [%~z1]==[0] del "%~1"
exit /b 0
:eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment