Note: these are early notes based on some initial experiments with the Silverlight 5 beta, apply a pinch of salt to what you read.
This is a simple one – I’d read that Silverlight 5 could now do hardware decoding of H.264 encoded video on Windows so I thought I’d give that a try.
I wanted a 1080p video so I did a quick search and came up with http://www.h264info.com/clips.html (I’ve no idea of the legality of these video clips by the way) and I downloaded the trailer for “The Bourne Ultimatum”).
This is 80MB of video clip, it runs for 1 minute 30 seconds and, according to Windows Explorer, it runs at 1920×816.
I first played the video in Windows Media Player where my machine was pretty much idle during the playback;
Note that this wasn’t some scientific test, I was just playing the video and other apps and services were definitely running on my machine and that might be some of the spikes there.
Next, I made a Silverlight 5 application and dropped the 80MB video onto the website that the application launches from and played it with a simple MediaElement;
<MediaElement Width="1920" Height="816" Source="trailer.mp4" />
and this is how Task Manager displayed it;
Clearly, this is costing me a bunch more CPU cycles than Windows Media Player was. I switched on GPU Acceleration for the plugin in my ASPX page;
and ran the video again;
it seemed a little lower but I suspect that’s a freak result. I switched on BitmapCache for my MediaElement;
and ran it again;
and that picture looks pretty good and settles down to practically not touching the CPU too much during the 90 seconds of that video.
At the point where I started this post, I wasn’t sure ( based on some docs that I’d read ) whether I’d have to explicitly switch on enableGPUAcceleration and CacheMode in order to get this functionality but, from the tests so far, it seems pretty conclusive that I do need to in the Silverlight 5 beta ( unless I’m seeing a false positive result here? ).