Skip to content

Instantly share code, notes, and snippets.

@spajus
Created January 25, 2023 07:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spajus/21ae60873061374072240c2c8868a828 to your computer and use it in GitHub Desktop.
Save spajus/21ae60873061374072240c2c8868a828 to your computer and use it in GitHub Desktop.
A batch file that uses ffmpeg to create high quality cropped gifs from any video footage
@echo off
if exist "%~1" (
echo "Will convert to gif: %~1"
) else (
echo "Usage: Drag and drop a video file on this script"
pause
exit 1
)
set "start_time=0.0"
set /p "start_time=Start time [0.0]: "
set "duration=10.0"
set /p "duration=Duration[10.0]: "
set "itsscale=1.0"
set /p "itsscale=Video speed [1.0]: "
set "fps=12"
set /p "fps="GIF FPS [12]: "
set "top_left=0:0"
set /p "top_left=Top Left (width:height) [0:0]: "
set "rect=640:480"
set /p "rect=Rect Size (width:height) [640:480]: "
set "out_w=640"
set /p "out_w=Gif Width [640]: "
@echo on
ffmpeg -ss %start_time% -t %duration% -itsscale %itsscale% -i "%~1" -vf "fps=%fps%,crop=%rect%:%top_left%,scale=w=%out_w%:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -y -loop 0 "%~1.gif"
echo "closing in 5 seconds"
sleep 5
REM pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment