Pointless

Jul 10, 2010 at 2:52 PM
Edited Jul 10, 2010 at 2:55 PM
So I was quite impressed with this kit, at least until I dove deeper into the code, but as the post previous to mine suggests DXVA does not work in WPF Media kit. This makes the kit completely pointless, as the media-element inside VS renders video about 6 times faster than this kit can. Everything else the kit can do can be done with the DirectShowLibary. So I fail to understand why anyone would want to render video with this issue not being fixed, it seems like a big problem, I have tried to fix this but it's slow going for the time being, if I do get it working I will post an update. I notice that the previous post might have gotten the code working with DXVA but he didn't know how to upload the source? But no one seems to have gotten back to him (I will reply in a moment). So FYI in the mean time to anyone looking at this kit, it might be off little uses to you because its a CPU hog, I have confirmed this on 6 Dev computers, Running Server 2008, Server 2008 R2, and Windows 7, done with x86 and 64 Bit OS, its the same results with each PC, (File I am Rendering is a WMV). A video that would normal use 3 - 6 % CPU usage with Media-element takes about 35 - 30 % with this kit (EVR or VRM9) It's a shame because the rest of the kit is really nice. Regards UHAX
Jul 10, 2010 at 2:55 PM
Reorder!
Jul 10, 2010 at 3:28 PM

Hi UHAX,

Can you describe how you verified that DXVA not working is the cause of the CPU performance problem?

Jeremiah pointed me to his blog on this matter.  http://jmorrill.hjtcentral.com/Home/tabid/428/EntryId/428/Missing-Windows-Media-DXVA-in-Windows-7.aspx

He also explained that actually there is some additional overhead in this kit related to Direct 3D.

Could this be the cause of the overhead problem you are seeing?

With regard to "pointless". I must disagree.

Even with the overhead (not 10x, but something reasonable) this kit is extremely useful because it enables you to add the power and flexibility of WPF layout to any DirectShow graph that uses screen rendering.

I would be very interested to hear more on your performance metrics, because, of course, despite all its advantages, it is critical in video applications

David

Coordinator
Jul 10, 2010 at 10:56 PM
UHAX, The WPF MediaKit does support DXVA. This is why it uses the D3DImage for WPF interop. The problems you are having are related with Windows. Microsoft is slowly moving away from DirectShow and have some migration pains (as you've noticed). Any Windows version after Vista, you will get better out-of-the-box luck with DXVA in MediaFoundation. MediaKit does support MediaFoundation via the EVR presenter, but you will have to make a player for it. As David pointed out with a link to my blog post, WMV hw acceleration is disabled on some Windows machines. I can currently play WMVs on my machine at the same CPU usage as Windows Media Player. Again, as David said, the MediaKit is more than playback of WMV. TV Tuners, DVD Players, Webcams, etc. Though not everything is perfect with the project, some people find it useful...and it is open source for a reason. Should something not work right, you have the opportunity to fix it. The downside is you first must have the inclination and/or the intelligence to do so. I'm not sure which is true in your case. I'm only one person with a full-time job and felt this was something I wanted to share. If you don't like it, don't use it. -Jer
Jul 13, 2010 at 8:23 AM

Thanks for the reply guys, but I dont think this is just over head. As I have said I have tested this on 3 computers, each PC is new, each PC is dual boot with the 86 and 64 bit (aside from the R2 64 bit only), so I have tested this on Windows Server 2008, Windows Server 2008 R2 and Windows 7

 

In each case the CPU load is very high, in comparison to WMP or the MediElement, each of these uses about 3 - 6 % CPU usage, however when I used the MediaKit it jumps to about 35%. So something much be quite off, I should add that I am not doing anything with the code, I am just using the samples provided, I have not edited them in anyway.

Each PC has all the Windows updates, and Nvidia 8800 GTX cards (512mb) with the newest drivers installed.

I will do more tests, I will try patch into the graph as explained in another thread and try confirm that the issue s with the DVXA but I fail to see at this point what else could possibly be causing the issue!

 

Regards

Coordinator
Jul 13, 2010 at 9:31 PM
I don't think comparing WMP and the built in players in MediaKit is a correct. WMP (and MediaElement) use MediaFoundation for playback of a WMV file, not DirectShow. As I eluded to before, Microsoft has some migration issues moving to MF and a lot of computers by default have DXVA in DirectShow disabled by default. If you want to use MediaFoundation, you just have to create a player and use the MediaKits EVR presenter. If you want to do a proper comparison, use the graphedit utility from the Windows SDK and use the VMR9 renderer. You will have very similar CPU usage as MediaKit. The only fix to this I have found is that link ( http://jmorrill.hjtcentral.com/Home/tabid/428/EntryId/428/Missing-Windows-Media-DXVA-in-Windows-7.aspx ) to my blog. Also, test MediaKit in windows Vista where there were no DXVA issues with DirectShow and you will see it is using DXVA out of the box. I've never tested MediaKit on server versions of Windows, but my experience with server versions is they aren't configured out of the box to do much with the GPU. -Jer
Jul 14, 2010 at 5:12 PM
Edited Jul 15, 2010 at 7:20 AM

Hi,

DXVA by using EVR with the CustomPresenter not works properly. Same changes i have done:

    * redirection of getService MR_VIDEO_ACCELERATION_SERVICE to the D3DPresentEngine
    * implement GetNativeVideoSize(SIZE* pszVideo, SIZE* pszARVideo) and
    * the colorspace is set to normal (0-255)

The CPU-usage is changed from 29% to 9% with the same video (1080i coded AVC1)  after replace with the new EVRPresenter.dll by using the SampleApplication. The filters in the Graph must support hardwaredecoding (DXVA). MS-Filter in Windows 7 do this.

You can find it the dll and the source http://home.vrweb.de/~siegfried.krueger/MediaKIT/

SiggiK

 

Sep 19, 2010 at 5:15 PM

Hi,

now  i have made based on the Microsoft Sample a new EVR-Presenter. More methods are implementet for some interfaces and so work

 - DXVA  (if filters support this)
 - Mouse in DVD-Navigator
 - GetCurrentImage(..) from IMFVideoDisplayControl

There is a sample to get the CurrentImage in WPF:

    /// <summary>
    /// Get the Image from Presenter
    /// (dspControl is the IMFVideoDisplayControl from EVR-Renderer)
    /// </summary>
    /// <returns></returns>
    override public BitmapSource GetCurrentImage()
    {
        BitmapInfoHeader bih = new BitmapInfoHeader();
        bih.Size = Marshal.SizeOf(bih);

        // Ptr to ImageData
        IntPtr scan0 = IntPtr.Zero;
        int imagesize = 0;
        long tStamp = 0;

        try
        {
            int hr = dspControl.GetCurrentImage(bih, out scan0, out imagesize, out tStamp);
            if (hr != 0 || imagesize == 0)
                return null;

            PixelFormat pixelFormat = PixelFormats.Pbgra32;

            // we need to know beforehand details of our bitmap
            int stride = bih.Width * (bih.BitCount >> 3);
            switch (bih.BitCount)
            {
                case 24: pixelFormat = PixelFormats.Rgb24; break;
                case 32: pixelFormat = PixelFormats.Pbgra32; break;
                case 48: pixelFormat = PixelFormats.Rgb48; break;

                default: throw new DirectShowException("Unknown BitCount");
            }

            // Create the BitmapSource.
            return BitmapSource.Create(bih.Width, bih.Height, 96, 96, pixelFormat, null, scan0, imagesize, stride);
        }
        finally
        {
            if (scan0 != IntPtr.Zero)
                Marshal.FreeCoTaskMem(scan0);
        }
    }

You can use this EVR-Presenter without install the DirectX Redistributable Package!

You can find the dll and the source http://home.vrweb.de/~siegfried.krueger/MediaKIT/

SiggiK

Nov 2, 2010 at 10:44 AM
Edited Nov 2, 2010 at 10:46 AM

Hi,

Any plan on integrating SiggiK's work on Codeplex if it works ?

btw. I really love this project, I use it for my pet project, and I'm really grateful !

 

thanks Jer for this, and keep up the hard work :)

-Fabio