如何使用C#.Net和DirectX编写音视频播放引擎(综合分析)?
前提:
我在一家广播解决方案公司工作,我们从外部供应商购买播放sdk,这减轻了我们视频加载、渲染、播放等的负担。它为我们提供了许多功能,例如字符生成器,叠加图像、文本、flash (*.swf) 文件、流媒体等。我们主要关注应用程序开发(而不是技术开发)。因此,我们从 C# 代码到 SDK DLL 进行简单的 API 调用,例如播放、暂停、seal、覆盖等,这让我们的生活变得轻松。
同时我们还面临问题,因为 SDK 是由另一个国家的第三方提供的,因此支持的质量取决于他们。此外,他们添加的功能具有通用性,他们每两周发布一个新版本。他们的代码有很多错误。即使我们购买了他们的完整产品,我们也面临许可问题。
要求:
- 我们想要评估编写我们自己的播放/渲染引擎的选项 - 最初只有最低限度的功能,但从长远来看,我们会添加更多功能,例如覆盖图像或文本或 Flash swf文件、搜索、快进等。
- 我们还从硬件设备获取实时输入源,并通过硬件设备将视频源发送到电视,并将实时源记录在磁盘上。我们在实时输入和本地存储的视频文件之间切换。
- 我们需要播放各种类型的视频(快节奏、mp4、flv 等),因此我们还将依赖第 3 方编解码器。
- 我们可以使用不同的硬件卡进行输入和输出,并且需要迭代并获取可用的硬件配置。
- 我们从事 C# 工作,我们有经验丰富的 C# 开发人员,我们不想使用 C++ 进行开发,因为我们公司目前没有 C++ 专家。
问题:
- 我们的方法应该是什么 - 我们可以使用纯 C# 和 DirectX 11 编写具有上述功能的播放(这是正确的方法还是存在其他更好的方法)?
- 实现同样的目标有多容易或多困难(这是一个主观问题 - 主观答案就足够了)?
- 编写良好的 C# 代码是否比 C++ 代码慢(就 DirectX 和媒体播放而言,我可能需要为 NTSC 标准提供每秒最多 30 个视频帧)?
- 启动它的好方法(资源)是什么(包括概念和编码)?
这是一个综合性的问题,但您的专家建议将使我的方向和进步变得容易。
Premise :
I work for a broadcast solution company and we buy the playout sdk from an external vendor, this reduces our burden of video load, rendering, play, etc. It provides us with numerous features like character generator, overlaying image, text, flash (*.swf) files, streaming, etc. We mostly focus on application development (not technology development). So we make simple API calls from our C# code to the SDK DLLs like play, pause, seak, overlay, etc. and it makes our lives easy.
Meanwhile we also face issues because the sdk is provided by a 3rd party in another country and so the quality of support depends upon them. Also the feature addition done by them is of generic nature and they give a new release every fortnight. Their code has lots of bugs. We also face licensing issues even when we have bought their full product.
Requirements :
- We want to evaluate the option of writing our own playout / rendering engine - initially with bare minimum features but in the long run we would add more features to it like overlaying an image or text or flash swf file, seeking, fast forward, etc.
- We also take live input feed from hardware devices and send the video feed out to Tv through hardware devices and record live feeds on disk. We switch between live input and locally stored video files.
- We need to play all kinds of videos (quick time, mp4, flv, etc.) so we will also depend upon 3rd party codecs.
- We can use different hardware cards for input and output and will need to iterate through and get the available hardware configuration.
- We work on C# and we have experienced developers on C# and we do not want to use C++ for development as we do not have a C++ expert in our company currently.
Questions :
- What should be our approach - can we write a playout with mentioned features using pure C# and DirectX 11 (is it the right way or some other better way exists) ?
- How easy or difficult is it to achieve the same (it is a subjective question - a subjective answer would suffice) ?
- Is a well written C# code slower than a C++ code (with respect to DirectX and media playout where I may need to deliver up to 30 video frames per second for NTSC standards) ?
- What is a good way (resource) to start it (including the concepts and coding)?
It is a comprehensive question but you expert advise will make my direction and progress easy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在参与过一个使用 C# 和 .NET 构建 3D 电视图形系统的项目后,我不得不说,是的,这绝对是可能的。
为了回答您的具体问题,
希望这会有所帮助!
Having worked on a project where I built a 3D television graphics system using C# and .NET, I have to say yes, this is definitely possible.
To answer your specific questions,
Hope this helps!
我建议使用 MS Expression Encoder SDK - 非常非常易于使用,有一个非常有用的示例代码。
如果您坚持使用 DirectShow,那么DirectShow 到 .NET 的端口效果非常好。这是一个教程,展示了如何使用它。
I would recommend working with MS Expression Encoder SDK - very, very easy to use, has a a very useful sample code.
If you insist on working with with DirectShow there is a DirectShow port to .NET that works pretty good. Here is a tutorial, showing how to work with it.