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

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

问题描述

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



我已经环顾四周,并找到了几个包装器,如SharpFFmpeg( http://sourceforge.net/projects/sharpffmpeg/ )和ffmpeg-sharp( http://code.google.com/p/ffmpeg-sharp/ )。首先,我想使用ffmpeg-sharp作为其LGPL,而SharpFFmpeg是GPL。但是,它有相当多的编译错误。原来它是为单声道编译器编写的,我尝试用单声道编译,但无法弄清楚如何。然后,我自己手动修改编译器错误,但是遇到了一些可怕的错误,并且认为我最好不要这样做。所以我放弃了ffmpeg-sharp。



然后我看着SharpFFmpeg,它看起来像我想要的,所有的功能P /调用给我。但是它的GPL? AVCodec.cs和AVFormat.cs文件看起来像avcodec.c和avformat.c的端口,我认为我可以自己端口?然后就不用担心许可了。



但是,我想在开始编码之前就这样做。我应该:


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


  1. 端口avcodec.h和avformat.h(所有我需要?)到c#通过使用大量的DllImports并将其完全写入C#?

首先,我认为我不太在C ++,因为我很少使用它,但我知道足够绕开。我认为#1的原因可能是更好的选择是,大多数FFmpeg教程是在C ++中,我还将比内存管理更多的控制,如果我要在c#中执行。



你觉得怎么样?
你也会碰巧有使用FFmpeg的任何有用的链接(也许是教程)?

解决方案

其他一些
$ b



编写自己的互操作包装器在.NET中可能是一个耗时且困难的过程。为互操作编写C ++库有一些优势 - 特别是它允许您大大简化C#代码的接口。然而,如果你只需要一个图书馆的一个子集,那可能会使你的生活更容易在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.

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.

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. Write my own C++ library for interacting with ffmpeg, then have my C# program talk to the C++ library in order to play/convert videos etc.

OR

  1. Port avcodec.h and avformat.h (is that all i need?) to c# by using a whole lot of DllImports and write it entirely in 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#.

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

解决方案

a few other managed wrappers for you to check out

Writing your own interop wrappers can be a time-consuming and difficult process in .NET. There are some advantages to writing a C++ library for the interop - particularly as it allows you to greatly simplify the interface that the C# code. However, if you are only needing a subset of the library, it might make your life easier to just do the interop in C#.

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

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