1
1
@ ECHO OFF
2
- REM SendTo_FFmpeg is a set of windows batches for effortless and free transcoding
3
- REM Copyright (c) 2018-2021 Keerah, keerah.com. All rights reserved
4
- REM More information at https://keerah.com https://github.com/keerah/SendTo_FFmpeg
2
+ REM SendTo_FFmpeg is a set of windows batches for effortless transcoding
3
+ REM Download from https://github.com/keerah/SendTo_FFmpeg
5
4
6
5
setlocal enabledelayedexpansion
7
6
8
- set argCount = 0
9
- for %%x in (%* ) do (
10
- set /A argCount += 1
11
- set " argVec[!argCount!] = %%~x "
12
- set " argVn[!argCount!] = %%~nx "
7
+ SET argCount = 0
8
+ FOR %%f IN (%* ) DO (
9
+ SET /A argCount += 1
10
+ SET " argFile[!argCount!].name = %%~f "
11
+ SET " argFile[!argCount!].trname = %%~nf "
12
+ SET " argFile[!argCount!].ext = %%~xf "
13
+ SET " argFile[!argCount!].path = %%~dpf "
13
14
)
14
15
15
- ECHO [---------------------------------------------------------------------------------]
16
- ECHO [--- SendTo FFmpeg encoder v2.2 by Keerah.com ---]
17
- ECHO [--- Multi APNG module has been invoked ---]
18
- ECHO [--- Preset: plain, loop forever ---]
16
+ IF %argCount% LEQ 0 (
17
+ ECHO [-----------------------------------------------------------------------------------]
18
+ ECHO [ NO FILE^ (S^ ) SPECIFIED ]
19
+ GOTO :End
20
+ )
21
+
22
+ ECHO [-----------------------------------------------------------------------------------]
23
+ ECHO [--- SendTo FFmpeg encoder v3.0 by Keerah ---]
24
+ ECHO [--- Preset: APNG plain, loop forever ---]
19
25
20
- set " cmdp = %~dp0 "
21
- set " argp = %~dp1 "
26
+ SET " cmdp = %~dp0 "
27
+ SET " argp = %~dp1 "
22
28
29
+ REM get settings
23
30
IF EXIST " %argp% sendtoffmpeg_settings.cmd" (
24
31
CALL " %argp% sendtoffmpeg_settings.cmd"
25
- ECHO [--- Settings: LOCAL ---]
32
+ ECHO [--- Settings: * LOCAL*, Verbosity: !vbl!
26
33
) ELSE (
27
- CALL " %cmdp% sendtoffmpeg_settings.cmd"
28
- ECHO [--- Settings: GLOBAL ---]
34
+ IF EXIST " %cmdp% sendtoffmpeg_settings.cmd" (
35
+ CALL " %cmdp% sendtoffmpeg_settings.cmd"
36
+ ECHO [--- Settings: Global, Verbosity: !vbl!
37
+ ) ELSE (
38
+ ECHO [--- Sorry, the sendtoffmpeg_settings.cmd is unreacheable. Unable to continue! ---]
39
+ GOTO :End
40
+ )
29
41
)
30
42
31
- IF %argCount% == 0 (
32
-
33
- ECHO [---------------------------------------------------------------------------------]
34
- ECHO [ NO FILE SPECIFIED ]
35
- GOTO End
43
+ REM Check for ffmpeg
44
+ IF NOT EXIST " %ffpath% ffmpeg.exe" (
45
+ ECHO [--- Sorry, the path to ffmpeg.exe is unreacheable. Unable to continue! ---]
46
+ GOTO :End
36
47
)
37
-
38
- IF %argCount% GTR 1 (
39
48
40
- ECHO [---------------------------------------------------------------------------------]
41
- ECHO [ %argCount% files queued to encode
42
- )
43
49
44
- IF %dscr% GTR 0 (SET " dscrName=_animpng" ) ELSE (SET " dscrName=" )
50
+ REM compression settings
51
+ SET " wset.params = -v %vbl% -hide_banner -stats"
52
+ SET " wset.videocomp = -f apng -plays 0"
53
+ SET " wset.audiocomp = "
54
+ IF %quietover% == 1 (SET " wset.over=-y" ) ELSE (SET " wset.over=" )
55
+ IF %dscr% GTR 0 (SET " wset.dscr=_animpng" ) ELSE (SET " wset.dscr=" )
56
+ SET " wset.suff = !wset.dscr! .png"
57
+
58
+ ECHO [-----------------------------------------------------------------------------------]
59
+ ECHO [ %argCount% files queued to encode
45
60
46
61
FOR /L %%i IN (1,1,%argCount% ) DO (
47
62
48
- ECHO [---------------------------------------------------------------------------------]
49
- ECHO [ Transcoding %%i of %argCount% : !argVn[%%i ]!
63
+ ECHO [-----------------------------------------------------------------------------------]
50
64
51
- for /F " delims=" %%f in ('call " %ffpath% ffprobe.exe" -v error -show_entries " format=duration" -of " default=noprint_wrappers=1:nokey=1" " !argVec [%%i ]! " ') do echo [ Video length is: %%f
65
+ FOR /F " tokens=* delims=" %%f IN ('call " %ffpath% ffprobe.exe" -v error -show_entries " format=duration" -of " default=noprint_wrappers=1:nokey=1" " !argFile [%%i ].name ! " ') DO SET " vlen = %%f "
52
66
53
- " %ffpath% ffmpeg.exe" -v %vbl% -hide_banner -stats -i " !argVec[%%i ]! " -f apng -plays 0 -y " !argVn[%%i ]!%dscrName% .png"
54
- )
67
+ IF !vlen! NEQ " N/A" (
68
+ ECHO [ The source is a single image file with no length
69
+
70
+ IF !imgseq! GTR 0 (
71
+ REM detecting image sequence
72
+ IF !frcounter! GTR 0 (
73
+ REM detecting the counter in the end of the filename
74
+ SET " basename = !argFile[%%i ].trname:~0 ,-%frcounter%! "
75
+ SET " countername = !argFile[%%i ].trname:~-%frcounter%! "
76
+ FOR /F " tokens=* delims=0" %%N IN (" !countername! " ) DO SET /A frnumber = %%N
77
+ IF !frnumber! GTR 0 (
78
+ SET " argFile[%%i].name = !argFile[%%i ].path!!basename! %% 0!frcounter! d!argFile[%%i ].ext! "
79
+ ECHO [ Image sequence detected ]
80
+ ECHO [ Basename: " !basename! " Start frame: !frnumber! Pattern: " !basename! %% 0!frcounter! d"
81
+ SET " seqfr = -framerate %fps% -start_number !frnumber! -pattern_type sequence"
82
+ SET " seqfrout = -r %fps% "
83
+ ) ELSE (
84
+ SET " seqfr = "
85
+ SET " seqfrout = "
86
+ )
87
+ ) ELSE (
88
+ REM detecting the counter after first found dot
89
+ REM No implementation yet
90
+ )
91
+ ) ELSE (
92
+ SET " seqfr = "
93
+ SET " seqfrout = "
94
+ )
95
+ ) ELSE (
96
+ echo [ Video length is: !vlen! seconds
97
+ )
55
98
56
- :End
57
- ECHO [---------------------------------------------------------------------------------]
58
- ECHO [ SERVED ]
59
- ECHO [---------------------------------------------------------------------------------]
99
+ ECHO [ Transcoding %%i of %argCount% : !argFile[%%i ].trname!
100
+ " %ffpath% ffmpeg.exe" !wset.params! !seqfr! -i " !argFile[%%i ].name! " !wset.videocomp! !wset.audiocomp! !seqfrout! !wset.over! " !argFile[%%i ].trname! " !wset.suff!
101
+ )
60
102
61
- if %pse% GTR 0 PAUSE
103
+ ECHO [-----------------------------------------------------------------------------------]
104
+ ECHO [ SERVED ]
105
+ ECHO [-----------------------------------------------------------------------------------]
62
106
63
- rem the main settings are defined in file sendtoffmpeg_settings.cmd, read the description inside it
107
+ :End
108
+ if %pse% GTR 0 PAUSE
0 commit comments