水印+直播过滤器

发布于 2024-08-27 09:58:23 字数 106 浏览 7 评论 0原文

我想在我的视频上添加水印。是否可以使用 directshow 过滤器。 想要在视频上重叠图像,例如频道徽标。这样当视频播放时图像就会被固定。

请提供一些有价值的帮助或示例(VC++)

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++)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纵山崖 2024-09-03 09:58:23

我以前做过这个。你有两个选择。

  1. 使用 VMR-7 或 VMR-9 的混音器功能。我向你保证这看起来真的很难看,因为 VMR 滤镜根本无法进行 Alpha 混合。您的水印将具有粗糙边缘。

  2. 实现一个从 CTransInPlaceFilter 派生的过滤器类。

您实现以下方法:

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

在过滤器的构造函数中(或在图形运行之前调用的某些其他方法),从文件或资源加载水印。将图像文件的位图位保存到缓冲区中。

当调用 Transform 时,打开传入的 IMediaSample,访问其缓冲区,并使用双重嵌套 for 循环将水印的每个像素复制到图像的缓冲区中。

所有这一切的一个问题是您的输入源可能不是原生 RGB。例如,大多数网络摄像头都是 YUV 源(或更糟糕的是 MJPG)。通过将过滤器限制为仅接受 RGB 类型,将强制加载 DShow 颜色转换器过滤器。因此,额外的延迟可能会添加到您的图表中。至于 alpha 混合(如果你想要的话),你就得靠你自己了 - 你在其上位块传输的源缓冲区可能是没有 alpha 通道的 RGB24。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文