s1 为片头长度。s2为片尾长度
代码语言:javascript复制@echo off & setlocal enabledelayedexpansion
set "s1=00:00:36.00"
set "s2=00:00:36.00"
for /f "tokens=1-4delims=:." %%a in ("%s2%") do (
set /a "t2=(1%%a %% 100 *3600 1%%b %% 100 * 60 1%%c %% 100) * 1000 1%%d %% 1000"
)
md NEW 2>nul
for %%i in (*.mp4) do (
for /f "tokens=2-5delims=:., " %%a in ('ffmpeg -i "%%i" 2^>^&1 ^| find "Duration:"') do (
set /a "t=(1%%a%0*3600 1%%b%0*60 1%%c%0)*1000 1%�%00,t-=t2,ms=t%00,t/=1000"
set /a h=t/3600,m=t%600/60,s=t%`,h =100,m =100,s =100,ms =1000
set "t=!h:~1!:!m:~1!:!s:~1!.!ms:~1!"
ffmpeg -i "%%i" -ss !s1! -to !t! -vcodec copy -acodec copy "NEW%%i" -y
)
)
pause