[FFmpeg-user] Some questions about PTS

Michael Koch astroelectronic at t-online.de
Fri Aug 28 12:55:02 EEST 2020


Am 28.08.2020 um 11:25 schrieb Edward Park:
> Hello,
>
> I am not confident about this info but I've always thought the timebase is usually the reciprocal of the framerate *or smaller*. As in, the duration of a frame can be represented accurately enough as the difference between the timestamps, which aren't counted using seconds, but "ticks" in whatever timebase. So smaller fractions could be used as the timebase as long as the system is capable, and on the other hand, when you create low-fps video like 4fps, obviously the timebase isn't going to be 1/4, it'll probably have the same timebase as any other export. (I think of it as an analog wall clock, except it doesn't go tick-tock every second, it goes tick-tock every 1/90000 seconds.)
>
> Actually, I think for the codec timebase, it is more common for it to be 1/2 the reciprocal of the frame rate; if that's codec-specific, I don't know why that is. Maybe you've also seen some setpts examples where you divide/multiply something by 2 for some arcane reason? Hopefully someone can explain further..
>
> When you delay some frames by whatever amount, it necessarily effects a change in the frame rate (but not the timebase). I'm not sure where the FR value for setpts comes from, maybe it wouldn't matter if it stays the same as the nominal framerate if indicated by the media, but if it is something that can change, maybe the effective rate at the end of the chain, obviously it wouldn't work as expected.
>
> Just for the sake of curiosity, what has you looking to delay frames using setpts? I feel there are easier methods.

Let's assume the framerate is constant. For example, I want to delay a 
video by 5 frames and then hstack the original video and the delayed 
version:

ffmpeg -i test.mp4 -vf 
"split[a][b];[b]setpts=PTS+5/(FR*TB)[c];[a][c]hstack" -y out.mp4

Are there other / better / easier methods to do the same thing?

Michael



More information about the ffmpeg-user mailing list