在 .net 中使用 FFmpeg? [英] Using FFmpeg in .net?

查看:30
本文介绍了在 .net 中使用 FFmpeg?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我知道这是一个相当大的挑战,但我想使用 FFmpeg 库在 C# 中编写一个基本的电影播放器​​/转换器.但是,我需要克服的第一个障碍是将 FFmpeg 库包装在 c# 中.我已经下载了 ffmpeg 但无法在 Windows 上编译它,所以我为我下载了一个预编译版本.好棒.然后我开始寻找 C# 包装器.

So I know its a fairly big challenge but I want to write a basic movie player/converter in c# using the FFmpeg library. However, the first obstacle I need to overcome is wrapping the FFmpeg library in c#. I've downloaded ffmpeg but couldn't compile it on Windows, so I downloaded a precompiled version for me. Ok awesome. Then I started looking for C# wrappers.

我环顾四周,发现了一些包装器,例如 SharpFFmpeg (http://sourceforge.net/projects/sharpffmpeg/) 和 ffmpeg-sharp (http://code.google.com/p/ffmpeg-sharp/).首先,我想使用 ffmpeg-sharp 作为它的 LGPL,而 SharpFFmpeg 是 GPL.但是,它有很多编译错误.原来它是为单声道编译器编写的,我尝试用单声道编译它,但不知道如何编译.然后我开始自己手动修复编译器错误,但遇到了一些可怕的错误,并认为我最好不要管它们.所以我放弃了 ffmpeg-sharp.

I have looked around and have found a few wrappers such as SharpFFmpeg (http://sourceforge.net/projects/sharpffmpeg/) and ffmpeg-sharp (http://code.google.com/p/ffmpeg-sharp/). First of all, I wanted to use ffmpeg-sharp as its LGPL and SharpFFmpeg is GPL. However, it had quite a few compile errors. Turns out it was written for the mono compiler, I tried compiling it with mono but couldn't figure out how. I then started to manually fix the compiler errors myself, but came across a few scary ones and thought I'd better leave those alone. So I gave up on ffmpeg-sharp.

然后我查看了 SharpFFmpeg,它看起来像我想要的,所有功能 P/Invoked 为我.然而它的GPL?AVCodec.cs 和 AVFormat.cs 文件看起来像 avcodec.c 和 avformat.c 的端口,我认为我可以自己移植?那就不用担心执照问题了.

Then I looked at SharpFFmpeg and it looks like what I want, all the functions P/Invoked for me. However its GPL? Both the AVCodec.cs and AVFormat.cs files look like ports of avcodec.c and avformat.c which I reckon I could port myself? Then not have to worry about licencing.

但我想在我开始编码之前把它弄好.我应该:

But I want to get this right before I go ahead and start coding. Should I:

  1. 编写我自己的 C++ 库以与 ffmpeg 交互,然后让我的 C# 程序与 C++ 库对话以播放/转换视频等.

  1. 使用大量 DllImports 将 avcodec.h 和 avformat.h(这就是我需要的全部内容吗?)移植到 C# 中,并完全用 C# 编写?

首先考虑一下我不太擅长 C++,因为我很少使用它,但我知道的足够多.我认为 #1 可能是更好的选择的原因是大多数 FFmpeg 教程都是用 C++ 编写的,而且我对内存管理的控制也比我在 c# 中做的要多.

First of all consider that I'm not great at C++ as I rarely use it but I know enough to get around. The reason I'm thinking #1 might be the better option is that most FFmpeg tutorials are in C++ and I'd also have more control over memory management than if I was to do it in c#.

你怎么看?另外,您是否碰巧有使用 FFmpeg 的任何有用链接(也许是教程)?

What do you think? Also would you happen to have any useful links (perhaps a tutorial) for using FFmpeg?

推荐答案

原来的问题现在已经 5 年多了.与此同时,现在有来自 ffmpeg 的 WinRT 解决方案和来自 微软.

The original question is now more than 5 years old. In the meantime there is now a solution for a WinRT solution from ffmpeg and an integration sample from Microsoft.

这篇关于在 .net 中使用 FFmpeg?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆