This commit is contained in:
Stian Lund
2024-10-19 00:17:35 +02:00
parent 6490f1d545
commit 902afbcfc0
2 changed files with 61 additions and 47 deletions
+5
View File
@@ -71,6 +71,11 @@ s::Send("{Down}")
d::Send("{Right}")
#HotIf ; End
; Handle RMB click if menu already showing
#HotIf WinExist("ahk_class #32768")
RButton::Send("{F13 Down}{Click,right}{F13 Up}")
#HotIf ; End
; Unit Dashboard
;#HotIf WinActive("ahk_class TfUnitDashboardNew")
;q::Send("{F4}") ; Q - Close Unit Dashboard
+56 -47
View File
@@ -23,15 +23,19 @@ SET "mode="
SET "dither="
SET "bayerscale="
SET "start_time="
SET "end_time="
SET "webp_lossy="
SET "duration="
SET "colormax="
SET "version="
SET "build="
:: Setting the path to the Working Directory and storing FFmpeg Version String
:: Setting the path to the Working Directory
SET WD=%TEMP%\VID2ANI
SET palette=%WD%\template
:: 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"
@@ -82,9 +86,9 @@ ECHO (Default for WebP is lossless)
ECHO -c The maximum amount of colors useable per palette.
ECHO (Optional value up to 256)
ECHO This option isn't used by default.
ECHO -s Start of the animation (HH:MM:SS.MS)
ECHO -s Start time of the animation (HH:MM:SS.MS)
ECHO (Optional)
ECHO -e Duration of the animation (HH:MM:SS.MS)
ECHO -e End time of the animation (HH:MM:SS.MS)
ECHO (Optional)
ECHO -k Enables error diffusion.
ECHO (Optional)
@@ -141,7 +145,7 @@ IF NOT "%~1" =="" (
IF "%~1" =="-t" SET "filetype=%~2" & SHIFT
IF "%~1" =="-o" SET "output=%~dpnx2" & SHIFT
IF "%~1" =="-s" SET "start_time=%~2" & SHIFT
IF "%~1" =="-e" SET "duration=%~2" & SHIFT
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" =="-k" SET "errorswitch=0"
@@ -161,20 +165,27 @@ GOTO :safchek
:safchek
:: Setting a clear range of acceptable setting values and noob proofing bayerscale
:: Output file type
echo %filetype% | findstr /r "\<gif\> \<png\> \<apng\> \<webp\>" >nul
IF %errorlevel% NEQ 0 (
ECHO Not a valid file type
GOTO :EOF
)
IF "%filetype%"=="png" SET filetype=apng
IF "%filetype%"=="apng" SET output=%output%.png
IF "%filetype%"=="webp" SET output=%output%.webp
IF "%filetype%"=="gif" SET output=%output%.gif
:: Palettegen
IF %mode% GTR 3 (
ECHO Not a valid mode
ECHO Not a valid palettegen mode
GOTO :EOF
) ELSE IF %mode% LSS 1 (
ECHO Not a valid mode
ECHO Not a valid palettegen mode
GOTO :EOF
)
:: Dithering
IF %dither% GTR 8 (
ECHO Not a valid dither algorithm
GOTO :EOF
@@ -183,6 +194,24 @@ IF %dither% GTR 8 (
GOTO :EOF
)
:: Bayerscale
IF DEFINED bayerscale (
IF !bayerscale! GTR 5 (
ECHO Not a valid bayerscale value
GOTO :EOF
) ELSE IF !bayerscale! LSS 0 (
ECHO Not a valid bayerscale value
GOTO :EOF
)
IF !bayerscale! LEQ 5 (
IF %dither% NEQ 1 (
ECHO This setting only works with bayer dithering
GOTO :EOF
)
)
)
:: Lossy WEBP
IF DEFINED webp_lossy (
IF NOT "%filetype%" == "webp" (
ECHO Lossy is only valid for filetype webp
@@ -196,32 +225,25 @@ IF DEFINED webp_lossy (
)
)
IF DEFINED bayerscale (
IF !bayerscale! GTR 5 (
ECHO Not a valid bayerscale value
GOTO :EOF
) ELSE IF !bayerscale! LSS 0 (
ECHO Not a valid bayerscale value
:: Noob Proofing clipping
IF DEFINED start_time (
IF DEFINED end_time SET "trim=-ss !start_time! -to !end_time!"
IF NOT DEFINED end_time (
ECHO Please input the end time
GOTO :EOF
)
IF !bayerscale! LEQ 5 (
IF %dither% EQU 1 GOTO :script_start
IF %dither% NEQ 1 (
ECHO This setting only works with bayer dithering
GOTO :EOF
)
)
IF NOT DEFINED start_time (
IF DEFINED end_time (
ECHO Please input the start time
GOTO :EOF
)
)
GOTO :script_start
:script_start
:: Set output file name
IF "%filetype%"=="png" SET filetype=apng
IF "%filetype%"=="apng" SET output=%output%.png
IF "%filetype%"=="webp" SET output=%output%.webp
IF "%filetype%"=="gif" SET output=%output%.gif
:: Displaying FFmpeg Version String and Creating the Working Directory
:: Displaying FFmpeg version string and creating the working directory
ECHO %version%
ECHO %build%
ECHO Output file: %output%
@@ -229,30 +251,16 @@ ECHO Creating Working Directory...
MD "%WD%"
:palettegen
:: Noob Proofing clipping
IF DEFINED start_time (
IF DEFINED duration SET "trim=-ss !start_time! -t !duration!"
IF NOT DEFINED duration (
ECHO Please input a duration
GOTO :cleanup
)
)
IF NOT DEFINED start_time (
IF DEFINED duration (
ECHO Please input a start time
GOTO :cleanup
)
)
:: Putting together command to generate palette
SET frames=%palette%_%%05d
SET filters=fps=%fps%,scale=%scale%:-1:flags=lanczos
:: Palettegen mode
IF %mode% EQU 1 SET encode=palettegen=stats_mode=diff
IF %mode% EQU 2 SET encode="palettegen=stats_mode=single"
IF %mode% EQU 3 SET encode=palettegen
:: Max colors
IF DEFINED colormax (
IF %mode% LEQ 2 SET "mcol=:max_colors=%colormax%"
IF %mode% EQU 3 SET "mcol==max_colors=%colormax%"
@@ -270,26 +278,27 @@ IF NOT EXIST "%palette%_00001.png" (
)
)
:: Setting variables to put the command together
:: Setting variables to put the encode command together
:: Checking for Error Diffusion if using Bayer Scale and adjusting the command accordingly
IF %mode% EQU 1 SET decode=paletteuse
IF %mode% EQU 2 SET "decode=paletteuse=new=1"
IF %mode% EQU 3 SET decode=paletteuse
:: Error diffusion
IF DEFINED errorswitch (
IF %mode% EQU 1 SET "errordiff==diff_mode=rectangle"
IF %mode% EQU 2 SET "errordiff=:diff_mode=rectangle"
IF %mode% EQU 3 SET "errordiff==diff_mode=rectangle"
)
:: Setting WEBP lossy arguments
:: WEBP pixel format and lossy quality
IF "%filetype%" == "webp" (
IF DEFINED webp_lossy (
SET "webp_lossy=-lossless 0 -pix_fmt yuv420p -quality %webp_lossy%"
) ELSE SET "webp_lossy=-lossless 1"
)
:: Setting dither algorithm
:: Dither algorithm
IF %dither% EQU 0 SET ditheralg=none
IF %dither% EQU 1 SET ditheralg=bayer
IF %dither% EQU 2 SET ditheralg=heckbert