FFmpeg_droidFix.AutoGen 8.1.0.1

dotnet add package FFmpeg_droidFix.AutoGen --version 8.1.0.1
                    
NuGet\Install-Package FFmpeg_droidFix.AutoGen -Version 8.1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FFmpeg_droidFix.AutoGen" Version="8.1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FFmpeg_droidFix.AutoGen" Version="8.1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="FFmpeg_droidFix.AutoGen" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FFmpeg_droidFix.AutoGen --version 8.1.0.1
                    
#r "nuget: FFmpeg_droidFix.AutoGen, 8.1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FFmpeg_droidFix.AutoGen@8.1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FFmpeg_droidFix.AutoGen&version=8.1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=FFmpeg_droidFix.AutoGen&version=8.1.0.1
                    
Install as a Cake Tool

FFmpeg auto generated unsafe bindings for C#/.NET.

What changed from original project:

As very beginning of making projectFrameCut, I selected this library to implement AV decoding/encoding, etc. because this thing can let me call FFmpeg and read out frame directly, by all C# Managed code, save my time and increase the speed. Also the alternative choice FFmpegKit has been discontinued at that time, and I don't want to take this risk of using something has no longer be maintainced.

When I'm trying to test projectFrameCut on Android, while I try to call this library on the Android platform, I found that I kept receiving the "PlatformNotSupportedException" error. After some diagnosis, I discovered that it was caused by the changes in .NET 5+ to System.OSPlatform. So that I fixed this file by use the modern System.OperatingSystem API, also I added a Function Resolver for Android. Finally this is fixed in the upstream repo, but it still could not be used on Android.

But, I found this is not the only problem while running on Android devices. After this fix, I start receive a "DllImportException" when I try to call the library, after days of fix, I finally discover why: "libdl.so.2" isn't exists on Android devices, and dlopen moved to "libc.so" instead of libdl. I also added a user-friendly exception processing telling why libraries failed to load.

I also added a property AddVersionSuffixToLibraryPaththat allows you to manually disable adding a version suffix to library names when attempting to load a library. This can resolve issues where certain platforms remove the version suffix when packaging the application.

This fork is fully compatible with the original FFmpeg.AutoGen library with only a little bit breaking change (after 8.0.0.1, before that is almost compatible).

This project is intended to fix the compatibility issues only on FFmpeg.AutoGen on Android, but I also add a lot of new features in the later release.

NuGet Version get the fork here

Breaking change from original project:

There is some breaking changes in this fork, but they are all optional and can be easily fixed by just set some properties before calling any FFmpeg functions.

Target runtime changed

The project now targets .NET 8.0+ instead of .NET Standard 2.0, which means it can only be used in .NET 8.0 or later projects. If you are using an older version of .NET, you can still use the original FFmpeg.AutoGen library, which is compatible with .NET Standard 2.0.

The main project worked on now changed

Now FFmpeg.AutoGen is the main project that works on, not the FFmpeg.AutoGen.Abstractions.

Another way to initialize the bindings:

In the original project, the bindings will be initialized and when any FFmpeg function is called for the first time, or by call DynamicallyLoadedBindings.Initalize(). In this fork, you can set DynamicallyLoadedBindings.EnableAutoInitialization to true to enable this behavior, or you can call DynamicallyLoadedBindings.TryInitialize() manually to initialize the bindings and validate the library versions before calling any FFmpeg functions.

Please note that DynamicallyLoadedBindings.EnableAutoInitialization is default to false, so you need to set it to true if you want to use this feature. Also, DynamicallyLoadedBindings.TryInitialize() will return a boolean value indicating whether the initialization and validation succeed, so you can check the result before proceeding.

To get the original behavior of DynamicallyLoadedBindings.Initialize() in upstream repo, Use these code:

if (DynamicallyLoadedBindings.FunctionResolver == null) DynamicallyLoadedBindings.FunctionResolver = FunctionResolverFactory.Create();
DynamicallyLoadedBindings.InitializeInternal();

The binding and version check system

There is a new binding check system in this fork, which will automatically validate the functions in the FFmpeg libraries against the expected functions defined in the code. If any function is missing or has a different signature, it will throw an exception with detailed information about the mismatch. This can help you to identify and fix any issues with the FFmpeg libraries you are using.

The check's result will be stored in ffmpeg.BindingVerificationResult, which is an instance of FFmpegBindingVerificationResult class. You can check the IsSuccess property to see if the validation succeed, and if not, you can check the Errors property to get a list of all the mismatches.

Also, the library version check will be performed during initialization, and it will compare the actual versions of the FFmpeg libraries against the expected versions defined in ffmpeg.LibraryVersionMap, as well as the target major and minor versions defined by TargetFFmpegMajorVersion and TargetFFmpegMinorVersion if DynamicallyLoadedBindings.ValidateReleaseVersion is true. If there is any mismatch, it will throw an exception with detailed information about the version mismatch. You can disable the version check by set DynamicallyLoadedBindings.EnableAutoValidation to false, but it's not recommended unless you know what you are doing, as it can lead to unexpected behavior if the FFmpeg libraries you are using are not compatible with the bindings.

AOT Compatibility

This fork is compatible with .NET's Native AOT support, which allows you to compile your application to native code. You don't need to do anything special to use this feature, except you'll need to manually set the native library path by set ffmpeg.RootPath to the directory where the FFmpeg libraries are located in Android or iOS-like platforms, as the we can't get the native library path by code in these platforms without using some platform-specific APIs.


Usage

DON'T FORGET TO Initialize the bindings before call any FFmpeg functions, either by call DynamicallyLoadedBindings.TryInitialize() manually or set DynamicallyLoadedBindings.EnableAutoInitialization to true to enable auto initialization when call any FFmpeg function for the first time.

The basic example of the library usage: video decoding, conversion and frame extraction to jpeg is included in FFmpeg.AutoGen.Example project.

You may check to example project it shows how specify path to libraries, anc call these libraries like decode video, convert it and extract frames to jpeg.

For the more sophisticated operations please refer to offical ffmpeg Documentation expecially API section of it.

The FFmpeg API is vast and complex and this project exposes it with minimum modifications - support is very limited.

Nuget packages version uses semantic versioning and in sync with MAJOR and MINOR version of FFmpeg as PATCH incremets does not changing API.

Per-Platform Usage

  • on Windows or linux or OSX(macOS):

    This library's MacOS usage usually only works in Console/Avalonia application (untested, but maybe work if you don't use MAUI as backend) , not MacCatalyst (see below for MacCatalyst)

    Native ffmpeg libraries are NOT pre bundled in this repository, not like the origin build. Obtain the binary by yourself, either by downloading from ffmpeg official website, by compiling it by yourself or from the package manager.

    Set ffmpeg.RootPath to manual specify the path to the directory where the FFmpeg libraries are located.

    Othwerwise the library will try to load them from the AppDomain.CurrentDomain.BaseDirectory.

  • on MacCatalyst and iOS-Like platform (iOS/iPadOS/tvOS/WatchOS/visionOS) in .NET MAUI:

    I haven't tested this yet. (I don't have a mac)

    Follow these steps to use this library on iOS-like platforms:

    1. add these code to any place in your app (suggested in MauiProgram.cs) before you call any FFmpeg functions:
    #if iOS || MACCATALYST || TVOS || WATCHOS 
    ffmpeg.RootPath = NSBundle.MainBundle.BundlePath;
    #endif
    
    1. Then, create a directory inside <your .NET MAUI project root path>/Platforms/iOS/, name it whatever you want. Create a folder named same as the FFmpeg libraries' ABI name (like arm64) your get/compile inside the folder your created. Put all .dylib files inside it, don't add any suffix or prefix.

    2. Add these things to the project's .csproj file:

    <ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
            <NativeReference Include="Platforms\iOS\<name of the directory your named>\**\*.dylib" />
    </ItemGroup>
    

    Don't forget to replace <name of the directory your named> to the name of the directory your named in 2nd step. Your project's file structure should like this:

    .
    |
    \---Platforms
        +---iOS
        |   |   ......
        |   |
        |   +---Assets
        |   +---ffmpeg
        |   |   \---arm64
        |   |           libavcodec.dylib
        |   |           libavfilter.dylib
        |   |           libavformat.dylib
        |   |           libavutil.dylib
        |   |           libswresample.dylib
        |   |           libswscale.dylib
        |   |
        |   +---Resources
        |   ......
        |
    ......
    
  • on Android (.NET MAUI):

    Follow these steps to use this library on Android:

    1. add these code to any place in your app (suggested in MauiProgram.cs) before you call any FFmpeg functions:
    #if ANDROID
    ffmpeg.RootPath = Android.App.Application.Context.ApplicationInfo.NativeLibraryDir;
    JavaSystem.LoadLibrary("c");
    #endif
    
    1. Then, create a directory inside <your .NET MAUI project root path>/Platforms/Android/, name it whatever you want. Create a folder named same as the FFmpeg libraries' ABI name (like arm64-v8a) your get/compile inside the folder your created. Put all .so files inside it, don't add any suffix or prefix.

    2. Add these things to the project's .csproj file:

    <ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
            <AndroidNativeLibrary Include="Platforms\Android\<name of the directory your named>\**\*.so" />
    </ItemGroup>
    

    Don't forget to replace <name of the directory your named> to the name of the directory your named in 2nd step.

    Your project's file structure should like this:

    .
    |   
    |
    \---Platforms
        +---Android
        |   |   ......
        |   |
        |   +---Assets
        |   +---ffmpeg
        |   |   \---arm64-v8a
        |   |           libavcodec.so
        |   |           libavfilter.so
        |   |           libavformat.so
        |   |           libavutil.so
        |   |           libswresample.so
        |   |           libswscale.so
        |   |
        |   +---Resources
        |   ......
        |
    ......
    
  • Other platforms (WebAssembly, .Net nanoFramework, Unity, etc.):

    1. Try to implement a IFunctionResolver for your platfrom.
    2. Set DynamicallyLoadedBindings.FunctionResolver to your implementation before call any FFmpeg functions, and call DynamicallyLoadedBindings.InitializeInternal, like this:
    var resolver = new YourPlatformFunctionResolver();
    DynamicallyLoadedBindings.FunctionResolver = resolver;
    DynamicallyLoadedBindings.InitializeInternal();
    

    Note that, if your platform use a different constant for EAGAIN, ENOMEM, EINVAL, or EPIPE from default (11 or 35 in iOS-Like, 12, 22, 32), You'll need to avoid use them. They've a fixed constant.

Generation

The bindings generator uses CppSharp.

Prerequisites:

  • Visual Studio 2022 with C# and C++ desktop development workloads and Windows SDK for desktop.

Steps to generate:

  • Run FFmpeg.AutoGen.CppSharpUnsafeGenerator;
  • All files with extension *.g.cs in FFmpeg.AutoGen project will be regenerated.

Origin content and License (picked)

main nuget

readme from original project

Important Announcement

This project is undergoing a transition to a semi-managed model over the coming months.

  • All existing packages and versions will continue to work - there will be no breaking changes to existing functionality
  • The project is now MIT licensed (changed from LGPL) - see LICENSE.txt for details
  • Contributions are welcome! If you'd like to help with the project, please feel free to contribute
  • The FFmpeg binaries continue to be distributed with their original licenses from the source

Founder & Maintainer: Ruslan Balanukhin (Rationale One)

For questions and support, please continue using stackoverflow.com or the questions repository.

Important

The FFmpeg API is vast and complex and this project exposes it with minimum modifications - support is very limited. Please consider to ask how to questions on stackoverflow.com or in special repository on github.com. The community may be able to offer some assistance but you will largely be on your own. As another option you can search for a solution in C(lang) as with some effort you can convert it to C#. Here repository with C# converted examples: https://github.com/stjeong/ffmpeg_autogen_cs

License

Copyright © 2025 Ruslan Balanukhin (Rationale One)
All rights reserved.

Distributed under the MIT License.
See LICENSE.txt for full license text.

Note: FFmpeg binaries are distributed under their original licenses (GPL/LGPL) from the source. Please refer to FFmpeg License for details.


License

The fork is created by hexadecimal0x12e. Copyright © 2025-2026 hexadecimal0x12e. All rights reserved.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
8.1.0.1 93 4/19/2026
8.1.0 84 4/18/2026
8.0.0 425 11/19/2025
7.1.1 191 10/14/2025