[FFmpeg-user] Freeze frames in timeline editing
george at nsup.org
Sun Jul 22 20:07:54 EEST 2018
John Allan Farleyton (2018-07-21):
> 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?
Your math is wrong.
> ffmpeg -i ball.avi -vf "setpts='if(gte(N,100),2,1)'*PTS" -c:v libx264 -crf
> 20 -pix_fmt yuv420p ball_slow.avi
First, I think it is not a good idea to mix N and PTS. More reliable to
use only PTS.
For the following explanations, I will assume TB = 1 and all
computations are done as real numbers; FFmpeg works with integers and
uses TB as the base unit, you will have to take this into account.
Your example video has 30 FPS, therefore, in this particular case,
N = 30*PTS. Let us inject that into your formula:
And let us translate this with more readable operators:
(30*PTS >= 100 ? 2 : 1) * PTS
Let us swap the condition (easier to have the first case on the left)
and divide by 30:
(PTS < 3.33 ? 1 : 2) * PTS
Well, just plot this in your favorite grapher, and you will see the
gnuplot -persist <<<'plot [0:5] (x<3.33?1:2)*x'
The frame at input PTS = 3.30 is set to output PTS 3.30;
the frame at input PTS = 3.33 is set to output PTS 6.67.
Therefore, the frame at input PTS 3.30 stays for 3.37 seconds.
To avoid jerky output, the formula in setpts needs to be continuous.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 833 bytes
Desc: Digital signature
More information about the ffmpeg-user