views:

181

answers:

1

I want to put a watermark on my video. IS it possible to do with directshow filter. Want to overlap an image on video like channel logo. so that image will be fixed when video is playing.

Please provide some valuable help or samples (VC++)

A: 

I've done this before. You have two options.

  1. Use VMR-7 or VMR-9's mixer capabilities. I guarantee you this will look real ugly, because VMR filters can't do alpha blending at all. Your watermark will have rough edges.

  2. Implement a filter class that derives from CTransInPlaceFilter.

You implement the following methods:

  CheckMediaType   (accept all RGB formats)
   SetMediaType     (accept all RGB formats)
   Transform        (this is where you do the overlay)

In your filter's constructor (or on some other method that gets called before the graph runs), load your watermark from file or resources. Save the bitmap bits of the image file into a buffer.

When Transform gets called, crack open the IMediaSample that's passed in, access its buffer, and have a double-nested-for loop to copy each pixel of the watermark onto the buffer of the image.

One problem with all of this is that your input source may not be native RGB. Most webcams for example are YUV sources (or worse, MJPG). By constraining your filter to only accept RGB types will force the DShow color converter filters to load. As such, extra latency may get added to your graph. As for alpha blending (if you want it), you are on your own here - the source buffer you are blitting on top of will likely be RGB24 with no alpha channel.

selbie