Created
January 25, 2023 07:00
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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