MathewSachin / Captura

Capture Screen, Audio, Cursor, Mouse Clicks and Keystrokes
https://mathewsachin.github.io/Captura/
MIT License
9.68k stars 1.81k forks source link

Avoid flickering when using SharpAvi #568

Open alantan opened 4 years ago

alantan commented 4 years ago

When using SharpAvi, frames occasionally get dropped and the Texture2DFrame.CopyTo method produces a transparent frame. This has been observed to happen when recording the Windows desktop applications such as File Explorer. This causes the recording to flicker and have flashes of empty frames.

The fix checks for transparency by comparing the current frame to all zeros, and uses the previously saved frame if necessary. For performance, it uses memcmp to compare to a byte array pre-filled with zeros.

NB: I realize this might be better fixed in the SharpAvi part of the code, but I spent a couple of days investigating and trying out different things, and could not figure out what was causing the frame drops.

MathewSachin commented 4 years ago

If Texture2DFrame.CopyTo is producing transparent frames, I think we should handle this check there only. This can happen with other writers also I think. I'll only be able to look into the problem after a few weeks, too busy with work right now.