Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Avoid flickering when using SharpAvi #568

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

alantan
Copy link

@alantan alantan commented Jul 4, 2020

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.

When using SharpAvi, frames occassionally 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 prefilled with zeros.
@alantan alantan changed the title Avoid flickering when using SharpAvi. Avoid flickering when using SharpAvi Jul 4, 2020
@MathewSachin
Copy link
Owner

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.

Use a token, such as a GUID, which can be used to stop a recording.

Can be used with or without length:
- If no length is provided, recording will continue indefinitely
  until a token signal is sent.
- If a length is provided, recording will continue until the time
  has expired or a token signal is sent, whichever arrives first.

Example code to stop a recording that was started using --stop ABCDE:

var doneWithInit = new EventWaitHandle(
    false, EventResetMode.ManualReset, "ABCDE");
doneWithInit.Set();
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants