本帖最后由 xp3000 于 2022-9-28 23:17 编辑
ffmpeg截图命令我改了一下确实快了很多- @echo off & setlocal enabledelayedexpansion
- title ffmpeg视频尾部X秒批量截图
- :a
- set /p "str=输入1-9秒:"
- echo %str%|findstr /x "[1-9]" >nul||(echo 输入有误,按任意键返回&goto :a )
-
- for /f "delims=" %%i in ('dir /b /a-d *.avi *.mkv *.mp4 *.flv') do (
- for /f "tokens=2-5delims=:., " %%a in ('ffmpeg -i "%%i" 2^>^&1 ^| find "Duration:"') do (
- set /a "t=(1%%a%%100*3600+1%%b%%100*60+1%%c%%100)*1000+1%%d0%%1000,t-=%str%*1000,ms=t%%1000,t/=1000"
- set /a h=t/3600,m=t%%3600/60,s=t%%60,h+=100,m+=100,s+=100,ms+=1000
- set "t=!h:~1!:!m:~1!:!s:~1!.!ms:~1!"
- echo 文件:%%i 将在!t!处截图,请耐心等待……
- ffmpeg -v quiet -ss !t! -i "%%i" -frames:v 1 "%%~ni.png"
- )
- )
- pause
复制代码 有时候自己也要用到截图尾部几十秒的- @if(0)==(0) echo off& setlocal EnableDelayedExpansion&cd %~dp0
- title ffmpeg视频尾部XX秒批量截图
- :ss
- set /p ss=请输入秒数(例:5或21):
- @for /f "delims=" %%i in ('echo %ss%^|cscript -nologo -e:jscript "%~f0"') do (
- if not "%%i"=="正确" echo. & echo 时间格式不对,请重新输入1-59内数字 & goto ss
- )
- for /f "delims=" %%i in ('dir /b /a-d *.avi *.mkv *.mp4 *.flv') do (
- for /f "tokens=2-5delims=:., " %%a in ('ffmpeg -i "%%i" 2^>^&1 ^| find "Duration:"') do (
- set /a "t=(1%%a%%100*3600+1%%b%%100*60+1%%c%%100)*1000+1%%d0%%1000,t-=%ss%*1000,ms=t%%1000,t/=1000"
- set /a h=t/3600,m=t%%3600/60,s=t%%60,h+=100,m+=100,s+=100,ms+=1000
- set "t=!h:~1!:!m:~1!:!s:~1!.!ms:~1!"
- echo 文件:%%i 将在!t!处截图,请耐心等待……
- )
- ffmpeg -v quiet -ss !t! -i "%%i" -frames:v 1 "%%~ni.jpg"
- )
-
- pause & exit /b
- @end
- WSH.echo(WSH.StdIn.ReadAll().replace(/^[1-5]\d|^[1-9]/, '正确').match(/^[^\r\n]+/).join('\r\n'));
复制代码
|