I'm trying to figure out why even with that fix to account for the fractional part of the 15734 Hz sample rate, the audio still gets out of sync with the video for long running videos.
It just dawned on me that the video is not exactly 60 FPS, it's 59.94 FPS.
For the video:
Code: Select all
90000 frames @ 60.00 fps = 1500.00 seconds
90000 frames @ 59.94 fps ~= 1501.50 seconds
Which makes sense, because consuming the same number of frames at
a higher frame rate should be faster, so by lying and saying the
video frames are 60 fps, the video should be played back a tiny
bit faster than it should.
For the audio:
Code: Select all
23601000 samples @ 15734 Hz = 1500.00 seconds
23601000 samples @ (28636360 Hz / 1820) ~= 1499.97 seconds
Which also makes sense, because consuming the same number of
samples at a slower sample rate should take longer, so by lying
and saying the sample rate is 15734 Hz, the audio should be
played back slower than it should.
Taking both of those together, the video playing back faster than
it should, and the audio playing back slower, I would expect the
video to end up leading the audio, but when I merge the video and
audio streams together at the end, it ends up that the audio
leads the video!
What could I be doing wrong?