0

I try to set pts for each frame of the input video.

Here is the command I use to slowdown frame 1 and speed up frame 2:

ffmpeg -i input.mkv -filter_complex "[0:v]setpts='PTS*2*eq(N,0)+PTS*0.5*eq(N,1)+...'[out]" -map [out] output.mkv

I am new to ffmpeg and I can't figure out why my output duration is longer than my input.

If I make the 1st frame 2x slower and the 2nd frame 2x faster the output should have the same duration as the input ?

Thanks !

3
  • No, if you had 2 frames and your original frame duration was 1 second, then total duration would be 2 seconds. If you changed frame 1 duration to 2 seconds and frame 2 to 0.5 seconds, then total duration would become 2.5 seconds, which is longer.
    – Gyan
    May 5 at 4:14
  • Now, what your setpts expr actually does is multiply the presentation timestamp directly. That does not do what you intend. PTS have to be monotonic i.e. always increasing, so if frame 20 has original pts 20 seconds, and frame 21 has 21 seconds, then with your expr, frame 20 will have new pts 40 and frame 21 will have new pts 10.5. That's not valid and ffmpeg will adjust the pts of 21 to be larger than frame 20.
    – Gyan
    May 5 at 4:19
  • Ok, it's clear now. I was confused because I thought that PTS was the starting point of the current frame (taking into account the pts of the previous frame) but if I understood correctly, it is that of the entry without consideration of the previous frames and their pts. Thank you very much for your time! Your answer is well explained !
    – legeba
    May 6 at 7:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.