Skip to content

About

Low-level, ABI-focused .NET bindings for FFmpeg, providing direct access to native structures, functions, callbacks, constants, and macros with minimal abstraction. Designed for performance, cross-platform ABI correctness, and Native AOT compatibility.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

Flyleaf.FFmpeg.ABI

Low-level, ABI-focused .NET bindings for FFmpeg.

Flyleaf.FFmpeg.ABI provides direct access to FFmpeg's native structures, unions, functions, callbacks, constants, macros, and supported inline functions with minimal abstraction.

The bindings are generated with ClangABI directly from the FFmpeg C headers, with an emphasis on ABI correctness, performance, portability, and Native AOT compatibility.

Features

  • Direct, low-level access to the FFmpeg C API
  • Native structures and unions with ABI-correct layouts
  • Functions, callbacks, constants, macros, and supported inline functions
  • Fixed-size and inline arrays
  • Native function pointers and callback signatures
  • Cross-platform native type handling
  • FFmpeg hardware-context headers included
  • Supporting SDK headers included during generation where required
  • Minimal abstraction and marshaling
  • Native AOT compatible
  • Windows and Linux ABI targets

Full FFmpeg Header Parsing

The bindings are generated from a broad FFmpeg public-header surface rather than only the most commonly used libraries or declarations.

This includes FFmpeg hardware-context headers and the external SDK headers required to parse them, including APIs related to:

  • D3D11VA / D3D12VA / DXVA
  • CUDA
  • AMF
  • OpenCL
  • Vulkan
  • Intel oneVPL / QSV
  • VA-API
  • VDPAU

The goal is to expose the native FFmpeg ABI as completely and faithfully as practical, including less commonly used APIs that are often omitted from smaller binding sets.

Cross-Platform ABI

A C declaration does not necessarily have the same binary representation on every platform.

For example, on 64-bit platforms:

Windows (LLP64)    long = 32-bit
Linux   (LP64)     long = 64-bit

Types such as long, unsigned long, size_t, ptrdiff_t, intptr_t, and platform-dependent structures therefore need to be interpreted against the correct target ABI.

Flyleaf.FFmpeg.ABI is generated using the appropriate Clang target environment for each supported platform rather than assuming that declarations generated on one operating system are valid everywhere.

This also applies to platform-specific FFmpeg hardware contexts and their dependent system or SDK headers.

Installation

dotnet add package Flyleaf.FFmpeg.ABI

or:

<PackageReference Include="Flyleaf.FFmpeg.ABI" Version="..." />

Minimum Usage

using Flyleaf.FFmpeg;
using static Flyleaf.FFmpeg.Raw;

LoadLibraries(
    @"C:\path\to\ffmpeg\bin",
    LoadProfile.All);

Console.WriteLine(av_version_info_str());

LoadLibraries loads the required native FFmpeg libraries and configures the bindings to resolve them from the supplied directory.

The native FFmpeg binaries themselves are not included in the package.

Native AOT

Flyleaf.FFmpeg.ABI is designed to be compatible with .NET Native AOT.

The generated bindings favor direct native representations, unmanaged pointers, blittable structures, and native function pointers while avoiding unnecessary runtime-generated interop machinery.

A Native AOT application can therefore use the bindings in the same way.

For the application itself, enable Native AOT in the project:

<PropertyGroup>
  <PublishAot>true</PublishAot>
</PropertyGroup>

and publish for a concrete runtime identifier such as win-x64.

Low-Level by Design

Flyleaf.FFmpeg.ABI intentionally stays close to the native FFmpeg API.

It does not attempt to hide pointers, ownership rules, native lifetimes, or FFmpeg's underlying API model behind a managed abstraction layer.

That makes it suitable as a foundation for higher-level wrappers and media frameworks while keeping the ABI layer small, predictable, and efficient.

Generated with ClangABI

The bindings are generated using ClangABI, a C-to-C# ABI binding generator powered by ClangSharp.

Generation includes support for:

  • Records and unions
  • Enums
  • Functions
  • Native callbacks
  • Fixed arrays
  • Macros
  • Inline functions
  • Platform-specific native types
  • Custom post-processing and generation rules

FFmpeg Versions

Package releases target specific FFmpeg ABI versions.

Applications should use native FFmpeg libraries compatible with the version targeted by the package, particularly when FFmpeg library major versions change.

Flyleaf

Flyleaf.FFmpeg.ABI is also used as the native FFmpeg binding layer for Flyleaf.

Flyleaf provides the higher-level media framework, playback, decoding, rendering, and workflow functionality built on top of these low-level bindings.

License

Flyleaf.FFmpeg.ABI is licensed under the MIT License.

FFmpeg and the third-party SDK headers used during binding generation remain subject to their respective licenses.

About

Low-level, ABI-focused .NET bindings for FFmpeg, providing direct access to native structures, functions, callbacks, constants, and macros with minimal abstraction. Designed for performance, cross-platform ABI correctness, and Native AOT compatibility.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages