[FFmpeg-user] Freeze frames in timeline editing
Gyan Doshi
gyandoshi at gmail.com
Sun Jul 22 20:02:10 EEST 2018
On 21-07-2018 04:12 PM, John Allan Farleyton wrote:
> Hi,
> I am trying to slow down a video to half speed beginning from frame 100
> with the setpts filter. It works, but from frame 100 I get 100 additional
> frozen dropped frames before the video continues at half speed. Is my
> command wrong or is there a problem with the setpts filter?
>
> Command:
> ffmpeg -i ball.avi -vf "setpts='if(gte(N,100),2,1)'*PTS" -c:v libx264 -crf
> 20 -pix_fmt yuv420p ball_slow.avi
Since your video has a timescale of 30 tbn, equal to the framerate, we
can treat each frame's PTS to be equal to its N index.
So, as your expression,
frame 99 will have PTS 99 = 99/30 = 3.33s and
frame 100 will have PTS 200 = 200/30 = 6.67s;
101 will have 6.73s.
That's because PTS of frames N >= 100 can be thought to be comprised of
both an interval from the previous frame as well the common offset from
the start of the whole stream. For double speed, you only need to double
the inter-frame interval.
So, use instead,
setpts='if(eq(N,0),0,PREV_OUTPTS+if(gte(N,100),2,1)*(PTS-PREV_INPTS))'
Gyan
More information about the ffmpeg-user
mailing list