English 中文(简体)
Hardware accelerated video in DirectShow / WinForms
原标题:

Currently prototyping a Windows .NET app that needs to play back high definition WMV and H264 video. My test files are full 1080p.

The target hardware has weak Atom processors but strong NVidia 9400 graphics. I know the graphics are integrated but my understanding is that they are good for video playback.

Testing on Windows 7, if I play my test files in WPF, using the MediaElement control, my CPU usage is 0.

However, target OS is Windows XP and we may not have .NET 3.0. Therefore the app needs to run in WinForms. For various reasons, Windows Media Player ActiveX is not an option. So we are looking at DirectShow.

I put together a player using DirectShow.NET, playing the video back full screen using the VMR9. Using this approach, my WMV files consume somewhere between 20 - 30% CPU. I had to install an mp4 muxer/demuxer to even get the H264 files to play, and then they consumed 40 - 50% CPU.

  • I know that Windows 7 supports H264 out the box. However, it seems it s not a DirectShow filter?
  • Why is my video accelerated using WPF, but not when using DirectShow? My understanding is that DirectShow supports DXvA.

tldr: how can I achieve hardware accelerated WMV and H264 video playback in WinForms?

Thanks!

问题回答

There are many commercial hardware accelerated h264 directshow filters available out there. Some use DXVA, some use Cuda. None of them are free, but most of them aren t expensive. Ffdshow and the related ffmpeg projects are great, but they will absolutely not do HD h264 on an Atom cpu. (If anyone can prove otherwise, I d love to hear from you.)

I ve been doing HD h264 playback on the same Ion platform that you described, using DirectShow in XP. It s borderline in performance for 1080p, but can manage it if you can limit the bitrate and don t need to do much other CPU or GPU work at the same time. 720p is a lot more comfortable, especially if you can get by with 24 or 30 fps instead of 60.

Off the top of my head, the codecs that worked best on the Ion for h264 were MainConcept, CoreAVC, and Cyberlink.

I would also suggest trying VMR7 instead of VMR9 if that s an option for you. Some DXVA codecs are more reliable and have better performance with VMR7.

Don t have a direct answer for you, but the DXVA checker utility has helped me debug DXVA issues in the past. Here is a download link: http://bluesky23.hp.infoseek.co.jp/en/index.html

I have done some checking with the DXVA utility recommended by Jeremiah Morill.

I have a pretty good idea of what s going on now....

  • I think the H264 support in Windows 7 is provided by MediaFoundation, which explains why my DirectShow app can t use it!
  • Running a WMV video using the DirectShow filter in Windows 7 provides different levels of performance depending on the renderer (VMR7 / VMR9 / EVR). The VMR7 is the least processor intensive (6 - 7% CPU) but worst quality, the EVR (8 - 12% CPU) is a little more efficient than the VMR9 (12 - 13% CPU) however they both look similar. However, the kicker is the MediaFoundation filter - which is obviously full accelerated and uses 0% CPU. Therefore I would guess that on Windows 7, the MediaElement uses MediaFoundation?

So the bottom line is that I need to test on a Windows XP box with the 9400 graphics. It looks like full hardware acceleration will not be possible (since we don t have MediaFoundation, and hence we don t have DXvA2)...

Thanks again for the help!





相关问题
Bring window to foreground after Mutex fails

I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...

How to start WinForm app minimized to tray?

I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Apparent Memory Leak in DataGridView

How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

WPF-XAML window in Winforms Application

I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.

热门标签