处理 DirectShow 中的动态格式更改
我只有简单的图表:
SourceFilter ---> CustomTransformFilter --> VideoRendererFilter
在我的CustomTranformFilter中,我动态更改视频属性:即我将视频重新调整为新的尺寸。
Input Video[1024,720]-->|CustomTransformFilter|--->Output Video[640,480]
但我的渲染器认为视频仍保持原始大小( [1024,720] 未重新缩放 [640,480] ) 我在视频渲染器上得到损坏的图像:因为渲染器尝试根据旧尺寸绘制新图像...
我该如何修复它?
最美好的祝愿
更新:
据我从戴维斯的回答中了解到:
Given: The graph is active, but the filters in question do not support dynamic
pin reconnections
戴维斯
Possible mechanisms for changing the format: (MSDN DirectShow Doc)
a. QueryAccept (Downstream)
b. QueryAccept (Upstream)
c. ReceiveConnection
建议使用 ReceiveConnection。 ReceiveConnection:当输出引脚建议格式更改为 它的下游对等体,并且新格式需要更大的缓冲区。 (MSDN DirectShow Doc)。
gmfbridge 示例“太复杂”,我无法弄清楚如何使用“ReceiveConnection”。 我是 DirectShow 的新手。
有人有使用 ReceiveConnection 机制响应动态格式更改的简单代码示例吗?
I just have simple graph:
SourceFilter ---> CustomTransformFilter --> VideoRendererFilter
In my CustomTranformFilter i change video properties dynamically:i.e i rescale video into new dimensions.
Input Video[1024,720]-->|CustomTransformFilter|--->Output Video[640,480]
But my renderer see the video as still in its original size ( [1024,720] not rescaled [640,480] )
And i get corrupted images at video renderer:Since renderer try to draw new image based on old dimensions...
How can i fix it?
Best Wishes
Update:
As i understand from Davies answer :
Given: The graph is active, but the filters in question do not support dynamic
pin reconnections
And
Possible mechanisms for changing the format: (MSDN DirectShow Doc)
a. QueryAccept (Downstream)
b. QueryAccept (Upstream)
c. ReceiveConnection
Davies suggest ReceiveConnection.
ReceiveConnection:is used when an output pin proposes a format change to
its downstream peer, and the new format requires a larger buffer. ( MSDN DirectShow Doc).
The gmfbridge example is "too complex" for me to figure out how to use "ReceiveConnection".
I am novice at DirectShow.
Any one has simple code example that use ReceiveConnection mechanism to respond dynamic format change?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 DirectShow 中进行动态类型更改的正常方法是将媒体类型附加到您提供的示例中。这不适用于视频渲染器,因为它正在分配样本。在从分配器获取样本之前,您需要请求更改类型。
您可以使用 ReceiveConnection 来执行此操作。您必须确保该分配器上没有未完成的缓冲区,然后您可以调用 IPin::ReceiveConnection (无需先断开连接)。 www.gdcl.co.uk/gmfbridge 的 gmfbridge 代码中的 BridgeSourceOutput::SwitchTo() 中有一个这样的示例。
G
The normal way to do a dynamic type change in DirectShow is to attach a Media Type to the sample that you deliver. This won't work with the video renderer, since it is allocating the samples. You need to request a change in type before you get the sample from the allocator.
You do this using ReceiveConnection. You must make sure that there are no buffers outstanding on that allocator, and then you can call IPin::ReceiveConnection (without disconnecting first). There is an example of this in the gmfbridge code at www.gdcl.co.uk/gmfbridge, in BridgeSourceOutput::SwitchTo().
G