Enabling DXVA with WPF MediaKit?

Jun 8, 2010 at 10:34 PM
Edited Jun 8, 2010 at 11:05 PM

Hello,

I've been desperately trying to get 1080p H.264 video playing smoothly in a WPF application on an Acer AspireRevo R3610 (Atom 330 1.6GHz, NVIDIA ION) running Windows 7 x64. I am using the DivX H.264 decoder that comes with the DivX Plus HD software, with DXVA enabled. In WMP and the DShowPlayer sample from the Windows SDK, I get very low CPU usage: approx. 10% while playing a 1080p H.264 video on that slow machine. However, when using the MediaElement, CPU usage is still not very high (20-25%) but video stutters.

That's when I did some searching and found the WPF MediaKit. I integrated it and tested it only to find out that hardware acceleration doesn't seem to kick in. CPU usage is very high and some frames are dropped. I tried using ffdshow instead and I get the same high CPU usage w/ WPF MediaKit and low CPU usage w/ WMP and DShowPlayer SDK sample (20-25%). I also tried both VMR9 and EVR - same result except that the EVRPresenter32 crashes sometimes (weird. known issue?).

To debug, I downloaded GraphStudio and GraphEdit to compare the graphs of WPF MediaKit with WMP/DShowPlayer. Unfortunately, I am unable to see any remote graphs with either of those programs. I registered the proppage.dll in Windows\SysWOW64 but that didn't help. I also tried registering quartz.dll. No luck either. For that reason, I am unable to compare the graph of WPF MediaKit vs. WMP/DShowPlayer.

Do you have any hint you could provide me? Great work on the WPF MediaKit, I'm just praying I can get DXVA to work. I don't feel like writing a native DirectShow player. :\

Thanks in advance!

Coordinator
Jun 8, 2010 at 10:42 PM
Windows Media Player and MediaElement may be using the MediaFoundation path and not using DirectShow at all.  Can you verify it is using your filter?

IIRC, Windows 7 comes with hardware accelerated h264 codecs..but not 100% sure.  Can you try out my blog post here and see if that helps?  http://jmorrill.hjtcentral.com/Home/tabid/428/EntryId/428/Missing-Windows-Media-DXVA-in-Windows-7.aspx

Also, mediakit needs to be built in debug for the remote graph to show up and you also must be running the same "bitage"...For instance, if you app is running as 32bit, make sure to run the 32 bit version of graphedit.

DXVA should work in MediaKit, though as my blog post suggested, there are some issues since Windows 7.

Let me know if this helps and if not..maybe we can try somethin else.

-Jer
Jun 10, 2010 at 4:35 PM

How would I verify what path MediaElement uses? As far as I know, MediaElement doesn't expose its graph. Regarding WMP, it's definitely using my DiVX H.264 filter because I'm seeing the exact same CPU usage between WMP and the DirectShow Player sample. Moreover, if I disable DXVA from the DivX Codec Settings, CPU usage goes high on both WMP and the DirectShow Player sample.

Your blog post concerns WMV DXVA, but H.264 DXVA, as explained above, works just fine with the proper decoder. It just doesn't seem to kick in with MediaUriElement. :\

As you suggested, I built the MediaKit in debug and yes, the graph showed up! It is indeed showing the same filter (DivX H.264 Decoder) as WMP and the DirectShow Player sample... but with way higher CPU usage and some dropped frames. :(

Any other ideas?

Best regards,
Alexandre

Jun 11, 2010 at 1:55 PM

There is a great DLL out there that, once registered, will allow you to use graphedt (or, better, GraphStudio) to spy on a dshow graph.

You can get GraphStudio from the author's blog:

http://blog.monogram.sk/janos/

 

You can find the DirectShow FilterGraph Spy on its author's blog:

http://alax.info/blog

 

Jun 23, 2010 at 4:01 PM

Hallo,

DXVA does not work.  

in the CustomPresenter-sample from MC is a bug. GetService to EVR to get the AccelerationService (IDirect3DDeviceManager9) from the Custom Presenter do not work. You can check it by:

bool IsDXVASupported(IBaseFilter evrfilter)

{

       IMFGetService service = evrfilter as IMFGetService 

 

       object objToCreate;

       int hr = service.GetService(MFServices.MR_VIDEO_ACCELERATION_SERVICE,

                      typeof(IDirect3DDeviceManager9).GUID, out objToCreate);

 

     IDirect3DDeviceManager9 devman = objToCreate as IDirect3DDeviceManager9;

     SafeRelease(devman);

 

     return hr == 0 ;

}

you get always null (NoImplemented). So all filters in the graph can't use DXVA (Software rendering for MPEG2/H.264/VC1).

I have modified the code, no it works. CPU-Load is the same for MPEG2 and H.264 but the video card activity grows up. It is tested with Cyberlik H.264 Filter and Microsoft DTV-DVD Video Decoder Filter.

 I don' know how to append the new code, say it and I send it.

SiggiK

sorry for my smal english

Jul 10, 2010 at 3:54 PM
Did you ever get DVXA Working with this kit? If so please post the code, or drop me an e-mail with it and I will post it for you, this DVXA issue is driving me nuts, any help with it would be great!
Jul 11, 2010 at 1:37 AM

I went the "sure way" and used DirectShow natively. Works flawlessly. :)

The Windows SDK even contains a fully functional player (DShowPlayer) that you can modify to suit your needs.

SiggiK apparently found the bug though.

Hope that helps.