美文网首页
ffmpeg 去掉片头片尾。。。

ffmpeg 去掉片头片尾。。。

作者: 毛毛v5 | 来源:发表于2019-05-14 12:07 被阅读0次

s1 为片头长度。s2为片尾长度

@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%%100*3600+1%%b%%100*60+1%%c%%100)*1000+1%%d0%%1000,t-=t2,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!"
        ffmpeg -i "%%i" -ss !s1! -to !t! -vcodec copy -acodec copy "NEW\%%i" -y
    )
)
pause

相关文章

网友评论

      本文标题:ffmpeg 去掉片头片尾。。。

      本文链接:https://www.haomeiwen.com/subject/pnqsaqtx.html