- SET FSO = CREATEOBJECT("SCRIPTING.FILESYSTEMOBJECT")
- SET WSH329 = CREATEOBJECT("WSCRIPT.SHELL")
-
-
- FUNCTION NUMSTR(X) ' X > 0
- IF X < 1 THEN
- NUMSTR = 0 & X
- ELSE
- NUMSTR = X
- END IF
- END FUNCTION
-
-
- SUB TAKE(FN, T, CNT, Y, JPGFN, TMPNAM62)
- ' ffmpeg -ss 1 -t 0.002 -i QQ视频20221105205711.mp4 SAMPLES\sample.jpg -vframes 1 -an -f image2
-
- FOR I = 1 TO CNT
- SET TS = FSO.OPENTEXTFILE(TMPNAM62, 8, TRUE)
- JPGFN2 = JPGFN & I & ".JPG"
- TS.WRITELINE("file '" & JPGFN2 & "'")
- TS.CLOSE
-
- ' CMD = "CMD /C ffmpeg -y -ss " & T & " -t " & NUMSTR(Y) * I & " -i """ & FN & """ """ & JPGFN & I & ".JPG"" -vframes 1 -an -f image2"
- CMD = "CMD /C ffmpeg -y " & " -ss " & NUMSTR(T + Y * I) & " -i """ & FN & """ """ & JPGFN2 & """ -vframes 1 -an -f image2"
- WSCRIPT.ECHO(CMD)
- WSH329.RUN CMD, 10, TRUE
- NEXT
- END SUB
-
-
- FUNCTION GET_DURATION(FN, TMPNAM62)
- ' ffmpeg -i QQ视频20221105205711.mp4 2>&1 | findstr Duration
- ' Duration: 00:00:13.23, start: 0.000000, bitrate: 1492 kb/s
-
- CMD = "CMD /C ffmpeg -i """ & FN & """ 2>&1 | findstr Duration > """ & TMPNAM62 & """"
- WSCRIPT.ECHO(CMD)
- WSH329.RUN CMD, 10, TRUE
-
- SET TS = FSO.OPENTEXTFILE(TMPNAM62, 1, FALSE, TRISTATETRUE)
- LN = TS.READLINE
- TS.CLOSE
- FSO.DELETEFILE TMPNAM62
- SET REGEX = NEW REGEXP
- REGEX.PATTERN = "(\d\d):(\d\d):(\d\d)"
- SET MATCHES = REGEX.EXECUTE(LN)
- T = CINT(MATCHES(0).SUBMATCHES(0))
- T = T * 60 + CINT(MATCHES(0).SUBMATCHES(1))
- T = T * 60 + CINT(MATCHES(0).SUBMATCHES(2))
- GET_DURATION = T
- END FUNCTION
-
-
- SUB MAIN4(FN, CNT, Y, JPGFD, TMPNAM62, GIFOUT)
- IF NOT FSO.FOLDEREXISTS(JPGFD) THEN
- FSO.CREATEFOLDER(JPGFD)
- END IF
-
- DURATION = GET_DURATION(FN, TMPNAM62)
- FOR I = 0 TO 7
- WSCRIPT.ECHO(I)
- TAKE FN, DURATION/8 *I, CNT, Y, JPGFD & "\SAMPLE-" & I & "-", TMPNAM62
- NEXT
-
- CMD = "ffmpeg -r 10 -f concat -safe 0 -i PRINT12912213.TMP.TXT " & GIFOUT
- WSCRIPT.ECHO(CMD)
- WSH329.RUN CMD, 10, TRUE
- END SUB
-
- MAIN4 WSCRIPT.ARGUMENTS(0), 10, 1, "SAMPLES21031", "PRINT12912213.TMP.TXT", WSCRIPT.ARGUMENTS(1)
复制代码 使用方法:保存为PRINTS.VBS文件,在命令行输入以下命令执行:- CSCRIPT PRINTS.VBS "C:\Users\ADMIN\Videos\知识点精讲-毛概.FLV OUT.GIF
复制代码 后面两个参数是视频和GIF名称,根据实际修改。 |