自定义 DirectShow 视频渲染器过滤器 - 动态分辨率更改
我有一个自定义 DirectShow 视频渲染过滤器
,它比Microsoft 的视频渲染过滤器
具有一些扩展功能,例如叠加图像。我知道我可以使用 Transform Filter
执行相同的操作,但我选择了这种方式。我还相信,使用 Transform Filter
我会遇到同样的问题,我将在下面描述。
当我使用Microsoft 的视频渲染器过滤器
时,它能够在流启动/更改时自动调整窗口大小和缓冲区大小。我的过滤器能够执行相同的操作,但不同的是,我无法在流启动后接收事件。我相信我可以以某种方式查询,但我不知道如何查询。
当前事件管道如下所示。
On Pin Connect
--------------
CreateInstance
Video Renderer Class Constructor
CheckMediaType
SetMediaType
-> Width: 100, Height: 100
CheckMediaType
CheckMediaType
CheckMediaType
SetMediaType
-> Width: 100, Height: 100
On Play
-------
StartStreaming
DoRenderSample
...
...
...
DoRenderSample
On Stop
-------
Video Renderer Class Destructor
我的源过滤器设置的默认窗口大小是 100x100。我可以通过引脚连接两次。但在 StartStreaming
之后,我无法再次获取 CheckMediaType
和 SetMediaType
事件。我可以尝试从源过滤器触发它们(这也是我的代码),但由于 Microsoft 的视频渲染器
能够在 StartStreaming
上自动调整大小,我希望拥有相同的功能。
问题:
- 流媒体开始后,我应该如何触发
CheckMediaType
/SetMediaType
调用?实际上SetMediaType
对我来说很重要。或者还有其他方法来查询当前流分辨率吗? - 我是否需要在
DoRenderSample
中连续检查可能的视频尺寸变化?
I have a Custom DirectShow Video Renderer Filter
which has some extended features over Microsoft's Video Renderer Filter
like overlay images. I know I could do the same with a Transform Filter
but I've chosen that way. I also believe, I would face the same problem with a Transform Filter
which I'll describe below.
When I use Microsoft's Video Renderer Filter
, it is capable of resizing the window and buffer sizes automatically when stream starts/changes. My filter is capable of doing the same but except, I'm unable to receive events after stream starts. I believe I can query somehow but I don't know how.
Current event pipeline is like below.
On Pin Connect
--------------
CreateInstance
Video Renderer Class Constructor
CheckMediaType
SetMediaType
-> Width: 100, Height: 100
CheckMediaType
CheckMediaType
CheckMediaType
SetMediaType
-> Width: 100, Height: 100
On Play
-------
StartStreaming
DoRenderSample
...
...
...
DoRenderSample
On Stop
-------
Video Renderer Class Destructor
Default windows size set by my source filter is 100x100. I'm able to get this on pin connect twice. But after StartStreaming
, I'm unable to get CheckMediaType
and SetMediaType
events again. I could try to trigger them from source filter (it's my code as well) but since Microsoft's Video Renderer
is capable of automatically resizing on StartStreaming
, I wanted to have the same feature.
Questions:
- How should I trigger
CheckMediaType
/SetMediaType
calls after streaming starts? ActuallySetMediaType
is the important one for me. Or is there another way to query current stream resolution? - Do I need to check for possible video size changes continuously in
DoRenderSample
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CheckMediaType
和SetMediaType
并不完全是“事件”,它们不会自行出现,因此您无法触发它们。你要改变决议吗?像VMR那样靠自己去扩展步伐?或者接受上游过滤器的分辨率更改?此 MSDN 部分涵盖详细信息:动态格式更改。
CheckMediaType
andSetMediaType
are not exactly "events", they don't come up on their own, so you cannot trigger them. Are you going to change resolutions? On your own to extend stride like VMR does? Or accept resolution changes from upstream filter?This MSDN section covers details: Dynamic Format Changes.