Advertisement
Guest User

Untitled

a guest
Jun 24th, 2025
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. @echo off
  2. set ffmpeg_path="C:\Program Files (x86)\FFmpeg 6.0\bin\ffmpeg.exe"
  3. set ffprobe_path="C:\Program Files (x86)\FFmpeg 6.0\bin\ffprobe.exe"
  4.  
  5. md trimmed
  6.  
  7. for %%a in ("*.mp4") do (
  8. for /f "tokens=* usebackq" %%b in (`"%ffprobe_path%" -v error -show_entries format^=duration -of default^=noprint_wrappers^=1:nokey^=1 "%%a"`) do (
  9. call :process "%%a" %%b
  10. )
  11. )
  12. goto :eof
  13.  
  14. :process
  15. setlocal
  16. set file=%~1
  17. set duration=%~2
  18.  
  19. rem Remove fractional seconds
  20. for /f "tokens=1 delims=." %%d in ("%duration%") do set /a new_end=%%d - 10
  21.  
  22. rem Format the new duration in HH:MM:SS
  23. set /a hh=new_end / 3600
  24. set /a mm=(new_end %% 3600) / 60
  25. set /a ss=new_end %% 60
  26.  
  27. rem Pad with zeros
  28. if %hh% lss 10 set hh=0%hh%
  29. if %mm% lss 10 set mm=0%mm%
  30. if %ss% lss 10 set ss=0%ss%
  31.  
  32. set end_time=%hh%:%mm%:%ss%
  33.  
  34. echo Trimming %file% from 00:03:00 to %end_time%
  35. "%ffmpeg_path%" -i %file% -ss 00:03:00 -to %end_time% -c:v copy -c:a copy "trimmed\%file%"
  36. endlocal
  37. goto :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement