-
-
Notifications
You must be signed in to change notification settings - Fork 315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create supporting nuget package with latest LGPL binaries for Windows. #64
Comments
@qmfrederik could you please elaborate the rational need of this. |
@Ruslan-B Thanks for the fast response! Well - at the root of the issue is that I'm using libav, not ffmpeg, though they are very (but not totally) compatible. I prefer libav because they publish LGPL binaries, whereas ffmpeg provides (by default) GPL binaries. Another use case would also be upgrading to a newer version of ffmpeg - they may bump the API version if they add new functions or remove deprecated functions, but bindings for a lower API version should still work, as long as you're not using the deprecated functions. The same may also hold true if you're developing an assembly which you want to run on different Linux distributions which may include different versions of ffmpeg. Ideally you are compatible with the different ffmpeg versions which ship out of the box on your Linux distribution, as long as you (the developer) make sure the functions you call are present on all versions of ffmpeg you want to target. I know it's a stretch, but wanted to share the approach just in case :). |
@qmfrederik okay, I got you point it is indeed interesting to know. However, I see few problems which can be address I a slightly different way. With respect to next version of ffmpeg I already have the nuget package my intention is to update it for every major/minor release it going to be sufficient. Distribution on Linux should not be a problem at all as ffmpeg has packages and you can install required version or if you brave enough you just can symlink installed version to any other. |
That would a great idea :-). I maintain a couple of packages that distribute binaries (mostly .dll's on Windows & .dylib's on macOS) via NuGet. It becomes really easy when you're targetting .NET Core or newer NuGet versions. In that case, you just need to put the native files in the If you want to target Desktop .NET, you'll also need to provide a |
Ok then I'll rename this issue, I have plans to do so during next week. |
Awesome, thanks! |
It appears it is quite a problem to build stable version of ffmpeg (3.3). |
@Ruslan-B I'm experimeting with a Travis project which cross-builds ffmpeg for Windows on Ubuntu and packages that in a NuGet package - see http://github.com/qmfrederik/ffmpeg-win32 |
@qmfrederik it is awesome! It appears I took quite complex route. However, I tried the package (r30) and didn't manage to open any file or uri it fails with the |
@Ruslan-B DId you use the FFmpeg.Native.H264 package? That one is built from the h264-only package and only contains the h264 decoder (because that's the part of ffmpeg we're using in our software). I'm building a FFmpeg.Native package as well, I'll try to upload that later today so you can give it a try. As a note, I've noticed that the GPL build of FFmpeg for Windows links with all possible dependencies. If you want to do that, you'll need to compile each of them and include it in the NuGet package. So I kind of took a shortcut by not linking with any external FFmpeg dependency. The gnutls dependency is a dependency which caused quite some trouble for me (because it has a lot of other dependencies); in the end it turns out that you don't really need to use gnutls on Windows because FFmpeg can use the standard Windows cryptography APIs. So if you ever want to build a FFmpeg package which is more complete than mine - just remember that gnutls isn't really required. I'll keep you updated in this thread. If you want to publish a package with the runtime dependencies (or take ownership of FFmpeg.Native), that'd be fine with me, too. |
@qmfrederik thank for the update! Yes, used the FFmpeg.Native.H264 package so it explains. |
@Ruslan-B I pushed a package with x64 LGPL binaries here (free of charge 😄 ): https://www.nuget.org/packages/FFmpeg.Native. It may take a couple of minutes for NuGet to index it but it should be there soon. I also updated the README file with a list of all options which are included. Let me know if it works for you! |
@qmfrederik works like a charm! I think some minor twinks can be done like put semantic version and throw a way binaries from this repo and update read me but this package is really big step forward. |
I got strange error while starting NET Core 2.0 console application:
but why library is trying to load avformat.57 instead avformat-57? csproj
|
@hey-red what platform are you running on? |
@Ruslan-B My apologies, I thought this library doesn't use LoadLibrary and works out of box with FFmpeg.Native. |
It appreas to be true they are not working out of box. I wonder how @qmfrederik uses FFmpeg.Native package. As .NET Core host does not extract native dlls from the package. |
I currently use the FFmpeg.Native package which only includes the H264 codecs. That said, native library loading is being improved in .NET Core. dotnet/corefx#17135 describes a new API which has been approved today and will land soon. It's probably best to wait for this to land & build on that one. |
Thanks for clarifying. |
In case someone is also struggling to build a valid LGPL ffmpeg build for Windows x64/x86, there is this fantastic piece of work on github which is called media-autobuild_suite. These scripts do basically all the work for you and provide many customization features for all kind of ffmpeg features like openh264 and many more. |
If you want to build a specific version of FFmpeg to use it in FFmpeg autogen you can do this by editing the media-suite_compile.sh script. |
For using <ItemGroup>
<None Include="$(NuGetPackageRoot)ffmpeg.native\1.0.0-r31\runtimes\win7-x64\native\*.*">
<Link>runtime\%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup> Edit the paths if other versions of |
Looks like a good workaround. Nevertheless, we have and issue here quamotion/ffmpeg-win32#2 to automate the process. I had a plan to add an extra target file to package to do this automatically. |
Closing this issue as irrelevant to project as seems supporting package never going to meet all users requirements. So if you don't like GPL binaries you need to build your own very special version of FFMPEG any way. |
The P/Invoke declarations currently link to a specific version of the FFmpeg/libav libraries, like this:
For example, libav 11.7 includes
avcode-58
instead ofavcodec-57
, so you can't use FFmpeg.AutoGen with libav 11.7 (although they are fairly API-compatible). And dllmap isn't an option, as .NET (Core) doesn't provide dllmap support.You could workaround this by manually loading the functions. An example of how this is done, can be found in the .NET Core source code.
You would first:
dlopen
orLoadLibrary
); see https://github.com/dotnet/corefx/blob/bc9a9d7ed76053c9b7a5ffad6707002ff7a815db/src/System.Drawing.Common/src/System/Drawing/GdiplusNative.Unix.cs:L19I believe you use ClangSharp to auto-generate the P/Invoke code so I assume it could be amended to use this logic, providing a bit more of flexibility to the users of this library so to which dlls are exactly loaded.
The text was updated successfully, but these errors were encountered: