Last active
December 6, 2023 04:45
-
-
Save 0b5vr/667e58a884f868bfda875f1bebc3e09b to your computer and use it in GitHub Desktop.
Batch: png to gif
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 | |
setlocal | |
rem (c) 0b5vr, MIT License https://opensource.org/licenses/MIT | |
set START=0 | |
set WIDTH=-1 | |
set COLORS=32 | |
set RATE=50 | |
set OUTPUT=renban.gif | |
set PATTERN=%%05d.png | |
:params | |
if [%1] == [] goto process | |
if "%1" == "-h" goto help | |
if "%1" == "-s" set START=%2 | |
if "%1" == "-w" set WIDTH=%2 | |
if "%1" == "-c" set COLORS=%2 | |
if "%1" == "-r" set RATE=%2 | |
if "%1" == "-o" set OUTPUT=%2 | |
if "%1" == "--pattern" set PATTERN=%2 | |
shift | |
shift | |
goto params | |
:process | |
set PALETTE=palette.png | |
set FILTERS=fps=%RATE%,scale=%WIDTH%:-1:flags=lanczos | |
ffmpeg -v warning -f image2 -r %RATE% -start_number %START% -i %PATTERN% -vf "%FILTERS%,palettegen=max_colors=%COLORS%" -y %PALETTE% | |
ffmpeg -v warning -f image2 -r %RATE% -start_number %START% -i %PATTERN% -i %PALETTE% -lavfi "%FILTERS% [x]; [x][1:v] paletteuse" %OUTPUT% | |
del %PALETTE% | |
goto end | |
:help | |
echo Usage: | |
echo renban | |
echo. | |
echo Options: | |
echo -h show this help | |
echo -s start number | |
echo -w width in pixels | |
echo -c number of colors | |
echo -r frame rate | |
echo -o output file | |
echo --pattern image maching pattern. default is %%%%05d.png | |
echo. | |
goto end | |
:end | |
endlocal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment