Skip to content
  • Niklas Haas's avatar
    utils/frame_queue: add PTS drift compensation · de6d57f0
    Niklas Haas authored
    By default, allows for correcting drift/jitter of up to 1 ms per frame,
    in line with expected jitter from e.g. Matroska sources. This is enough
    to cover the mismatch between 23.976 Hz and 24.000 Hz, but not the
    mismatch between 24 and 25 Hz (which is just over 1ms per frame).
    There are two use cases in which this code will be useful:
    1. Displaying 23.976 Hz video files on e.g. 60.000 Hz monitor (or any
       other near-miss), in display-timed mode. Given the usual 3:2
       cadence, after five vsyncs (three source frames), we will have:
       Vsync (wallclock) PTS = 83.33333333333334
       Frame PTS = 83.41675008341676
       This is a difference of 0.1ms, and will therefore be fixed by this
       code, adjusting all future wallclock PTS up by the cumulative drift
    2. Displaying any video with some amount of jitter on the PTS
       measurements. This avoids some situation where we have frames with
       weights 0.999 and 0.001 for example. Normally this should get rounded
       away by the frame mixing code anyway, but it's better to have an
       exact match.