4

I am trying to find a way to render video in WPF with lower CPU usage than MediaElement. The goal is smooth and low CPU video playback as much as Direct3D/DirectDraw video rendering in C++ programming.

I tried Direct2D(with WindowsAPICodePack) to render video, and the result is CPU usage is pretty low, but the problem is that I have no way to render video smoothly since there's no accurate timer to update video at exact time like DirectX in C++.

Maybe I need to go back to C++ world to use Direct3D natively and hosting C++ with DirectX window in C# WPF window. Even though I don't know what will happen with that, it may worth to try, I guess.

If you guys have any advise, please let me know.

Aki24x
  • 1,058
  • 1
  • 13
  • 28

1 Answers1

1

You could try writing a small XNA app to render the video and embed that into your winform

Adrian Grigore
  • 33,034
  • 36
  • 130
  • 210
  • Thanks Adrian, I tried some with your advise. Then, finally I used Direct3D w/C++ to render video into Win32 window and embed into WPF window. It's pretty smooth and low CPU usage. Seemingly there's no way to update each frame at exact timing to match to actual frame rate in C#. And it makes video un-smooth since the frame rate is fixed unlike realtime rendering pictures such as video games. Again, thanks to your good advise. =) – Aki24x Feb 06 '11 at 08:39
  • I ended up doing this using DirectShow.NET and BitBlt / CreateCompatibleDib within managed code (p/invoke), while rendering on a separate thread. This gives great performance (rendering 3000x1080 at 200+ FPS). BitBlt is the fastest method to push pixels at least from what I have encountered. – Dennis Smit Mar 15 '11 at 21:26
  • Hi Dennis, that sounds very nice! How about CPU usage? I wanted to make very low-light renderer as same as overlay (like DDraw) because my renderer will be used for showing preview while doing time-critical tasks. However, 3000x1080 at 200+ FPS is really impressive! =D – Aki24x Mar 24 '11 at 05:50