Add files via upload
Update Credits and add comments to explain how the script works.
This commit is contained in:
parent
3dbc772241
commit
537124767a
45
gifconv.bat
45
gifconv.bat
|
@ -1,15 +1,17 @@
|
|||
@ECHO OFF
|
||||
REM By: MDHEXT, Nabi KaramAliZadeh <nabikaz@gmail.com>
|
||||
REM Description: Video to GIF converter
|
||||
REM Version: 5.1
|
||||
REM Url: https://github.com/MDHEXT/video2gif, forked from https://github.com/NabiKAZ/video2gif
|
||||
REM License: The MIT License (MIT)
|
||||
:: By: MDHEXT, Nabi KaramAliZadeh <nabikaz@gmail.com>
|
||||
:: Description: Video to GIF converter
|
||||
:: Version: 5.5
|
||||
:: Url: https://github.com/MDHEXT/video2gif, forked from https://github.com/NabiKAZ/video2gif
|
||||
:: What this script is based on: http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
|
||||
:: License: The MIT License (MIT)
|
||||
|
||||
SETLOCAL ENABLEDELAYEDEXPANSION
|
||||
SET input="%~1"
|
||||
SET vid="%~dpnx1"
|
||||
SET output=%~dpn1.gif
|
||||
SET FILEPATH=%~dp1
|
||||
:: Storing Paths
|
||||
|
||||
SET "scale="
|
||||
SET "fps="
|
||||
|
@ -21,6 +23,7 @@ SET "duration="
|
|||
SET "colormax="
|
||||
SET "version="
|
||||
SET "build="
|
||||
:: Clearing all variables
|
||||
|
||||
SET WD=%TEMP%\GIFCONV
|
||||
SET palette=%WD%\template
|
||||
|
@ -32,17 +35,19 @@ FOR /F "delims=" %%a in ('ffmpeg -version') DO (
|
|||
)
|
||||
)
|
||||
GOTO :help_check_1
|
||||
:: Setting the path to the Working Directory and storing FFmpeg Version String
|
||||
|
||||
:help_message
|
||||
ECHO -------------------------------------------------------------------------------------------------------------
|
||||
ECHO [96mVideo to GIF converter v5.1 ^(C^) 2017-2021, MDHEXT ^&^ Nabi KaramAliZadeh ^<nabikaz@gmail.com^>[0m
|
||||
ECHO ------------------------------------------------------------------------------------------------------------------------------------
|
||||
ECHO [96mVideo to GIF converter v5.5 ^(C^) 2017-2022, MDHEXT ^&^ Nabi KaramAliZadeh ^<nabikaz@gmail.com^>[0m
|
||||
ECHO [96mYou can download this fork from here: https://github.com/MDHEXT/video2gif[0m
|
||||
ECHO [96myou can download the original release here: https://github.com/NabiKAZ/video2gif[0m
|
||||
ECHO [96mThis tool uses ffmpeg, you can download that here: https://www.ffmpeg.org/download.html#build-windows[0m
|
||||
ECHO -------------------------------------------------------------------------------------------------------------
|
||||
ECHO [95mThis tool wouldn't be possible without the research listed here: http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html[0m
|
||||
ECHO ------------------------------------------------------------------------------------------------------------------------------------
|
||||
ECHO [32mUsage:[0m
|
||||
ECHO gifconv [input_file] [Arguments]
|
||||
ECHO -------------------------------------------------------------------------------------------------------------
|
||||
ECHO ------------------------------------------------------------------------------------------------------------------------------------
|
||||
ECHO [32mArguments:[0m
|
||||
ECHO -o : Specifies output filename. [96m(will be outputted to the same directory as your input video file.)[0m
|
||||
ECHO If left empty, [33mthis will default to the same filename as your video.[0m
|
||||
|
@ -58,13 +63,13 @@ ECHO -e : Specifies the duration of the gif file in seconds. [96m(Optional)[0m
|
|||
ECHO -c : Sets the maximum amount of colors useable per palette. [96m(Value up to 256)[0m [33mThis option isn't used
|
||||
ECHO by default.[0m
|
||||
ECHO -k : Enables error diffusion. [96m(Optional)[0m
|
||||
ECHO -p : Opens the resulting GIF file in the default Photo Viewer. [96m(Optional)[0m
|
||||
ECHO -------------------------------------------------------------------------------------------------------------
|
||||
ECHO -p : Opens the resulting GIF file in your default Photo Viewer. [96m(Optional)[0m
|
||||
ECHO ------------------------------------------------------------------------------------------------------------------------------------
|
||||
ECHO [32mPalettegen Modes:[0m
|
||||
ECHO 1: diff - only what moves affects the palette
|
||||
ECHO 2: single - one palette per frame
|
||||
ECHO 3: full - one palette for the whole gif
|
||||
ECHO -------------------------------------------------------------------------------------------------------------
|
||||
ECHO ------------------------------------------------------------------------------------------------------------------------------------
|
||||
ECHO [32mDithering Options:[0m
|
||||
ECHO 1: Bayer
|
||||
ECHO 2: Heckbert
|
||||
|
@ -72,12 +77,16 @@ ECHO 3: Floyd Steinberg
|
|||
ECHO 4: Sierra2
|
||||
ECHO 5: Sierra2_4a
|
||||
ECHO 6: No Dithering
|
||||
ECHO -------------------------------------------------------------------------------------------------------------
|
||||
ECHO ------------------------------------------------------------------------------------------------------------------------------------
|
||||
ECHO [32mAbout Bayerscale:[0m
|
||||
ECHO [31mWhen bayer dithering is selected[0m, the Bayer Scale option defines the scale of the pattern (how much the
|
||||
ECHO crosshatch pattern is visible). A low value means more visible pattern for less banding, and higher value
|
||||
ECHO means less visible pattern at the cost of more banding. The option must be an integer value in the range
|
||||
ECHO [0,5]. [33mThe Default is 2.[0m [96mBayer Scale is optional.[0m
|
||||
ECHO ------------------------------------------------------------------------------------------------------------------------------------
|
||||
ECHO [95mPeople who made this project come to fruition:[0m
|
||||
ECHO ubitux, Nabi KaramAliZadeh, and the very kind and patient people in the Batch Discord Server.
|
||||
ECHO Without these people's contributions, This script would not be possible. Thank you all for your contributions and assistence^^!
|
||||
GOTO :EOF
|
||||
|
||||
:safchek
|
||||
|
@ -112,6 +121,7 @@ IF DEFINED bayerscale (
|
|||
)
|
||||
)
|
||||
GOTO :script_start
|
||||
:: Setting a clear range of acceptable setting values and noob proofing bayerscale
|
||||
|
||||
:varin
|
||||
IF NOT "%~1" =="" (
|
||||
|
@ -129,6 +139,7 @@ IF NOT "%~1" =="" (
|
|||
SHIFT & GOTO :varin
|
||||
)
|
||||
GOTO :help_check_2
|
||||
:: Using SHIFT command to go through the input and storing each setting into its own variable
|
||||
|
||||
:help_check_1
|
||||
IF %input% == "" GOTO :help_message
|
||||
|
@ -136,6 +147,7 @@ IF %input% == "help" GOTO :help_message
|
|||
IF %input% == "h" GOTO :help_message
|
||||
IF %input% == "-h" GOTO :help_message
|
||||
GOTO :varin
|
||||
:: Checking for blank input or help commands
|
||||
|
||||
:help_check_2
|
||||
IF NOT DEFINED scale SET "scale=-1"
|
||||
|
@ -143,12 +155,14 @@ IF NOT DEFINED fps SET fps=15
|
|||
IF NOT DEFINED mode SET mode=1
|
||||
IF NOT DEFINED dither SET dither=1
|
||||
GOTO :safchek
|
||||
:: Noob proofing the script to prevent it from breaking should critical settings not be defined
|
||||
|
||||
:script_start
|
||||
ECHO [33m%version%[0m
|
||||
ECHO [33m%build%[0m
|
||||
ECHO [32mCreating Working Directory...[0m
|
||||
MD "%WD%"
|
||||
:: Displaying FFmpeg Version String and Creating the Working Directory
|
||||
|
||||
:palettegen
|
||||
ECHO [32mGenerating Palette...[0m
|
||||
|
@ -166,6 +180,7 @@ IF NOT DEFINED start_time (
|
|||
GOTO :cleanup
|
||||
)
|
||||
)
|
||||
:: Noob Proofing clipping
|
||||
|
||||
SET frames=%palette%_%%05d
|
||||
SET filters=fps=%fps%,scale=%scale%:-1:flags=lanczos
|
||||
|
@ -187,6 +202,7 @@ IF NOT EXIST "%palette%_00001.png" (
|
|||
GOTO :cleanup
|
||||
)
|
||||
)
|
||||
:: Putting together command to generate palette, executing it, and then checking if the file is in the Working Directory, if not, cleaning up working files
|
||||
|
||||
ECHO [32mEncoding Gif file...[0m
|
||||
IF %mode% EQU 1 SET decode=paletteuse
|
||||
|
@ -212,9 +228,11 @@ IF %dither% LEQ 5 (
|
|||
IF NOT DEFINED errorswitch SET ditherenc==dither=!ditheralg!
|
||||
)else SET ditherenc=:dither=!ditheralg!
|
||||
)
|
||||
:: Setting variables to put the command together; checking for Error Diffusion if using Bayer Scale and adjusting the command accordingly
|
||||
|
||||
IF NOT DEFINED bayerscale SET "bayer="
|
||||
IF DEFINED bayerscale SET bayer=:bayer_scale=%bayerscale%
|
||||
:: Checking for Bayer Scale and adjusting command
|
||||
|
||||
ffmpeg -v warning %trim% -i %vid% -thread_queue_size 512 -i "%frames%.png" -lavfi "%filters% [x]; [x][1:v] %decode%%errordiff%%ditherenc%%bayer%" -y "%output%"
|
||||
|
||||
|
@ -222,6 +240,7 @@ IF NOT EXIST "%output%" (
|
|||
ECHO [31mFailed to generate gif file[0m
|
||||
GOTO :cleanup
|
||||
)
|
||||
:: Checking if gif was created and cleaning up if not
|
||||
|
||||
IF DEFINED picswitch START "" "%output%"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user