BtbN / FFmpeg-Builds

MIT License
6.97k stars 956 forks source link

ddagrab stuttering and cursor issues #347

Closed Sean-Zeo closed 3 months ago

Sean-Zeo commented 3 months ago

Hi, it seems ddagrab is currently broken in the latest builds. The cursor causes a tail effect and the frame rate skips/jumbles.

BtbN commented 3 months ago

Works fine for me on latest win64 build. Make sure your graphics driver is in working condition.

Sean-Zeo commented 3 months ago

Hi, same issue. Latest drivers for intel XE graphics. It also has the same issue on a cloud A4000 nvidia GPU PC.

https://github.com/BtbN/FFmpeg-Builds/assets/127526527/8a2d76cb-bb5e-4500-a62b-1d6046eb3229

BtbN commented 3 months ago

I have just tested it, and it works perfectly for me. So I'm not sure what to tell you or what I should do about it.

Sean-Zeo commented 3 months ago

Hi, even this sample command causes such an issue;

ffmpeg -filter_complex ddagrab=output_idx=0:framerate=60,hwdownload,format=bgra -c:v libx264 -crf 18 output.mp4

BtbN commented 3 months ago

Your command also works perfectly fine for me, and produces clean and intact output. This looks much more like some weird driver side issue than anything related to FFmpeg, let alone these specific builds of it.

Sean-Zeo commented 3 months ago

Hi, even software encoding, it does not work (no drivers required), same issue. I've tested on several machines with latest Windows 10, same issue.

BtbN commented 3 months ago

ddagrab is quite low level and directly interfaces with the graphics driver. It works perfectly for me on both Nvidia and Intel Iris Xe, so my suspicion is that it's some bug in older Intel GPU drivers or something.

It's probably fallout from https://github.com/FFmpeg/FFmpeg/commit/21c6d12449a2230a959da79f224b7443fe89d6d3 but without that patch capturing is completely broken in different ways. The patch still looks correct to me, and it's likely a driver bug where it does not honor the correct order of operations for some reason.

Sean-Zeo commented 3 months ago

Hi, as I said before, this issue is occurring on both an Intel Iris XE machine as well as a separate RTX 4000 machine. The issue also occurs when using software encoding. So I don't think this is driver related at all.

BtbN commented 3 months ago

The encoder is not involved in this, so not sure why you keep bringing it up. ddagrab always interfaces with the graphics driver.

And like I said before, I am completely unable to reproduce this on both an Nvidia and an Intel machine.

BtbN commented 3 months ago

Can you run a debugger on this? Since I can't reproduce this, I have no chance of fixing it otherwise.

Run ffmpeg like this: ./ffmpeg.exe -v debug -init_hw_device d3d11va=dbgdev:-1,debug=1 -filter_hw_device dbgdev -filter_complex ddagrab=0:framerate=60 -c:v hevc_nvenc -preset slow -cq:v 20 -y out.mp4

The output side doesn't matter, feel free to replace nvenc with x264 or whatever.

Run https://learn.microsoft.com/en-us/sysinternals/downloads/debugview before and while invoking ffmpeg like that. It should capture any D3D11 debug messages from ffmpeg, hopefully giving an explanation for this. For me it comes up completely empty outside of a bit of noise on shutdown.

For this to work, you need to have the d3d11 debug layers installed. You can check by running where.exe d3d11_1sdklayers.dll. It it's missing, you might have to install the "Graphical Tools" Optional Feature, or the full on D3D SDK.

BtbN commented 3 months ago

After quite a wild chase for this, we finally found the root cause and fixed it in https://github.com/FFmpeg/FFmpeg/commit/b47abd5737eed9304fc808bc7a1043c55b21263f I still don't fully understand why these flags are different per system or screen. But they are. And depending on what they are, it can break in multiple ways.