Add files via upload

Update Credits and add comments to explain how the script works.
This commit is contained in:
MDHEXT 2022-01-30 15:52:12 -07:00 committed by GitHub
parent 3dbc772241
commit 537124767a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 Video to GIF converter v5.1 ^(C^) 2017-2021, MDHEXT ^&^ Nabi KaramAliZadeh ^<nabikaz@gmail.com^>
ECHO ------------------------------------------------------------------------------------------------------------------------------------
ECHO Video to GIF converter v5.5 ^(C^) 2017-2022, MDHEXT ^&^ Nabi KaramAliZadeh ^<nabikaz@gmail.com^>
ECHO You can download this fork from here: https://github.com/MDHEXT/video2gif
ECHO you can download the original release here: https://github.com/NabiKAZ/video2gif
ECHO This tool uses ffmpeg, you can download that here: https://www.ffmpeg.org/download.html#build-windows
ECHO -------------------------------------------------------------------------------------------------------------
ECHO This tool wouldn't be possible without the research listed here: http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
ECHO ------------------------------------------------------------------------------------------------------------------------------------
ECHO Usage:
ECHO gifconv [input_file] [Arguments]
ECHO -------------------------------------------------------------------------------------------------------------
ECHO ------------------------------------------------------------------------------------------------------------------------------------
ECHO Arguments:
ECHO -o : Specifies output filename. (will be outputted to the same directory as your input video file.)
ECHO If left empty, this will default to the same filename as your video.
@ -58,13 +63,13 @@ ECHO -e : Specifies the duration of the gif file in seconds. (Optional)
ECHO -c : Sets the maximum amount of colors useable per palette. (Value up to 256) This option isn't used
ECHO by default.
ECHO -k : Enables error diffusion. (Optional)
ECHO -p : Opens the resulting GIF file in the default Photo Viewer. (Optional)
ECHO -------------------------------------------------------------------------------------------------------------
ECHO -p : Opens the resulting GIF file in your default Photo Viewer. (Optional)
ECHO ------------------------------------------------------------------------------------------------------------------------------------
ECHO Palettegen Modes:
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 Dithering Options:
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 About Bayerscale:
ECHO When bayer dithering is selected, 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]. The Default is 2. Bayer Scale is optional.
ECHO ------------------------------------------------------------------------------------------------------------------------------------
ECHO People who made this project come to fruition:
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 %version%
ECHO %build%
ECHO Creating Working Directory...
MD "%WD%"
:: Displaying FFmpeg Version String and Creating the Working Directory
:palettegen
ECHO Generating Palette...
@ -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 Encoding Gif file...
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 Failed to generate gif file
GOTO :cleanup
)
:: Checking if gif was created and cleaning up if not
IF DEFINED picswitch START "" "%output%"