Using VMR9 for overlays

Mar 1, 2010 at 8:51 PM
Edited Mar 1, 2010 at 8:54 PM

Hello,

Thanks for this nice lib - it really fills the void of WPF media manipulation solutions.

I've been struggling with a rather simple scenario lately. I need a player that can be supplied with a bitmap (BitmapSource or GDI, no matter) which becomes an overlay for the video. Changes for the overlay are applied according to playback time (hence the need for a player, that spits events, like MediaUriElement). My understanding is that VMR, which is used in MediaUriPlayer, has mixing functionality that would do the job. I've also downloaded some samples to see how it's done using DirectShow.NET (http://sourceforge.net/projects/directshownet/files/DirectShowSamples/2010-February/DirectShowSamples-2010-February.zip/download, BitmapMixer sample). I'm using the following approach:

- Derive from MediaUriPlayer and MediaUriElement to create MediaOverlayPlayer and MediaOverlayElement respectively. The wpf control is modified to supply the bitmap to the player.

- Override player's OpenSource method: essentially copy all the code from MediaUriPlayer's version but get IVMRMixerBitmap9 from renderer and configure it at an appropriate stage.

Here's where things get problematic - if I configure IVMRMixerBitmap9 before the rendering loop (RenderEx on all pins), SetAlphaBitmap in mixer bitmap configuration returns HRESULT E_INVALIDARG, which msdn points to a bunch of reasons, none of which correspond to the invalid argument problem in this case. If the configuration occurs after the rendering loop, no errors occur, but no overlay is visible. In this scenario I'm using GDI bitmap as overlay. I've also tried using d3d surfaces (just like in the aforementioned example), but with identical effect.

I'm kinda stuck and I'm not even sure I'm approaching this problem correctly. Thanks for any and all help you can provide.

Coordinator
Mar 1, 2010 at 9:25 PM
Is there a reason for not just using WPF to overlay the bitmap over the video?

For example:

<Grid>
  <MediaUriPlayer.../>
  <Image Width="20"  Height="20" Source="..."/>
</Grid>

Mar 1, 2010 at 9:30 PM

Yes, I intend to record the output to another file.