用于视频播放的.NET FFmpeg 包装器

发布于 2024-11-23 20:15:00 字数 1539 浏览 7 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(6

遗忘曾经 2024-11-30 20:15:00

有一个很好的解决方案可以将 FFmpeg 绑定到 C# 中。使用 FFmpeg.Autogen 来自:
https://github.com/Ruslan-B/FFmpeg.AutoGen
它还在下载源代码时提供了一个很好的示例(并且它附带了适用于 32 位和 64 位的预编译 ffmpeg)!

There is a great solution for binding FFmpeg into C#. Use the FFmpeg.Autogen from:
https://github.com/Ruslan-B/FFmpeg.AutoGen.
It also provides a good example when downloading the source (and it comes with precompied ffmpeg for 32 and 64 bits)!

廻憶裏菂餘溫 2024-11-30 20:15:00

据我所知,没有干净的方法可以通过 P/Invoke 从 C# 使用 ffmpeg,因此所有这些包装器都是不完整的项目。您可以做的是创建一个 ffplay.exe 的进程(在共享版本下下载)并传递命令行参数。否则我建议使用 WPF 或 Silverlight MediaElement,具体取决于您的需求;它对大多数基本任务(例如视频和音频播放)有相当不错的支持。

From what I know, there's no clean way to utilize ffmpeg from C# via P/Invoke, hence all these wrappers are incomplete projects. What you can do is to create a process to ffplay.exe (download under shared builds) and pass command line arguments to it. Otherwise I suggest using WPF or Silverlight MediaElement, depending on your needs; it has a pretty decent support for majority of basic tasks like video and audio playback.

临风闻羌笛 2024-11-30 20:15:00

您看过VLC 媒体播放器了吗?它是一个功能齐全的媒体播放器,使用 FFmpeg 项目的编解码器。您可以利用它的核心功能,SourceForge 上有一个最近更新的包装器项目以及关于代码项目(如果您想创建自己的项目)。我个人没有使用过其中任何一个,但它们看起来相当容易使用。

Have you looked at VLC Media Player yet? It is a full featured media player that uses the codecs from the FFmpeg project. You can make use of it's core functionality and there is a recently updated wrapper project on SourceForge and a tutorial on The Code Project if you want to create your own. I haven't used either of these personally, but they look fairly straight forward to use.

巨坚强 2024-11-30 20:15:00

我不认为这样的事情存在,坦率地说 ffmpeg API 仍然有些不稳定,所以即使今天有一些东西可以满足您的需求,但 2 年后它也有可能不再工作/保持更新日期。此外,在托管代码和本机代码之间编组数据相对昂贵。 99% 的情况下这并不重要,但在处理媒体(尤其是未压缩的视频帧)的情况下,它可能会对性能产生明显的影响。

在我看来,从 C# 处理 ffmpeg 的最佳方法是用 C 编写交互逻辑,并公开可以从 C# p/调用的更高级别的 API。如果有适当的低级包装器可用,情况仍然如此。

I don't think such a thing exists and frankly the ffmpeg API is still somewhat unstable, so even if there is something today that meets your needs there is a not insignificant chance that 2 years later it will no longer work/be kept up to date. Furthermore, marshaling data between managed and native code is relatively expensive. 99% of the time this doesn't matter, but in the case where you are dealing with media (especially uncompressed video frames) it can have a noticeable performance impact.

IMO the best way to deal with ffmpeg from C# is to write your interaction logic in C and to expose a higher level API that you can p/invoke to from C#. This would still be the case if there was a proper low level wrapper available.

找回味觉 2024-11-30 20:15:00

我非常确定稳定的专有包装器确实存在

去年年底我自己花了很多时间寻找一个,但没有成功。

I'm quite sure that stable proprietary wrappers do exist

I spent a good deal of time late last year looking for one myself, without success.

愁以何悠 2024-11-30 20:15:00

目前,还没有稳定的解决方案,因此最好的想法可能是等到有人完成它。

Currently, there is no stable solution for this, so the best idea probably is to wait until someone completes it.

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