8

This is what I have so far:

for i in *.mp4; do ffprobe -show_format -i "%i"

// get duration, then need to somehow subtract 30 seconds, and marry these two commands

ffmpeg -ss 0 -i "$i" -t %duration% "${i%.mp4}-cut.mp4

I thought it would be simple, ugh.. why you no have -endtrim switch, ffmpeg? or does it? Maybe another command line one like this can?

1
  • If you have found a solution to your question, please post it as an answer. – Ambo100 Apr 21 '14 at 19:38
5

Post on behalf of the OP who solved the problem themselves:

_trim.bat:

@echo off
for %%i in (*.mp4) do (
call _trim2.bat "%%i"
)

_trim2.bat:

@echo off
for /f "tokens=*" %%a in ('_ffprobe -show_format -i %1 ^| find "duration"') do set _duration=%%a
set _duration=%_duration:~9%
for /f "delims=. tokens=1*" %%b in ('echo %_duration%') do set /a "_durS=%%b"
for /f "delims=. tokens=2*" %%c in ('echo %_duration%') do set "_durMS=%%c"
rem following line is seconds to cut
set /a "_durS-=30"
set "_newduration=%_durS%.%_durMS%"
set "_output=%~n1"
md _fixed
_ffmpeg -ss 0 -i %1 -t %_newduration% -c copy "_fixed\%_output%.mp4"

the processed filed will be put in .\_fixed\samename.mp4 and will all be 30 seconds shorter.

0

I had to use this same exact method for some of files I have.

When I execute _trim2.bat it comes up with errors that Windows doesn't recognize _ffprobe and _ffmpeg (which of course it doesn't cause of underscores).

When I try to execute without underscores it gives an error for ffprobe and ffmpeg as following, respectively:

Missing argument for option 'i'
Unrecognized option '15.'.(duration is 15)
3
  • I am not sure whether this is an answer, or a follow-up issue. – Greenonline Aug 20 '20 at 2:47
  • It is a follow up question.I wasn't able to make a comment – hacker red Aug 20 '20 at 10:40
  • You should ask your own question, using the button at the top of the page and link back to this question using the URL. – Greenonline Aug 20 '20 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.