NiiightmareXD / windows-capture

Fastest Windows Screen Capture Library For Rust And Python 🔥
MIT License
209 stars 29 forks source link

[FEATURE ⭐] Pass through a frame timestamp #54

Closed skaugust closed 2 weeks ago

skaugust commented 4 months ago

I'm having trouble taking a capture after I finish taking an action (mouse move, click, etc). Right now I'm storing the last avaible frame as you suggested in issue #50, but very often it's from before my previous action. Is there any sort of timestamp information that is associated with when the frame was started/produced/buffer swapped that you could pass through and attach to the Frame object to help give more insight for the first guaranteed good frame? I realize there's a lot of pipelining by a lot of different components going on here, and it's likely not fully solvable, but any little bit may help!

NiiightmareXD commented 4 months ago

Hey, this is likely because you're getting the latest frame instantly after doing the action and it's not updated yet if you're using Rust you can use this function to get the time span of the frame: Frame.timespan

I will add this to the Python library soon.

honglei commented 4 weeks ago

Any Update?

WHalcyon commented 2 weeks ago

Would timestamps be the best way to find the recency of the frame?

For example, say that my application wants to handle only the latest frame. Sometimes my application will take longer processing a frame and in the meantime a few frames may accumulate, in that case I would want to discard any accumulated frames except for the latest one.

Is timestamps the way to go or is there a better way to support this pattern using library methods?

Edit: this seems to be the default behavior, but some clarity on how to best control this type of situation would be greatly appreciated.

NiiightmareXD commented 2 weeks ago

I added this just in case anyone needs it Frame.timespan and I think the unit is 100ns.