Update sync to GH
This commit is contained in:
50
README.md
50
README.md
@@ -21,43 +21,35 @@ vid2ani [input_file] [arguments]
|
||||
```
|
||||
## Arguments
|
||||
```
|
||||
-t Output filetype: gif, png, webp.
|
||||
The default is gif.
|
||||
-t Output file type.
|
||||
Valid: 'gif' (default), 'png', 'webp'.
|
||||
-o Output file.
|
||||
The default is the same name as the input video.
|
||||
-r Scale or size.
|
||||
Width of the animation in pixels.
|
||||
The default is the same scale as the original video.
|
||||
-s Start time of the animation (HH:MM:SS.MS)
|
||||
-e End time of the animation (HH:MM:SS.MS)
|
||||
-f Framerate in frames per second.
|
||||
The default is 15.
|
||||
-m Palettegen mode - one of 3 modes listed below.
|
||||
The default is 1 (diff).
|
||||
-d Dithering algorithm to be used.
|
||||
The default is 0 (None).
|
||||
-b Bayer Scale setting. (Optional)
|
||||
-b Bayer Scale setting.
|
||||
This can only be used when Bayer dithering is applied.
|
||||
See more information below.
|
||||
-l Set lossy WebP compression and quality
|
||||
Value 0-100, default 75.
|
||||
(Default for WebP is lossless)
|
||||
Range 0 - 5, default is 2.
|
||||
-m Palettegen mode - one of 3 modes listed below.
|
||||
The default is 1 (diff).
|
||||
-c The maximum amount of colors useable per palette.
|
||||
(Optional value up to 256)
|
||||
This option isn't used by default.
|
||||
-s Start of the animation in HH:MM:SS.MS format.
|
||||
(Optional)
|
||||
-e Duration of the animation in seconds.
|
||||
(Optional)
|
||||
-k Enables error diffusion.
|
||||
(Optional)
|
||||
Range 3 - 256 (default)
|
||||
-k Enables paletteuse error diffusion.
|
||||
-l Enable lossy WebP compression and quality.
|
||||
The default for WebP is lossless.
|
||||
Range 0 - 100, default 75.
|
||||
-v Set FFmpeg log level, for troubleshooting.
|
||||
The default log level is 'error'
|
||||
-p Opens the resulting animation in your default Photo Viewer.
|
||||
(Optional)
|
||||
|
||||
Palettegen Modes:
|
||||
1: diff - only what moves affects the palette
|
||||
2: single - one palette per frame
|
||||
3: full - one palette for the whole animation
|
||||
|
||||
Dithering Options:
|
||||
Dithering Modes:
|
||||
0: None
|
||||
1: Bayer
|
||||
2: Heckbert
|
||||
@@ -68,21 +60,25 @@ Dithering Options:
|
||||
7: burkes
|
||||
8: atkinson
|
||||
|
||||
Palettegen Modes:
|
||||
1: diff - only what moves affects the palette
|
||||
2: single - one palette per frame
|
||||
3: full - one palette for the whole animation
|
||||
|
||||
About Bayerscale:
|
||||
When bayer dithering is selected, the Bayer Scale option defines the
|
||||
scale of the pattern (how much the crosshatch pattern is visible).
|
||||
A low value means more visible pattern for less banding, a higher value
|
||||
means less visible pattern at the cost of more banding.
|
||||
The option must be an integer value in the range [0,5].
|
||||
The Default is 2. Bayer Scale is optional.
|
||||
```
|
||||
|
||||
## Examples
|
||||
```
|
||||
vid2ani sample.mp4
|
||||
vid2ani sample.mp4 -t png
|
||||
vid2ani sample.mp4 -t webp -l 50
|
||||
vid2ani sample.mp4 -f 20 -r 450
|
||||
vid2ani sample.mp4 -s 5:40 -e 5
|
||||
vid2ani sample.mp4 -s 5:40 -e 5:45
|
||||
vid2ani sample.mp4 -o babydance -m 2 -k -b 3
|
||||
```
|
||||
|
||||
|
||||
225
vid2ani.cmd
225
vid2ani.cmd
@@ -15,6 +15,9 @@ SET vid="%~dpnx1"
|
||||
SET output=%~dpn1
|
||||
SET FILEPATH=%~dp1
|
||||
|
||||
:: Setting the path to the Working Directory
|
||||
SET WD=%TEMP%\VID2ANI
|
||||
|
||||
:: Clearing all variables
|
||||
SET "filetype="
|
||||
SET "scale="
|
||||
@@ -28,113 +31,18 @@ SET "webp_lossy="
|
||||
SET "colormax="
|
||||
SET "version="
|
||||
SET "build="
|
||||
SET "loglevel="
|
||||
|
||||
:: Setting the path to the Working Directory
|
||||
SET WD=%TEMP%\VID2ANI
|
||||
|
||||
:: Palette filename
|
||||
SET palette=%WD%\palette
|
||||
|
||||
:: Storing FFmpeg version string
|
||||
FOR /F "delims=" %%a in ('ffmpeg -version') DO (
|
||||
IF NOT DEFINED version (
|
||||
SET "version=%%a"
|
||||
) ELSE IF NOT DEFINED build (
|
||||
SET "build=%%a"
|
||||
)
|
||||
)
|
||||
GOTO :help_check_1
|
||||
|
||||
:help_message
|
||||
:: Print usage message
|
||||
ECHO:
|
||||
ECHO [32mVideo to GIF/APNG/WEBP converter v5.5[0m
|
||||
ECHO [96m^(C^) 2017-2022, MDHEXT ^&^ Nabi KaramAliZadeh ^<nabikaz@gmail.com^>[0m
|
||||
ECHO:
|
||||
ECHO You can download this fork from here:[0m
|
||||
ECHO [96mhttps://github.com/MDHEXT/video2gif[0m
|
||||
ECHO You can download the original release here:
|
||||
ECHO [96mhttps://github.com/NabiKAZ/video2gif[0m
|
||||
ECHO This tool uses ffmpeg, you can download that here:
|
||||
ECHO [96mhttps://www.ffmpeg.org/download.html#build-windows[0m
|
||||
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:
|
||||
ECHO [32mUsage:[0m
|
||||
ECHO vid2ani [input_file] [Arguments]
|
||||
ECHO:
|
||||
ECHO [32mArguments:[0m
|
||||
ECHO -t Output filetype: gif, png, webp.
|
||||
ECHO [33mThe default is gif.[0m
|
||||
ECHO -o Output file.
|
||||
ECHO [33mThe default is the same name as the input video.[0m
|
||||
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 -f Framerate in frames per second.
|
||||
ECHO [33mThe default is 15.[0m
|
||||
ECHO -m Palettegen mode - one of 3 modes listed below.
|
||||
ECHO [33mThe default is 1 (diff).[0m
|
||||
ECHO -d Dithering algorithm to be used.
|
||||
ECHO [33mThe default is 0 (None).[0m
|
||||
ECHO -b Bayer Scale setting. [96m(Optional)[0m
|
||||
ECHO [96mThis can only be used when Bayer dithering is applied.
|
||||
ECHO See more information below.[0m
|
||||
ECHO -l Set lossy WebP compression and quality
|
||||
ECHO [33mValue 0-100, default 75.[0m
|
||||
ECHO [96m(Default for WebP is lossless)[0m
|
||||
ECHO -c The maximum amount of colors useable per palette.
|
||||
ECHO [96m(Optional value up to 256)[0m
|
||||
ECHO [33mThis option isn't used by default.[0m
|
||||
ECHO -s Start time of the animation (HH:MM:SS.MS)
|
||||
ECHO [96m(Optional)[0m
|
||||
ECHO -e End time of the animation (HH:MM:SS.MS)
|
||||
ECHO [96m(Optional)[0m
|
||||
ECHO -k Enables error diffusion.
|
||||
ECHO [96m(Optional)[0m
|
||||
ECHO -p Opens the resulting animation in your default Photo Viewer.
|
||||
ECHO [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 animation
|
||||
ECHO:
|
||||
ECHO [32mDithering Options:[0m
|
||||
ECHO 0: None
|
||||
ECHO 1: Bayer
|
||||
ECHO 2: Heckbert
|
||||
ECHO 3: Floyd Steinberg
|
||||
ECHO 4: Sierra2
|
||||
ECHO 5: Sierra2_4a
|
||||
ECHO 6: sierra3
|
||||
ECHO 7: burkes
|
||||
ECHO 8: atkinson
|
||||
ECHO:
|
||||
ECHO [32mAbout Bayerscale:[0m
|
||||
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 [96mThe option must be an integer value in the range [0,5].[0m
|
||||
ECHO [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
|
||||
ECHO Batch Discord Server. Without these people's contributions, this script
|
||||
ECHO would not be possible. Thank you all for your contributions and
|
||||
ECHO assistance^^!
|
||||
GOTO :EOF
|
||||
|
||||
:help_check_1
|
||||
:: Checking for blank input or help commands
|
||||
IF %input% == "" GOTO :help_message
|
||||
IF %input% == "help" GOTO :help_message
|
||||
IF %input% == "-?" GOTO :help_message
|
||||
IF %input% == "--help" GOTO :help_message
|
||||
GOTO :varin
|
||||
|
||||
:varin
|
||||
:: Checking for blank input or help commands
|
||||
IF %input% == "" GOTO :help_message
|
||||
IF %input% == "-?" GOTO :help_message
|
||||
IF %input% == "/?" GOTO :help_message
|
||||
IF %input% == "help" GOTO :help_message
|
||||
IF %input% == "--help" GOTO :help_message
|
||||
|
||||
:: Using SHIFT command to go through the input and storing each setting into its own variable
|
||||
IF NOT "%~1" =="" (
|
||||
IF "%~1" =="-r" SET "scale=%~2" & SHIFT
|
||||
@@ -148,6 +56,7 @@ IF NOT "%~1" =="" (
|
||||
IF "%~1" =="-e" SET "end_time=%~2" & SHIFT
|
||||
IF "%~1" =="-c" SET "colormax=%~2" & SHIFT
|
||||
IF "%~1" =="-l" SET "webp_lossy=%~2" & SHIFT
|
||||
IF "%~1" =="-v" SET "loglevel=%~2" & SHIFT
|
||||
IF "%~1" =="-k" SET "errorswitch=0"
|
||||
IF "%~1" =="-p" SET "picswitch=0"
|
||||
SHIFT & GOTO :varin
|
||||
@@ -158,6 +67,7 @@ GOTO :help_check_2
|
||||
:: Noob proofing the script to prevent it from breaking should critical settings not be defined
|
||||
IF NOT DEFINED filetype SET "filetype=gif"
|
||||
IF NOT DEFINED scale SET "scale=-1"
|
||||
IF NOT DEFINED loglevel SET "loglevel=error"
|
||||
IF NOT DEFINED fps SET fps=15
|
||||
IF NOT DEFINED mode SET mode=1
|
||||
IF NOT DEFINED dither SET dither=0
|
||||
@@ -169,7 +79,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 [91mNot a valid file type[0m
|
||||
GOTO :EOF
|
||||
)
|
||||
IF "%filetype%"=="png" SET filetype=apng
|
||||
@@ -243,15 +153,25 @@ IF NOT DEFINED start_time (
|
||||
GOTO :script_start
|
||||
|
||||
:script_start
|
||||
:: Storing FFmpeg version string
|
||||
FOR /F "delims=" %%a in ('ffmpeg -version') DO (
|
||||
IF NOT DEFINED version (
|
||||
SET "version=%%a"
|
||||
) ELSE IF NOT DEFINED build (
|
||||
SET "build=%%a"
|
||||
)
|
||||
)
|
||||
|
||||
:: Displaying FFmpeg version string and creating the working directory
|
||||
ECHO [33m%version%[0m
|
||||
ECHO [33m%build%[0m
|
||||
ECHO [32mOutput file: %output%[0m
|
||||
ECHO [92mOutput file: %output%[0m
|
||||
ECHO [32mCreating working directory...[0m
|
||||
MD "%WD%"
|
||||
|
||||
:palettegen
|
||||
:: Putting together command to generate palette
|
||||
SET palette=%WD%\palette
|
||||
SET frames=%palette%_%%05d
|
||||
SET filters=fps=%fps%,scale=%scale%:-1:flags=lanczos
|
||||
|
||||
@@ -268,7 +188,7 @@ IF DEFINED colormax (
|
||||
|
||||
:: Executing command to generate palette
|
||||
ECHO [32mGenerating palette...[0m
|
||||
ffmpeg -v warning %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" (
|
||||
@@ -320,7 +240,7 @@ IF DEFINED bayerscale SET bayer=:bayer_scale=%bayerscale%
|
||||
|
||||
:: Executing the encoding command
|
||||
ECHO [32mEncoding animation...[0m
|
||||
ffmpeg -v warning %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%" (
|
||||
@@ -337,3 +257,94 @@ ECHO [32mDeleting temporary files...[0m
|
||||
RMDIR /S /Q "%WD%"
|
||||
ENDLOCAL
|
||||
ECHO [93mDone![0m
|
||||
GOTO :EOF
|
||||
|
||||
:help_message
|
||||
:: Print usage message
|
||||
ECHO:
|
||||
ECHO [92mVideo to GIF/APNG/WEBP converter v5.5[0m
|
||||
ECHO [96m^(C^) 2017-2022, MDHEXT ^&^ Nabi KaramAliZadeh ^<nabikaz@gmail.com^>[0m
|
||||
ECHO:
|
||||
ECHO You can download this fork from here:[0m
|
||||
ECHO [96mhttps://github.com/MDHEXT/video2gif[0m
|
||||
ECHO You can download the original release here:
|
||||
ECHO [96mhttps://github.com/NabiKAZ/video2gif[0m
|
||||
ECHO This tool uses ffmpeg, you can download that here:
|
||||
ECHO [96mhttps://www.ffmpeg.org/download.html#build-windows[0m
|
||||
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:
|
||||
ECHO [92mUsage:[0m
|
||||
ECHO vid2ani [input_file] [Arguments]
|
||||
ECHO:
|
||||
ECHO [92mArguments:[0m
|
||||
ECHO:
|
||||
ECHO -t Output file type.
|
||||
ECHO [33mValid: 'gif' (default), 'png', 'webp'.[0m
|
||||
ECHO:
|
||||
ECHO -o Output file.
|
||||
ECHO [33mThe default is the same name as the input video.[0m
|
||||
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:
|
||||
ECHO -s Start time of the animation [96m(HH:MM:SS.MS)[0m
|
||||
ECHO:
|
||||
ECHO -e End time of the animation [96m(HH:MM:SS.MS)[0m
|
||||
ECHO:
|
||||
ECHO -f Framerate in frames per second.
|
||||
ECHO [33mThe default is 15.[0m
|
||||
ECHO:
|
||||
ECHO -d Dithering algorithm to be used.
|
||||
ECHO [33mThe default is 0 (None).[0m
|
||||
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:
|
||||
ECHO -m Palettegen mode - one of 3 modes listed below.
|
||||
ECHO [33mThe default is 1 (diff).[0m
|
||||
ECHO:
|
||||
ECHO -c The maximum amount of colors useable per palette.
|
||||
ECHO [33mRange 3 - 256 (default)[0m
|
||||
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:
|
||||
ECHO -v Set FFmpeg log level, for troubleshooting.
|
||||
ECHO [33mThe default log level is 'error'[0m
|
||||
ECHO:
|
||||
ECHO -p Opens the resulting animation in your default Photo Viewer.
|
||||
ECHO:
|
||||
ECHO [92mDithering Modes:[0m
|
||||
ECHO 0: None
|
||||
ECHO 1: Bayer
|
||||
ECHO 2: Heckbert
|
||||
ECHO 3: Floyd Steinberg
|
||||
ECHO 4: Sierra2
|
||||
ECHO 5: Sierra2_4a
|
||||
ECHO 6: sierra3
|
||||
ECHO 7: burkes
|
||||
ECHO 8: atkinson
|
||||
ECHO:
|
||||
ECHO [92mPalettegen 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 animation
|
||||
ECHO:
|
||||
ECHO [92mAbout Bayerscale:[0m
|
||||
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 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
|
||||
ECHO assistance^^!
|
||||
GOTO :EOF
|
||||
|
||||
Reference in New Issue
Block a user