模拟电视流上的新闻字幕 - C#
我想使用 c# 在模拟电视流上放置新闻字幕,我可以使用 DirectShow 流式传输模拟电视,但我不知道如何将其与旋转文本混合,我应该创建一个过滤器吗?或者我必须使用 DirectShow 以外的其他技术?
I want to put a news marquee over an analog TV stream using c#, I can stream analog TV using DirectShow but I can't figure out how to mix it with rotating text, should I create a filter? or I have to use another technology than DirectShow?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
DirectShow 是执行此操作的最简单方法,但它确实有一些学习曲线,特别是来自 C#。维基百科页面为您提供了 DirectShow 的基本概述。
最新的 Windows SDK 中提供了 DirectShow 工具。使用 C++ 进行 DirectShow 编程更加简单,但您可以通过 COM 互操作或 DirectShow.net(我还没有尝试过)相当轻松地使用 DirectShow。如果使用 COM 互操作,以下文章会有所帮助:
http:// /blogs.msdn.com/b/ericgu/archive/2004/09/20/232027.aspx
如果动画性能足够流畅,您也许可以使用 VMR 叠加过滤器。请参阅以下文章
http://www.codeproject.com/KB/audio-video /VideoPicture.aspx
http://www.codeproject.com/KB/audio-video/Ticker.aspx
http://msdn.microsoft.com/en- us/library/dd407344(v=vs.85).aspx
或者,您需要编写自己的过滤器,该过滤器在每个帧上呈现文本,并与视频帧的时间戳同步调整其位置。如果您只需要在自己的应用程序中执行此操作,那么以下方法可能是最简单的
http://www.sichbo .ca/Free_Code/100_C_Sharp_directshow_filters
出于性能原因,微软官方建议应在 C++ 中创建 DirectShow 过滤器,但在 C# 中覆盖滚动文本应该没问题,因为如果您仔细编程,瓶颈将是用于覆盖文本的 API。
DirectShow is the simplest way of doing this but it does have a bit of a learning curve, particularly coming from C#. The Wikipedia page gives you a basic overview of DirectShow.
DirectShow tools are available in the latest Windows SDK. Using C++ for DirectShow programming is more straightforward but you can use DirectShow fairly easily via COM interop or DirectShow.net (which I haven't tried yet). If using COM interop the following article is helpful:
http://blogs.msdn.com/b/ericgu/archive/2004/09/20/232027.aspx
You may be able to use the VMR overlay filter if the animation performance is smooth enough. See the following articles
http://www.codeproject.com/KB/audio-video/VideoPicture.aspx
http://www.codeproject.com/KB/audio-video/Ticker.aspx
http://msdn.microsoft.com/en-us/library/dd407344(v=vs.85).aspx
Alternatively you will need to write your own filter that renders the text on each frame adjusting its position in synch with the time stamps of the video frames. If you only need to do this inside your own application then the following approach might be easiest
http://www.sichbo.ca/Free_Code/100_C_Sharp_directshow_filters
Microsoft officially recommend that DirectShow filters should be created in C++ for performance reasons but overlaying scrolling text should be OK in C# as the bottleneck will be the APIs used to overlay the text if you program carefully.
实际上,您不必编写过滤器来在视频上绘制一些文本。只需制作一个图表,其中未压缩的视频通过样本采集器(标准 DirectShow 过滤器之一),为样本采集器设置回调,您就可以在回调中修改视频数据。使用 DirectShow.NET 在 C# 中执行此操作非常容易,但由于编组而不是最佳选择。您可以首先在 GraphEditPlus 中构建这样的图表,然后它会向您显示 C# 或 C++ 的源代码如何构建此图并使用样本采集器。
Actually you don't have to write a filter to draw some text over your video. Just make a graph where uncompressed video goes through sample grabber (one of standard DirectShow filters), set up a callback for the sample grabber and you'll be able to modify the video data in your callback. Doing it in C# is very easy using DirectShow.NET but not optimal due to marshalling. You can first build such a graph in GraphEditPlus, then it will show you source code in C# or C++ of how to build this graph and use sample grabber.