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

前端 未结 5 1057
悲&欢浪女
悲&欢浪女 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:31

    I kindly thank everyone here for encouraging me to keep searching, I found a solution that is perfect. Here it is. I am afraid the examples given even in the comments elude me but I will still try to read up and educate myself on how those commands work. Thanks again. Replace 8.25 (end trim) and 4.25 (beginning trim) and change the values until you are satisfied with the outputs.

    @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""
    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 (
        'FFProbe %opts% %1') Do (Set/A "ws=%%a-8.25" & Set "ps=%%b")
    rem If %ws% Lss 20 GoTo :EOF
    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 -i %1 -ss 00:00:04.2500 -to %hh%:%mm%:%ss%.%ps:~,3% -c:v copy -c:a copy "Trimmed\%~1"
    

提交回复
热议问题