Change to use color variables for readability
This commit is contained in:
+61
-51
@@ -9,6 +9,13 @@
|
||||
:: Enable delayed variable expension
|
||||
SETLOCAL ENABLEDELAYEDEXPANSION
|
||||
|
||||
:: Colors
|
||||
SET OFF=[0m
|
||||
SET GREEN=[32m
|
||||
SET YELLOW=[33m
|
||||
SET RED=[91m
|
||||
SET CYAN=[96m
|
||||
|
||||
:: Storing Paths
|
||||
SET input="%~1"
|
||||
SET vid="%~dpnx1"
|
||||
@@ -79,7 +86,7 @@ GOTO :safchek
|
||||
:: Output file type
|
||||
echo %filetype% | findstr /r "\<gif\> \<png\> \<apng\> \<webp\>" >nul
|
||||
IF %errorlevel% NEQ 0 (
|
||||
ECHO [91mNot a valid file type[0m
|
||||
ECHO %RED%Not a valid file type: %filetype%%OFF%
|
||||
GOTO :EOF
|
||||
)
|
||||
IF "%filetype%"=="png" SET filetype=apng
|
||||
@@ -89,33 +96,33 @@ IF "%filetype%"=="gif" SET output=%output%.gif
|
||||
|
||||
:: Palettegen
|
||||
IF %mode% GTR 3 (
|
||||
ECHO [91mNot a valid palettegen mode[0m
|
||||
ECHO %RED%Not a valid palettegen mode%OFF%
|
||||
GOTO :EOF
|
||||
) ELSE IF %mode% LSS 1 (
|
||||
ECHO [91mNot a valid palettegen mode[0m
|
||||
ECHO %RED%Not a valid palettegen mode%OFF%
|
||||
GOTO :EOF
|
||||
)
|
||||
:: Dithering
|
||||
IF %dither% GTR 8 (
|
||||
ECHO [91mNot a valid dither algorithm[0m
|
||||
ECHO %RED%Not a valid dither algorithm%OFF%
|
||||
GOTO :EOF
|
||||
) ELSE IF %dither% LSS 0 (
|
||||
ECHO [91mNot a valid dither algorithm[0m
|
||||
ECHO %RED%Not a valid dither algorithm%OFF%
|
||||
GOTO :EOF
|
||||
)
|
||||
|
||||
:: Bayerscale
|
||||
IF DEFINED bayerscale (
|
||||
IF !bayerscale! GTR 5 (
|
||||
ECHO [91mNot a valid bayerscale value[0m
|
||||
ECHO %RED%Not a valid bayerscale value%OFF%
|
||||
GOTO :EOF
|
||||
) ELSE IF !bayerscale! LSS 0 (
|
||||
ECHO [91mNot a valid bayerscale value[0m
|
||||
ECHO %RED%Not a valid bayerscale value%OFF%
|
||||
GOTO :EOF
|
||||
)
|
||||
IF !bayerscale! LEQ 5 (
|
||||
IF %dither% NEQ 1 (
|
||||
ECHO [91mThis setting only works with bayer dithering[0m
|
||||
ECHO %RED%This setting only works with bayer dithering%OFF%
|
||||
GOTO :EOF
|
||||
)
|
||||
)
|
||||
@@ -124,13 +131,13 @@ IF DEFINED bayerscale (
|
||||
:: Lossy WEBP
|
||||
IF DEFINED webp_lossy (
|
||||
IF NOT "%filetype%" == "webp" (
|
||||
ECHO [91mLossy is only valid for filetype webp[0m
|
||||
ECHO %RED%Lossy is only valid for filetype webp%OFF%
|
||||
GOTO :EOF
|
||||
) ELSE IF !webp_lossy! GTR 100 (
|
||||
ECHO [91mNot a valid lossy quality value[0m
|
||||
ECHO %RED%Not a valid lossy quality value%OFF%
|
||||
GOTO :EOF
|
||||
) ELSE IF !webp_lossy! LSS 0 (
|
||||
ECHO [91mNot a valid lossy quality value[0m
|
||||
ECHO %RED%Not a valid lossy quality value%OFF%
|
||||
GOTO :EOF
|
||||
)
|
||||
)
|
||||
@@ -139,14 +146,14 @@ IF DEFINED webp_lossy (
|
||||
IF DEFINED start_time (
|
||||
IF DEFINED end_time SET "trim=-ss !start_time! -to !end_time!"
|
||||
IF NOT DEFINED end_time (
|
||||
ECHO [91mPlease input the end time[0m
|
||||
ECHO %RED%Please input the end time%OFF%
|
||||
GOTO :EOF
|
||||
)
|
||||
)
|
||||
|
||||
IF NOT DEFINED start_time (
|
||||
IF DEFINED end_time (
|
||||
ECHO [91mPlease input the start time[0m
|
||||
ECHO %RED%Please input the start time%OFF%
|
||||
GOTO :EOF
|
||||
)
|
||||
)
|
||||
@@ -163,10 +170,10 @@ FOR /F "delims=" %%a in ('ffmpeg -version') DO (
|
||||
)
|
||||
|
||||
:: Displaying FFmpeg version string and creating the working directory
|
||||
ECHO [33m%version%[0m
|
||||
ECHO [33m%build%[0m
|
||||
ECHO [92mOutput file: %output%[0m
|
||||
ECHO [32mCreating working directory...[0m
|
||||
ECHO %YELLOW%%version%%OFF%
|
||||
ECHO %YELLOW%%build%%OFF%
|
||||
ECHO %GREEN%Output file:%OFF% %output%
|
||||
ECHO %GREEN%Creating working directory...%OFF%
|
||||
MD "%WD%"
|
||||
|
||||
:palettegen
|
||||
@@ -187,13 +194,14 @@ IF DEFINED colormax (
|
||||
)
|
||||
|
||||
:: Executing command to generate palette
|
||||
ECHO [32mGenerating palette...[0m
|
||||
ECHO %GREEN%Generating palette...%OFF%
|
||||
echo ffmpeg -v %loglevel% %trim% -i %vid% -vf "%filters%,%encode%%mcol%" -y "%frames%.png"
|
||||
ffmpeg -v %loglevel% %trim% -i %vid% -vf "%filters%,%encode%%mcol%" -y "%frames%.png"
|
||||
|
||||
:: Checking if the palette file is in the Working Directory, if not cleaning up
|
||||
IF NOT EXIST "%palette%_00001.png" (
|
||||
IF NOT EXIST "%palette%.png" (
|
||||
ECHO [91mFailed to generate palette file[0m
|
||||
ECHO %RED%Failed to generate palette file%OFF%
|
||||
GOTO :cleanup
|
||||
)
|
||||
)
|
||||
@@ -239,12 +247,13 @@ IF NOT DEFINED bayerscale SET "bayer="
|
||||
IF DEFINED bayerscale SET bayer=:bayer_scale=%bayerscale%
|
||||
|
||||
:: Executing the encoding command
|
||||
ECHO [32mEncoding animation...[0m
|
||||
ECHO %GREEN%Encoding animation...%OFF%
|
||||
echo ffmpeg -v %loglevel% %trim% -i %vid% -thread_queue_size 512 -i "%frames%.png" -lavfi "%filters% [x]; [x][1:v] %decode%%errordiff%%ditherenc%%bayer%" -f %filetype% %webp_lossy% -loop 0 -plays 0 -y "%output%"
|
||||
ffmpeg -v %loglevel% %trim% -i %vid% -thread_queue_size 512 -i "%frames%.png" -lavfi "%filters% [x]; [x][1:v] %decode%%errordiff%%ditherenc%%bayer%" -f %filetype% %webp_lossy% -loop 0 -plays 0 -y "%output%"
|
||||
|
||||
:: Checking if file was created and cleaning up if not
|
||||
IF NOT EXIST "%output%" (
|
||||
ECHO [91mFailed to generate animation[0m
|
||||
ECHO %RED%Failed to generate animation%OFF%
|
||||
GOTO :cleanup
|
||||
)
|
||||
|
||||
@@ -253,74 +262,75 @@ IF DEFINED picswitch START "" "%output%"
|
||||
|
||||
:cleanup
|
||||
:: Cleaning up
|
||||
ECHO [32mDeleting temporary files...[0m
|
||||
ECHO %GREEN%Deleting temporary files...%OFF%
|
||||
RMDIR /S /Q "%WD%"
|
||||
ECHO %YELLOW%Done.%OFF%
|
||||
ENDLOCAL
|
||||
ECHO [93mDone![0m
|
||||
GOTO :EOF
|
||||
|
||||
:help_message
|
||||
:: Print usage message
|
||||
ECHO:
|
||||
ECHO [92mVideo to GIF/APNG/WEBP converter v6.0[0m
|
||||
ECHO [96mBy MDHEXT, Nabi KaramAliZadeh, Pathduck[0m
|
||||
ECHO %GREEN%Video to GIF/APNG/WEBP converter v6.0%OFF%
|
||||
ECHO %CYAN%By MDHEXT, Nabi KaramAliZadeh, Pathduck%OFF%
|
||||
ECHO:
|
||||
ECHO You can download this fork from here:[0m
|
||||
ECHO [96mhttps://github.com/Pathduck/vid2ani/[0m
|
||||
ECHO You can download this fork from here:
|
||||
ECHO %CYAN%https://github.com/Pathduck/vid2ani/%OFF%
|
||||
ECHO You can download the original release here:
|
||||
ECHO [96mhttps://github.com/NabiKAZ/video2gif[0m
|
||||
ECHO %CYAN%https://github.com/NabiKAZ/video2gif%OFF%
|
||||
ECHO This tool uses ffmpeg, you can download that here:
|
||||
ECHO [96mhttps://www.ffmpeg.org/download.html#build-windows[0m
|
||||
ECHO %CYAN%https://www.ffmpeg.org/download.html%OFF%
|
||||
ECHO This tool wouldn't be possible without the research listed here:
|
||||
ECHO [96mhttps://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html[0m
|
||||
ECHO %CYAN%https://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html%OFF%
|
||||
ECHO:
|
||||
ECHO [92mUsage:[0m
|
||||
ECHO %GREEN%Usage:%OFF%
|
||||
ECHO vid2ani [input_file] [Arguments]
|
||||
ECHO:
|
||||
ECHO [92mArguments:[0m
|
||||
ECHO %GREEN%Arguments:%OFF%
|
||||
ECHO:
|
||||
ECHO -t Output file type.
|
||||
ECHO [33mValid: 'gif' (default), 'png', 'webp'.[0m
|
||||
ECHO %YELLOW%Valid: 'gif' (default), 'png', 'webp'.%OFF%
|
||||
ECHO:
|
||||
ECHO -o Output file.
|
||||
ECHO [33mThe default is the same name as the input video.[0m
|
||||
ECHO %YELLOW%The default is the same name as the input video.%OFF%
|
||||
ECHO:
|
||||
ECHO -r Scale or size.
|
||||
ECHO [96mWidth of the animation in pixels.[0m
|
||||
ECHO [33mThe default is the same scale as the original video.[0m
|
||||
ECHO %CYAN%Width of the animation in pixels.%OFF%
|
||||
ECHO %YELLOW%The default is the same scale as the original video.%OFF%
|
||||
ECHO:
|
||||
ECHO -s Start time of the animation [96m(HH:MM:SS.MS)[0m
|
||||
ECHO -s Start time of the animation %CYAN%(HH:MM:SS.MS)%OFF%
|
||||
ECHO:
|
||||
ECHO -e End time of the animation [96m(HH:MM:SS.MS)[0m
|
||||
ECHO -e End time of the animation %CYAN%(HH:MM:SS.MS)%OFF%
|
||||
ECHO:
|
||||
ECHO -f Framerate in frames per second.
|
||||
ECHO [33mThe default is 15.[0m
|
||||
ECHO %YELLOW%The default is 15.%OFF%
|
||||
ECHO:
|
||||
ECHO -d Dithering algorithm to be used.
|
||||
ECHO [33mThe default is 0 (None).[0m
|
||||
ECHO %YELLOW%The default is 0 (None).%OFF%
|
||||
ECHO:
|
||||
ECHO -b Bayer Scale setting.
|
||||
ECHO [96mThis can only be used when Bayer dithering is applied.
|
||||
ECHO [33mRange 0 - 5, default is 2.[0m
|
||||
ECHO %CYAN%This can only be used when Bayer dithering is applied.
|
||||
ECHO %YELLOW%Range 0 - 5, default is 2.%OFF%
|
||||
ECHO:
|
||||
ECHO -m Palettegen mode - one of 3 modes listed below.
|
||||
ECHO [33mThe default is 1 (diff).[0m
|
||||
ECHO %YELLOW%The default is 1 (diff).%OFF%
|
||||
ECHO:
|
||||
ECHO -c The maximum amount of colors useable per palette.
|
||||
ECHO [33mRange 3 - 256 (default)[0m
|
||||
ECHO %YELLOW%Range 3 - 256 (default)%OFF%
|
||||
ECHO:
|
||||
ECHO -k Enables paletteuse error diffusion.
|
||||
ECHO:
|
||||
ECHO -l Enable lossy WebP compression and quality.
|
||||
ECHO [96mThe default for WebP is lossless.[0m
|
||||
ECHO [33mRange 0 - 100, default 75.[0m
|
||||
ECHO %CYAN%The default for WebP is lossless.%OFF%
|
||||
ECHO %YELLOW%Range 0 - 100, default 75.%OFF%
|
||||
ECHO:
|
||||
ECHO -v Set FFmpeg log level, for troubleshooting.
|
||||
ECHO [33mThe default log level is 'error'[0m
|
||||
ECHO %YELLOW%The default log level is 'error'%OFF%
|
||||
ECHO:
|
||||
ECHO -p Opens the resulting animation in your default Photo Viewer.
|
||||
ECHO:
|
||||
ECHO [92mDithering Modes:[0m
|
||||
|
||||
ECHO %GREEN%Dithering Mode%OFF%
|
||||
ECHO 0: None
|
||||
ECHO 1: Bayer
|
||||
ECHO 2: Heckbert
|
||||
@@ -331,18 +341,18 @@ ECHO 6: Sierra3
|
||||
ECHO 7: Burkes
|
||||
ECHO 8: Atkinson
|
||||
ECHO:
|
||||
ECHO [92mPalettegen Modes:[0m
|
||||
ECHO %GREEN%Palettegen Modes%OFF%
|
||||
ECHO 1: diff - only what moves affects the palette
|
||||
ECHO 2: single - one palette per frame
|
||||
ECHO 3: full - one palette for the whole animation
|
||||
ECHO:
|
||||
ECHO [92mAbout Bayerscale:[0m
|
||||
ECHO %GREEN%About Bayerscale%OFF%
|
||||
ECHO When bayer dithering is selected, the Bayer Scale option defines the
|
||||
ECHO scale of the pattern (how much the crosshatch pattern is visible).
|
||||
ECHO A low value means more visible pattern for less banding, a higher value
|
||||
ECHO means less visible pattern at the cost of more banding.
|
||||
ECHO:
|
||||
ECHO [92mPeople who made this project come to fruition:[0m
|
||||
ECHO %GREEN%People who made this project come to fruition%OFF%
|
||||
ECHO ubitux, Nabi KaramAliZadeh, and the very kind and patient people in the
|
||||
ECHO Batch Discord Server. Without these people's contributions, this script
|
||||
ECHO would not be possible. Thank you all for your contributions and
|
||||
|
||||
Reference in New Issue
Block a user