Skip to content

Commit 45ba858

Browse files
authored
fix spaces
add support for files with spaces in path.
1 parent 0616772 commit 45ba858

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

gifconv.bat

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ REM Url: https://github.com/MDHEXT/video2gif, forked from https://github.com/Nab
66
REM License: The MIT License (MIT)
77

88
SETLOCAL ENABLEDELAYEDEXPANSION
9-
SET input=%~1
10-
SET vid=%~dpnx1
11-
SET output=%~dpn1.gif
12-
SET FILEPATH=%~dp1
9+
SET input="%~1"
10+
SET vid="%~dpnx1"
11+
SET output="%~dpn1.gif"
12+
SET FILEPATH="%~dp1"
1313

1414
SET "scale="
1515
SET "fps="
@@ -95,15 +95,14 @@ IF NOT "%~1" =="" (
9595
IF "%~1" =="-s" SET "start_time=%~2" & SHIFT
9696
IF "%~1" =="-e" SET "duration=%~2" & SHIFT
9797
IF "%~1" =="-c" SET "colormax=%~2" & SHIFT
98-
SHIFT
99-
GOTO :varin
98+
SHIFT & GOTO :varin
10099
)
101100
GOTO :help_check_2
102101

103102
:help_check_1
104-
IF "%input%" == "" GOTO :help_message
105-
IF "%input%" == "help" GOTO :help_message
106-
IF "%input%" == "h" GOTO :help_message
103+
IF %input% == "" GOTO :help_message
104+
IF %input% == "help" GOTO :help_message
105+
IF %input% == "h" GOTO :help_message
107106
GOTO :varin
108107

109108
:help_check_2
@@ -133,7 +132,7 @@ IF %mode% EQU 1 SET encode=palettegen=stats_mode=diff
133132
IF %mode% EQU 2 SET encode=palettegen=stats_mode=single & SET frames=%palette%_%%05d
134133
IF %mode% EQU 3 SET encode=palettegen
135134
IF DEFINED colormax SET "mcol=:max_colors=%colormax%"
136-
ffmpeg -v warning %trim% -i "%vid%" -vf "%filters%,%encode%%mcol%" -y "%frames%.png"
135+
ffmpeg -v warning %trim% -i %vid% -vf "%filters%,%encode%%mcol%" -y "%frames%.png"
137136
IF NOT EXIST "%palette%_00001.png" (
138137
IF NOT EXIST "%palette%.png" (
139138
ECHO Failed to generate palette file
@@ -142,7 +141,7 @@ IF NOT EXIST "%palette%_00001.png" (
142141
)
143142
ECHO Encoding Gif file...
144143
IF %mode% EQU 1 SET decode=paletteuse=diff_mode=rectangle
145-
IF %mode% EQU 2 SET decode=paletteuse=new=1 & SET frames=%palette%_%%05d
144+
IF %mode% EQU 2 SET decode=paletteuse=new=1:diff_mode=rectangle & SET frames=%palette%_%%05d
146145
IF %mode% EQU 3 SET decode=paletteuse=diff_mode=rectangle
147146
IF %dither% EQU 1 SET ditherenc=:dither=bayer
148147
IF %dither% EQU 2 SET ditherenc=:dither=heckbert
@@ -153,8 +152,8 @@ IF %dither% EQU 6 SET "ditherenc="
153152
IF NOT DEFINED bayerscale SET "bayer="
154153
IF DEFINED bayerscale SET bayer=:bayer_scale=%bayerscale%
155154

156-
ffmpeg -v warning %trim% -i "%vid%" -thread_queue_size 512 -i "%frames%.png" -lavfi "%filters% [x]; [x][1:v] %decode%%ditherenc%%bayer%" -y "%output%"
157-
IF NOT EXIST "%output%" (
155+
ffmpeg -v warning %trim% -i %vid% -thread_queue_size 512 -i "%frames%.png" -lavfi "%filters% [x]; [x][1:v] %decode%%ditherenc%%bayer%" -y %output%
156+
IF NOT EXIST %output% (
158157
ECHO Failed to generate gif file
159158
GOTO :cleanup
160159
)

0 commit comments

Comments
 (0)