2

Small background story:
A friend of mine and I are trying to make an arcade game simulator. We have got the 'wireframes' already set up (asset loading, gamestates, etc.), but we're completely stuck on video rendering.

Example (The pendulum / clocky-stuff you see in the background is a WMV3 lossless video, the rendering of this in the background w/ the UI in the foreground is what we are trying to achieve.

I've already tried using libraries other than SharpDX's mediafoundation (AForge, libvlc), but neither produced a proper result (AForge has no seeking functions and libVLC couldn't handle the video bitrate neither could I switch on HW acceleration in libvlc).

TL;DR Trying to render & decode high-bitrate 720p WMV3 video using SharpDX.MediaFoundation, utilising hardware accelerated decoding/rendering (D3D9 only)

Why D3D9?: Windows XP - Windows 10 compatibility, we're not very eager to use DX11.2 with MediaEngineEx, as this will drop support for Windows XP - Windows 7.

SharpDX MediaFoundation Docs (Looked at it myself, either I'm too dumb or it's too low-level code for me to understand)

What I currently have:

Rendering loop:

        Lib.Render += (RenderForm e) =>
        {
            GameStateManager.Draw();
        };

This event is called by:

    public static void Run(float drawRate = 60.0f, float updateRate = 60.0f)
    {
        DrawRate = drawRate;
        UpdateRate = updateRate;

        IsRunning = true;
        Begin = DateTime.Now;

        RenderLoop.Run(Window, () =>
        {
            Lib.BeginUpdate();

           OnUpdate();
            if (!IsResizing)
                OnRender();

            Lib.EndUpdate();
        });
    }

OnRender

This function makes part of a small library that is used to simplify SharpDX.Direct3D9 calls, which is initialised like this:

    public static DX9Device Initialise(int width = 1280, int height = 720)
    {
        Window = new RenderForm("Test");
        Window.ClientSize = new Size(width, height);
        Window.AllowUserResizing = false;

        TextureCache = new Dictionary<string, Texture>();

        DI = new DirectInput();
        D3D = new Direct3D();
        Device = new DX9Device(D3D, 0, DX9DeviceType.Hardware, Window.Handle, CreateFlags.HardwareVertexProcessing, new PresentParameters(Window.ClientSize.Width, Window.ClientSize.Height));

        KeyboardDevice = new Keyboard(DI);

        Window.ResizeBegin += Window_ResizeBegin;
        Window.Resize += Window_Resize;
        Window.ResizeEnd += Window_ResizeEnd;

        Foreground = new SharpDX.Direct3D9.Sprite(Device);
        Background = new SharpDX.Direct3D9.Sprite(Device);

        return Device;
    }

Might you need any more information to assist me with this issue, please do ask.

EDIT: Target framework is .NET 4 Client Profile

EDIT: I've tried this so far, but it gives a NullReferenceException on line "HDDevice dxvaDev_ = ...":

        public static void Initialise(DX9Device dev)
    {
        ContentDescription cd = new ContentDescription();
        Rational fps = new Rational();
        fps.Denominator = 1;
        fps.Numerator = 30;

        cd.InputFrameFormat = FrameFormat.Progressive;
        cd.InputFrameRate = fps;
        cd.InputWidth = 1280;
        cd.InputHeight = 780;
        cd.OutputFrameRate = fps;
        cd.OutputWidth = 1280;
        cd.OutputHeight = 720;


        HDDevice dxvaDev_ = new HDDevice(dev, cd, DeviceUsage.PlaybackNormal); //--> Why does this return null?!?!?!
    }

VideoHandler class (DX9Device is an alias for SharpDX.Direct3D9.DeviceEx)
This seems to be an internal issue.

EDIT: I will try Managed DirectX 9.0 for C#.
EDIT: Managed DirectX 9.0 for C# doesn't work out, disposing of the video when using RenderToTexture throws a NullReferenceException and Microsoft isn't offering worthy successors to their API.

EDIT: Now trying MediaFoundation for .NET (as of 01/dec/2015)

Arena
  • 360
  • 3
  • 10

0 Answers0