Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- set ffmpeg_path="C:\Program Files (x86)\FFmpeg 6.0\bin\ffmpeg.exe"
- set ffprobe_path="C:\Program Files (x86)\FFmpeg 6.0\bin\ffprobe.exe"
- md trimmed
- for %%a in ("*.mp4") do (
- for /f "tokens=* usebackq" %%b in (`"%ffprobe_path%" -v error -show_entries format^=duration -of default^=noprint_wrappers^=1:nokey^=1 "%%a"`) do (
- call :process "%%a" %%b
- )
- )
- goto :eof
- :process
- setlocal
- set file=%~1
- set duration=%~2
- rem Remove fractional seconds
- for /f "tokens=1 delims=." %%d in ("%duration%") do set /a new_end=%%d - 10
- rem Format the new duration in HH:MM:SS
- set /a hh=new_end / 3600
- set /a mm=(new_end %% 3600) / 60
- set /a ss=new_end %% 60
- rem Pad with zeros
- if %hh% lss 10 set hh=0%hh%
- if %mm% lss 10 set mm=0%mm%
- if %ss% lss 10 set ss=0%ss%
- set end_time=%hh%:%mm%:%ss%
- echo Trimming %file% from 00:03:00 to %end_time%
- "%ffmpeg_path%" -i %file% -ss 00:03:00 -to %end_time% -c:v copy -c:a copy "trimmed\%file%"
- endlocal
- goto :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement