8

I'm trying to setup a script to automate some video manipulation, including trimming the video. for that I'm using ffmpeg filter_complex.

I would like to specify the start and end position using the format HH:MM:SS.m, but I'm not able to do it, despite the fact that ffmpeg documentation states it could be done. Here's a simplified version of the code:

ffmpeg -i input.mp4 -filter_complex \
"[0:v]trim=1.40.1:1.59.3,setpts=PTS-STARTPTS[v]" \
-map "[v]" -pix_fmt yuv420p -c:v libx264 -preset fast -y output.mp4

I think this it due to the fact that ":" is used to separate arguments in the filter options.
Any chances to make it work?

Chong Onn Keat
  • 117
  • 1
  • 7
sanzoghenzo
  • 238
  • 2
  • 6
  • I've marked this duplicated as per the suggestion, but the answer to my question is way better (and includes link to documentation!) – sanzoghenzo Mar 22 '22 at 10:50

1 Answers1

18

Welcome to "escaping hell". There are a variety of methods to do this. Here are three:

"trim=start='00\:00\:01.23':end='00\:00\:04.56'"

"trim=start=00\\\:00\\\:01.23:end=00\\\:00\\\:04.56"

trim=start=00\\\\:00\\\\:01.23:end=00\\\\:00\\\\:04.56
llogan
  • 57,139
  • 15
  • 118
  • 145
  • Wow. I spent a long time trying to figure this one out. Thanks for the helpful answer! – Sam Jul 12 '20 at 12:44