Closed valbok closed 9 months ago
@geminixdev
The crash happens also with the video widget example.
Tested only on Ryzen 7 PC with AMD GPU.
Is it possible to check for different PC?I tested qml_video/widget_video examples for many files for 6.6.2 and 6.7.0, but Nvidia graphics.
ffplay
on the same PC? QMediaPlayer
, does it use D3D11 textures?D3D11: Removing Device. D3D11 ERROR: ID3D11Device::RemoveDevice: Device removal has been triggered for the following reason (DXGI_ERROR_DEVICE_HUNG: The Device took an unreasonable amount of time to execute its commands, or the hardware crashed/hung. As a result, the TDR (Timeout Detection and Recovery) mechanism has been triggered. The current Device Context was executing commands when the hang occurred. The application may want to respawn and fallback to less aggressive use of the display hardware). [ EXECUTION ERROR #378: DEVICE_REMOVAL_PROCESS_AT_FAULT]
ffplay
does not work, might be an issue inside ffmpeg. Or might be needed to upgrade DirectX?
- Btw I use the latest from https://github.com/BtbN/FFmpeg-Builds/releases
Yes, same. It wasn't the very latest, but I'll update to latest from today and retest.
If
ffplay
does not work, might be an issue inside ffmpeg. Or might be needed to upgrade DirectX?
In the Qt bugreports there had been crashes reported with AMD GPUs, apparently there was or is an issue when you try to render ffmpeg d3d11 decoded textures directly. It seems to be fixed in latest Qt though.
This is why I tested all, from Qt 6.6.1 over Qt 6.6.2 to latest Qt 6.6 dev, the coming 6.6.3.
I had to setup a dev system recently, due to hardware crash, so currently I can develop only with Ryzen 7 and AMD GPU, and all old Qts are gone, too.
I might be able to test on an Intel i7 system in about a week.
- Is it reproducible for all/many video files?
Any h264/aac mp4 or .ts file or stream I tried. The same I use all the time, whioch work fine everywhere, Quicktime, ffplay, VLC, or packed as HLS in HLS players.
It seems to be fixed in latest Qt though.
I was always afraid that it was hard to control the rendering. For D3D11 textures we explicitly set NV12 pixel formats for frames: https://github.com/valbok/QtAVPlayer/blob/master/src/QtAVPlayer/qavvideoframe.cpp#L421 And return 2 textures qavhwdevice_d3d11
So wondering if this is still relevant.
To make sure that I understand correctly:
1) you do not see this error / crash with #453 added in the video widget example (or elsewhere)? 2) And if not, what GPU? Intel / Nvidia / AMD?
And if you do not see it, does it seem that we now have full zero copy rendering there?
It seems to be fixed in latest Qt though.
I was always afraid that it was hard to control the rendering. For D3D11 textures we explicitly set NV12 pixel formats for frames: https://github.com/valbok/QtAVPlayer/blob/master/src/QtAVPlayer/qavvideoframe.cpp#L421 And return 2 textures qavhwdevice_d3d11
So wondering if this is still relevant.
I can follow what you say, and understand the question, but cannot answer (yet). Possibly a deep check of the Qt code can show what they try to do. (Hoping they do it correctly by now in the latest code).
To make sure that I understand correctly:
- you do not see this error / crash with Support only AV_PIX_FMT_D3D11 for d3d11 #453 added in the video widget example (or elsewhere)?
I don't see any crashes
- And if not, what GPU? Intel / Nvidia / AMD?
Nvidia
And if you do not see it, does it seem that we now have full zero copy rendering there?
For QML it was true even for 5.15 when RHI was introduced. But for widgets, I would need to check the code to confirm.
. (Hoping they do it correctly by now in the latest code).
We could try to avoid rendering, and see if it crashes anyway. F.e. keeping
QVideoFrame v = frame;
qDebug() << frame.handleType() << frame.handle();
and confirm that it does not crash.
. (Hoping they do it correctly by now in the latest code).
We could try to avoid rendering, and see if it crashes anyway. F.e. keeping
QVideoFrame v = frame; qDebug() << frame.handleType() << frame.handle();
and confirm that it does not crash.
I think I understand, and will test this.
- Btw I use the latest from https://github.com/BtbN/FFmpeg-Builds/releases
Yes, same. It wasn't the very latest, but I'll update to latest from today and retest.
I used the BtbN ffmpeg from December 2023, and updated now to the download from today.
And now the crash does not happen in the video widget example. In my app it is similar, not crashing, at least not yet in the short tests, but I can still provoke the DXGI_ERROR_DEVICE_HUNG device removal when I switch output windows. Not every time, but often.
However now there are semi transparent color stripe overlays in the video output, in the video widget example and in my App, usually violet, but occasionally whitish. Sometimes ot looks like the complete picture is whitish. See attachements.
In the Qt bugreports it was mentioned that the ffmpeg d3d11 decoding is using a texture array, and that they have difficulties to avoid that the same texture is read and written to. Looking at the pictures, this might be the issue.
My guess is that a deep look into the very latest Qt source and how they fixed this (if they did indeed go zero copy) might be required to see if anything can be done about this.
. (Hoping they do it correctly by now in the latest code).
We could try to avoid rendering, and see if it crashes anyway. F.e. keeping
QVideoFrame v = frame; qDebug() << frame.handleType() << frame.handle();
and confirm that it does not crash.
I think I understand, and will test this.
I did not test this anymore, because with the very latest ffmpag the crash did not happen yet, see comment above.
It seems to be fixed in latest Qt though.
I was always afraid that it was hard to control the rendering. For D3D11 textures we explicitly set NV12 pixel formats for frames: https://github.com/valbok/QtAVPlayer/blob/master/src/QtAVPlayer/qavvideoframe.cpp#L421 And return 2 textures qavhwdevice_d3d11
So wondering if this is still relevant.
Or could it be a format issue with the 2 NV12 textures which get returned? As you asked, if this would "still be relevant"?
Possibly there is a hint there, about the ffmpeg texture handling:
https://github.com/valbok/QtAVPlayer/pull/456 @geminixdev could you please check it out?
456 @geminixdev could you please check it out?
will test asap
456 @geminixdev could you please check it out?
Wow, thanks, this is excellent! It works!!!!!!!
No crash, no error messages, no color stripes. The picture looks correct.
Testing it also on a weak old Celeron PC with a 4K monitor, it plays smooth, it feels like zero copy rendering.
I will do more testing in the next days, but it looks all good now.
I implemented this in my App, and it crashes. Tested only on Ryzen 7 PC with AMD GPU. Tested with Qt 6.6.1, 6.6.2 and Latest 6.6.3 dev git, always the same.
The crash happens also with the video widget example.
Here is the output using the video widget example (fresh download today):
Reverting to the code before #453 has the effect that the crash does not happen, no error at all, very stable rendering (tested for hours and hours).
I understand that this somehow means that
There have recently been many changes and fixes in Qt Multimedia code concerning textures and rendering, also for D3D11 decoding / rendering, to avoid crashes and to optimize rendering. This crash seems to have the effect that we cannot benefit from them yet.