ra1nty / DXcam

A Python high-performance screen capture library for Windows using Desktop Duplication API
MIT License
521 stars 72 forks source link

Movement Dropping Framerate #20

Open Qfc9 opened 2 years ago

Qfc9 commented 2 years ago

First off, great repo, it is really coming in clutch.

Issue

I am able to typically achieve the framerate cap set ONLY if their is no movement. If I move my mouse around it causes the FPS to drop almost 50% and if I move windows around or have content moving in the background it lowers it even further (From 160 to 40ish). The performance loss only happens on movement.

Thought it may be a windows issue so I elevated the tasks run priority to realtime and their was no difference.

Thought it may be a GPU issue but still happens if games are or are not running. If the game is on a static page it will shoot up, but if there is any movement, it will drop back down again.

Not sure if this is a DXcam issue or python issue. I want to assume it's a DXcam issue internally or with the Windows API calls. It seems like the scenes are being cached which improves performance but once something changes, the cache is invalidated and the update process becomes very slow.

Output:

This is the output speed from me just moving my mouse around. I know it says CPS, but it is FPS. Code is pulled from another project and I was lazy and didn't change the output text.

CPS: 135
CPS: 136
CPS: 86
CPS: 52
CPS: 52
CPS: 129
CPS: 99

Desktop Specs:

Software (may be relevant, not sure)

Code

This is the code I was running. Forgive the code, it is cut out from a larger application


import time
import win32api
import dxcam

aaQuitKey = "Q"
cpsDisplay = True
count = 0
sTime = time.time()

screenshotTime = 0
imgTime = 0
modelTime = 0
formatTime = 0

region=(0, 0, 320, 320)

camera = dxcam.create(region=region)
camera.start(target_fps=160, video_mode=True)

st = time.time()
while win32api.GetAsyncKeyState(ord(aaQuitKey)) == 0:
    frame = camera.get_latest_frame()

    count += 1
    if (time.time() - sTime) > 1:
        if cpsDisplay:
            print("CPS: {}".format(count))

        count = 0

        sTime = time.time()```

### Let me know if you need me to submit more info
Qfc9 commented 2 years ago

Follow up

Here is the output from

code

print(dxcam.device_info())
print(dxcam.output_info())

output

Device[0]:<Device Name:NVIDIA GeForce RTX 2080 Dedicated VRAM:8010Mb VendorId:4318>

Device[0] Output[0]: Res:(3840, 2160) Rot:0 Primary:True
Device[0] Output[1]: Res:(3840, 2160) Rot:0 Primary:False
Device[0] Output[2]: Res:(1920, 1080) Rot:0 Primary:False
ninjatall12 commented 2 years ago

Any news on this im experiencing the same problem with 3060ti 32gb 5700x

AI-M-BOT commented 2 years ago

Have you tried video_mode=False ?

ninjatall12 commented 2 years ago

Have you tried video_mode=False ?

Yes still the same

ZCban commented 1 year ago

amazing rootkit developer and cv-go developer in the same post :)