如何使用C#.Net和DirectX编写音视频播放引擎(综合分析)?

发布于 2024-12-25 13:29:08 字数 1069 浏览 1 评论 0原文

前提:

我在一家广播解决方案公司工作,我们从外部供应商购买播放sdk,这减轻了我们视频加载、渲染、播放等的负担。它为我们提供了许多功能,例如字符生成器,叠加图像、文本、flash (*.swf) 文件、流媒体等。我们主要关注应用程序开发(而不是技术开发)。因此,我们从 C# 代码到 SDK DLL 进行简单的 API 调用,例如播放、暂停、seal、覆盖等,这让我们的生活变得轻松。

同时我们还面临问题,因为 SDK 是由另一个国家的第三方提供的,因此支持的质量取决于他们。此外,他们添加的功能具有通用性,他们每两周发布一个新版本。他们的代码有很多错误。即使我们购买了他们的完整产品,我们也面临许可问题。


要求:

  1. 我们想要评估编写我们自己的播放/渲染引擎的选项 - 最初只有最低限度的功能,但从长远来看,我们会添加更多功能,例如覆盖图像或文本或 Flash swf文件、搜索、快进等。
  2. 我们还从硬件设备获取实时输入源,并通过硬件设备将视频源发送到电视,并将实时源记录在磁盘上。我们在实时输入和本地存储的视频文件之间切换。
  3. 我们需要播放各种类型的视频(快节奏、mp4、flv 等),因此我们还将依赖第 3 方编解码器。
  4. 我们可以使用不同的硬件卡进行输入和输出,并且需要迭代并获取可用的硬件配置。
  5. 我们从事 C# 工作,我们有经验丰富的 C# 开发人员,我们不想使用 C++ 进行开发,因为我们公司目前没有 C++ 专家。

问题:

  1. 我们的方法应该是什么 - 我们可以使用纯 C# 和 DirectX 11 编写具有上述功能的播放(这是正确的方法还是存在其他更好的方法)?
  2. 实现同样的目标有多容易或多困难(这是一个主观问题 - 主观答案就足够了)?
  3. 编写良好的 C# 代码是否比 C++ 代码慢(就 DirectX 和媒体播放而言,我可能需要为 NTSC 标准提供每秒最多 30 个视频帧)?
  4. 启动它的好方法(资源)是什么(包括概念和编码)?

这是一个综合性的问题,但您的专家建议将使我的方向和进步变得容易。

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 :

  1. 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.
  2. 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.
  3. We need to play all kinds of videos (quick time, mp4, flv, etc.) so we will also depend upon 3rd party codecs.
  4. We can use different hardware cards for input and output and will need to iterate through and get the available hardware configuration.
  5. 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 :

  1. 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) ?
  2. How easy or difficult is it to achieve the same (it is a subjective question - a subjective answer would suffice) ?
  3. 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) ?
  4. 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 技术交流群。

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

发布评论

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

评论(2

祁梦 2025-01-01 13:29:08

在参与过一个使用 C# 和 .NET 构建 3D 电视图形系统的项目后,我不得不说,是的,这绝对是可能的。

为了回答您的具体问题,

  1. C# 和 DX 11 (SlimDX) 绝对可以完成这项工作,我已经使用 DX 9 和能力较差的硬件完成了这项工作。
  2. 我想说,如果你以几乎不产生垃圾(GC 产生图形卡顿)的观点来解决这个问题,并采用一种非常数据驱动的动画方法(我们称之为模板),你就会看到这条路我指着。
  3. 是的,C# 代码具有封送开销,但可以通过减少对 DX 的调用次数和传递到其中的数据量来降低该成本。
  4. 请参阅答案 #2

希望这会有所帮助!

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,

  1. C# and DX 11 (SlimDX) can definitely get the job done, I have done this with DX 9 and hardware that was a lot less capable.
  2. I'd say if you were to approach the problem with the view of generating little to no garbage (GC produces graphical hiccups) AND taking a very data-driven approach for the animations (we called them templates), you'll see the road I'm pointing at.
  3. Yes, C# code has marshaling overhead, but it is possible to reduce that cost by reducing both the number of calls you make to DX and decreasing the amount of data you pass into it.
  4. See Answer #2

Hope this helps!

简单 2025-01-01 13:29:08

我建议使用 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.

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