smasherprog / screen_capture_lite

cross platform screen/window capturing library
MIT License
616 stars 156 forks source link

black screen captured #159

Open jcyuan opened 10 months ago

jcyuan commented 10 months ago

Hi @smasherprog , i found that most time this lib works very well, but still chance that it will capture a black screen image, i'm not sure why it happened.

what i did is in my onNewFrame callback to stop the capturing (mgr.PauseCapturing()), because 1 frame is enough for me. is this the reason? why the first frame is black sometimes (very rare chance actually), how can i avoid this to happen?

thank you.

smasherprog commented 10 months ago

As afar as why it can be black, i am unsure.

Why is this a problem? The next frames should be correct, right? So if your doing any kind of a desktop streaming, this isnt noticeable at all and a non issue?

smasherprog commented 10 months ago

You only ever want to capture a single frame and then stop? If thats the case id add code to check if the first frame is black, and skip it and STOP at N checks.
If you want to debug the program, maybe theres some error I am not capturing correctly when gathering the first frame? Should be ez to debug as the code isnt very complex.

jcyuan commented 10 months ago

You only ever want to capture a single frame and then stop? If thats the case id add code to check if the first frame is black, and skip it and STOP at N checks.

exactly! because i'm making a screen color picker, so 1 frame is enough for this.

please give me some hints where should I dig into the source code for how to check if the current frame is a black screen? i wanna try to fix it myself first as i know you might be busy so i'm unsure when you can fix it.

smasherprog commented 10 months ago

This is the function that does the capturing. If there is an error, it will be in here https://github.com/smasherprog/screen_capture_lite/blob/1170d572d83d9a9dd74fc375cb182083b5e9cd6a/src_cpp/windows/DXFrameProcessor.cpp#L300

jcyuan commented 10 months ago

This is the function that does the capturing. If there is an error, it will be in here

https://github.com/smasherprog/screen_capture_lite/blob/1170d572d83d9a9dd74fc375cb182083b5e9cd6a/src_cpp/windows/DXFrameProcessor.cpp#L300

😵 well, I don't know DX11 well... is there a way to check if the current frame is fully black in C# side? so that i won't call mgr.PauseCapturing() in this case to stop the capturing?

smasherprog commented 10 months ago

The only thing i can do is point you in the code section. If you find a bug please post a PR