Sascha-L / WPF-MediaKit

Microsoft Public License
363 stars 115 forks source link

DXVA2 #24

Closed ASantos007 closed 7 years ago

ASantos007 commented 7 years ago

Hi all :)

I'm a little confused how the DXVA2 works!! I just need to run the Test Application inside WPFMediaKit solution or need I do some configuration to work whit DXVA2?

I am asking because when I play a video (4k) with WPFMediaKit application it is consuming more than 80% of CPU and just consume about 20% of GPU. I want to render the video with GPU not CPU and I can do that programmatically.

Anyone can help me please??

xmedeko commented 7 years ago

AFAIK you have to use EvrPresenter if you want to use DXVA2: compile the EvrPresenter from the source code and set the VideoRenderer property.

ASantos007 commented 7 years ago

Yes.. I forgot this issue, but I had already found the solution!

So, I can leave here some steps to work with WPF-MediaKit: 1- Install, for example, K-Lite Codec Pack 2- Open "Lav Video" tool and change "Hardware Decoder to use" field to DXVA2 3- Open EvrPresenter solution and compile it 4- Open WPF-MediaKit solution and replace the EvrPresenter.ddl on "Test Application" project to EvrPresenter.ddl generated in the previous step 5- In MainWindow.xaml add VideoRenderer="EnhancedVideoRenderer" in controls:MediaUriElement tag: controls:MediaUriElement x:Name="mediaUriElement" VideoRenderer="EnhancedVideoRenderer" ...controls:MediaUriElement>; .... Or you can simple change the default value in VideoRendererProperty property to VideoRendererType.EnhancedVideoRenderer 6- Compile and start the "Test Application" 7- Enjoy!!

You can use DXVA Checker to see if your graphic card support DXVA and if you are using DXVA to render the video!!

xmedeko commented 7 years ago

What happen if the video card has no DXVA and the EvrPrenter is used? Will be video still visible? I do not have a machine with such video card to test it. Thanks.

ASantos007 commented 7 years ago

The video will work well, but it will not use the GPU to render the video!

You can test render a video with or without DXVA with the same graphic card. You just need to change the "Hardware Decoder to use" field to DXVA2 or NONE value on Lav Video Tool.

The results of my tests are:

Without DXVA

With DXVA

With VMR9 instead EVR:

My purpose is only to use GPU to render the video and leave CPU free to do other things!

xmedeko commented 7 years ago

Thanks for the info. It's pity EVR without DXVA takes more CPU than VMR9. We distribute a public app and also want to use GPU if possible. But since DXVA is disabled by default and EVR takes more CPU then VMR9 without EVR, I think we keep using VMR9.

ASantos007 commented 7 years ago

Yes, make sense!

I was searching how we can user DXVA automatically and I have 2 option:

If you have more option, please share with us :)

xmedeko commented 7 years ago

LAV DXVA should be configurable at runtime, e.g. see http://forum.doom9.org/archive/index.php/t-156191-p-69.html search the code lavVideoSettings. I have not tried that yet. I am still a newbie in this Window video stuff so I will have to figure out if and how it's possible to plug this code into the WPF-MediaKit. (Hint: a C# code example is at Emby.Theater.Windows ).

ASantos007 commented 7 years ago

I am also a newbie with this stuff..

I found that the WPF can use MediaElement to render videos. So, if we are using WPF, why we need WPF-MediaKit? We can use MediaElment directly on our project. It is easier and faster to implement!

There is any reason to use WPF-MediaKit instead of MediaElement?

jluisestrada commented 7 years ago

MediaElement is very limited. With the WpfMediaKit you can control the video source at really low level.

Sent from my HAL 9000 terminal. Excuse the typos and/or any trapped astronauts in the airlock

xmedeko commented 7 years ago

@ASantos007 closing this issue, if you need something more, reopen it, please.