HD video playback… WPF…

by benl

OK so it was naive to think the RTM of .NET 3.0 would magically fix our issues with HD video playback in WPF. The 1080p sample clip (which is representative of our final HD file specification) currently runs at around 1fps which probably isn’t ideal for screening content to television buyers.

Playing the content in a blank window hosting a MediaElement works OK, although even then it requires some fairly beefy video hardware but admittedly this is to be expected with HD content. The issue arises when playing the content in the context of our application.

To provide some background: the app loads all screens upon startup and transitions between them as-and-when necessary. Since all the application screens are running concurrently there is a moderate overhead for each screen, but surprisingly even when a screen isn’t the foremost/visible.

Admittedly i’m no expert when it comes to low-level implementation of WPF but it appears although the screens aren’t actually lighting pixels (i.e. visible) they’re still being composited, and this is the overhead we’re seeing. I can understand the reasons for this: by having visual elements paint from the back to the front of the display it simplifies and enables things like transparency and flexibility for clipping etc…

But not without a cost. Thanks to this, the application when sitting idle (although not strictly idle as we have timers running performing minor CPU-bound stuff) is using up about %30 CPU… Not major I hear you say but when we transition in the full screen video playback the CPU is pretty much pegged at 90%+ when playing our HD content, which then drops frames and induces headaches/nausea for anyone watching.