I have a video where I would like to change the time scale of a video based on ratios read in from a file.
I have figured out that to double the speed for an entire video I could use the setpts
filter doing setpts=2*PTS
, however what I want to do is change the scale over time so the video would
- Start at 1x speed
- At the 5.7564 second mark it would switch to 1.4x speed
- At the 10.2571 second mark it would switch to 0.983333x speed
- At the 15.6251 second mark it would switch to 1x speed for the rest of the video.
I have figured out I would likely need to make a script file that could be read by -filter_script:v
but I don't know what to use to get the behavior I want.
My first naive approach was to do
setpts='
if(lt(T,5.7564),
1*PTS,
if(lt(T,10.2571),
1.4*PTS,
if(lt(T,15.6251),
0.983333*PTS,
1*PTS
))))'
but that causes the video to jump around at the cut points and can cause parts of the video to be skipped or repeated. I now understand why this happens, but I don't know what I should do instead.
The best way would likely be to cut the video into 4 segments and just use a single setpts=#*PTS
to per segment, but I don't know how to script that.