acowley / ffmpeg-light

Minimal Haskell bindings to the FFmpeg library
BSD 3-Clause "New" or "Revised" License
67 stars 29 forks source link

fix vplay framerate #45

Closed gelisam closed 6 years ago

gelisam commented 6 years ago

On my computer, vplay's fps was visibly incorrect, and videos looked like they were being played on slow motion. This fixes the problem by measuring the duration of the entire frame, not just the costly renderTexture call.

acowley commented 6 years ago

To be sure I understand, the point here is that using the IORef lets us include the ffmpeg frame decode in our inter-frame timing, whereas previously we were effectively timing only the inner loop?

gelisam commented 6 years ago

Ah! That wasn't the goal, no, but now that you point it out, yes, that's what the code is doing!

My goal was to include everything going on inside the frame, not just the bits which we think are costly. I previously thought that renderTexture was also decoding the next frame, so the only thing which wasn't being measured was this nothingOnQuit function. I thought that function was only polling for events and should thus complete super-quickly, but including it in the measurement fixed the problem, and that was good enough for me. Now that you point out that this function is also decoding the next frame, I finally understand why my fix works :)

acowley commented 6 years ago

Thank you!