Last active
April 21, 2018 06:12
-
-
Save dungwinux/fa8820586caec4670b96c1a2da25f9fc to your computer and use it in GitHub Desktop.
Make gif with ffmpeg and gifski
This file contains 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 | |
set _excode= | |
REM Check commands if available | |
where ffmpeg.exe | |
set ffmpeg_check=%errorlevel% | |
where gifski.exe | |
set gifski_check=%errorlevel% | |
IF %ffmpeg_check% NEQ 0 echo Missing ffmpeg | |
IF %gifski_check% NEQ 0 echo Missing gifski | |
If %ffmpeg_check% NEQ 0 ( | |
IF %gifski_check% NEQ 0 ( | |
exit /B 1 | |
) | |
) | |
REM Check input | |
set fname=%1 | |
set filename=%~nx1 | |
set filenamewithoutext=%~n1 | |
echo %1 | |
echo %filename% | |
echo %filenamewithoutext% | |
If [%1] EQU [] ( | |
echo Drag a movie file to this bat | |
pause | |
exit /B 1 | |
) | |
IF NOT EXIST %fname% ( | |
echo File Not Found | |
pause | |
exit /B 1 | |
) | |
REM Process | |
set foldername=%filenamewithoutext%_%random% | |
md ".\%foldername%" | |
copy /Y %fname% ".\%foldername%" | |
echo Processing... %filename% to %filenamewithoutext%.gif | |
ffmpeg -i ".\%foldername%\%filename%" ".\%foldername%"\frame%%05d.png | |
IF %errorlevel% NEQ 0 ( | |
echo Error in ffmpeg | |
set _excode=1 | |
pause | |
GOTO:END | |
) | |
gifski -o "%filenamewithoutext%.gif" ".\%foldername%"\frame*.png | |
IF %errorlevel% NEQ 0 ( | |
echo Error in gifski | |
set _excode=1 | |
pause | |
GOTO:END | |
) | |
echo. | |
echo DONE! | |
:END | |
rmdir /S /Q ".\%foldername%" | |
exit /B %_excode% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment