I need to cut MP4 videos. A part at the beginning and a part at the end in a batch fashion

前端 未结 5 1129
悲&欢浪女
悲&欢浪女 2021-02-06 14:09

I have several training videos. All .MP4s.

I want to remove 3.5 seconds from the beginning and 4.5 seconds from the end of the entire folder of them...

I know of

5条回答
  •  甜味超标
    2021-02-06 14:28

    Eric Lalonde script was good enough, thank you!

    For those who can't or don't like installing ffmpeg, I added ffmpeg path variable. In my scenario I am cutting the 14 seconds from the beginning and 9 seconds at the end.

    @Echo Off
    SetLocal
    Set "ext=mp4"
    Set "opts=-v quiet"
    Set "opts=%opts% -print_format "compact=print_section=0:nokey=1:escape=csv""
    Set "opts=%opts% -show_entries "format=duration""
    Set ffmpeg=C:\Users\user\Downloads\ffmpeg-20180102-57d0c24-win64-static\bin\
    If Exist *.%ext% (If Not Exist "Trimmed\" MD Trimmed)
    For %%a In (*.%ext%) Do Call :Sub "%%~a"
    Exit/B
    
    :Sub
    For /f "Tokens=1* Delims=." %%a In (
        '%ffmpeg%\ffprobe %opts% %1') Do (Set/A "ws=%%a-9.00" & Set "ps=%%b")
    Set/A hh=ws/(60*60), lo=ws%%(60*60), mm=lo/60, ss=lo%%60
    If %hh% Lss 10 Set hh=0%hh%
    If %mm% Lss 10 Set mm=0%mm%
    If %ss% Lss 10 Set ss=0%ss%
    %ffmpeg%\ffmpeg -i %1 -ss 00:00:14.000 -to %hh%:%mm%:%ss%.%ps,~3% -c:v copy -c:a copy "Trimmed\%~1"
    

提交回复
热议问题