Skip to content

Update for FFmpeg 9.0.1 - #358

Merged
Ruslan-B merged 1 commit into
mainfrom
feature/ffmpeg-9.0
Aug 16, 2026
Merged

Ruslan-B merged 1 commit into
mainfrom
feature/ffmpeg-9.0

Conversation

@Ruslan-B

Copy link
Copy Markdown
Owner

Regenerates the bindings against FFmpeg 9.0.1 "Lei" (libavutil 61.1.101).

Closes #357

Library versions

All sonames bumped: avcodec 62→63, avdevice 62→63, avformat 62→63, avutil 60→61, avfilter 11→12, swresample 6→7, swscale 9→10.

Generator: anonymous struct/union members

FFmpeg 9.0 introduced the first anonymous union in the public headers, in AVStreamGroupLayeredVideo:

#if FF_API_LCEVC_STRUCT
    union {
#endif
        unsigned int el_index;
#if FF_API_LCEVC_STRUCT
        attribute_deprecated
        unsigned int lcevc_index;
    };
#endif

Such a member carries no name in C, so the generator emitted public AVStreamGroupLayeredVideo_ @; and the build failed with CS1519/CS1646. Anonymous struct/union members now get a synthesized name — union{N} / struct{N}, numbered per declaring struct — used for both the field and the nested type:

public AVStreamGroupLayeredVideo_union0 @union0;

Flattening the union into the parent would require LayoutKind.Explicit with computed FieldOffsets on every struct containing one, so the nested type is kept instead. This is the only occurrence in the whole 9.0.1 header set.

Breaking changes

  • Structs gone: AVPacketList, AVFilterCommand, AVStreamGroupLCEVC (renamed to AVStreamGroupLayeredVideo)
  • Functions gone: av_opt_ptr, av_stream_get_codec_timebase, avformat_transfer_internal_stream_timing_info, av_int_list_length_for_size
  • Enum members gone: AV_CODEC_ID_V308 / V408 / V410, all of AVFMT_TBCF_*
  • AVCodecID values were renumbered — code hardcoding the numbers will break

New: AVDynamicHDRSmpte2094App5 with 4 functions, AVStreamGroupTREF, av_program_copy, av_program_add_stream_index2, SWS_BACKEND_*, 32 new enum members overall.

Versioning

The package version now tracks the full FFmpeg release instead of MAJOR.MINOR only: 9.0.1.0 ships as 9.0.1 (NuGet drops the trailing .0). README updated to match.

Example

The sample video moved to media.w3.org — the previous host serves at ~50 KB/s, w3.org at ~6 MB/s. The URL is a constant now.

Verification

  • dotnet build -c Release — 0 errors, 0 warnings
  • dotnet test -c Release — 22/22 passed
  • Example run against the new binaries: 1001 frames decoded to JPEG, re-encoded to frames/out.h264, verified with ffprobe as H.264 854x480 yuv420p, 1001 frames; av_version_info() reports 9.0.1-full_build-www.gyan.dev
  • Checked the generated output for name clashes: 306 declared types with no duplicates, 1248 fields across 114 structs with no duplicate names within a struct, no unnamed fields left

Note

libavutil/raw_color_params.h is new in 9.0 and is included in the header snapshot, but is not in the generator's curated parse list, so AVRawColorParams is not bound. Same situation as libavcodec/exif.h added in 8.1. Worth a separate issue if these should be exposed.

🤖 Generated with Claude Code

- Updated headers to FFmpeg 9.0.1 "Lei" (libavutil 61.1.101)
- New header: libavutil/raw_color_params.h
- Library sonames bumped: avcodec 62->63, avdevice 62->63, avformat 62->63,
  avutil 60->61, avfilter 11->12, swresample 6->7, swscale 9->10
- Regenerated bindings via CppSharpUnsafeGenerator
- Generator: handle anonymous struct/union members, first seen in 9.0
  (AVStreamGroupLayeredVideo). They carry no name in C and were emitted as
  an unnamed field, which did not compile; now named union{N}/struct{N},
  numbered per declaring struct
- Removed: AVPacketList, AVFilterCommand, AVStreamGroupLCEVC (renamed to
  AVStreamGroupLayeredVideo), av_opt_ptr, av_stream_get_codec_timebase,
  avformat_transfer_internal_stream_timing_info, AVFMT_TBCF_* enum;
  AVCodecID values renumbered
- Example: sample video moved to media.w3.org, the previous host serves at
  ~50 KB/s; the URL is a constant now
- Bump version 8.1.0.0 -> 9.0.1.0, package version now tracks the full
  FFmpeg release (NuGet drops the trailing .0)

Closes #357

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI lite review requested due to automatic review settings August 16, 2026 13:14
@Ruslan-B
Ruslan-B merged commit 721bebd into main Aug 16, 2026
1 check passed
@Ruslan-B
Ruslan-B deleted the feature/ffmpeg-9.0 branch August 16, 2026 13:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the vendored FFmpeg headers and regenerates the C# bindings to target FFmpeg 9.0.1 (“Lei”), including SONAME bumps and new/removed APIs, plus a generator fix for FFmpeg 9’s first anonymous union member in public headers.

Changes:

  • Updated vendored FFmpeg header snapshot/version macros to 9.0.1 (libavutil 61.1.101; SONAME bumps across libraries).
  • Regenerated bindings (structs/enums/macros/PInvoke vectors) to match the updated headers, including new HDR metadata and swscale API surface.
  • Updated the generator to synthesize valid names for anonymous struct/union members and refreshed docs/scripts/sample accordingly.

Reviewed changes

Copilot reviewed 42 out of 64 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
README.md Updates NuGet/package versioning description to align with FFmpeg release version.
Directory.Build.props Bumps package version to 9.0.1.0.
FFmpeg/download-ffmpeg.ps1 Updates default downloaded FFmpeg version to 9.0.1.
FFmpeg.AutoGen.Example/Program.cs Switches sample video URL to a faster host and centralizes it as a constant.
FFmpeg.AutoGen.CppSharpUnsafeGenerator/Processing/StructureProcessor.cs Synthesizes names for anonymous struct/union members during struct generation.
FFmpeg/include/libswscale/version.h Updates swscale version macros for FFmpeg 9.0.1.
FFmpeg/include/libswscale/version_major.h Bumps swscale major version macro.
FFmpeg/include/libswscale/swscale.h Updates swscale public API (new scaler/backend enums, new SwsContext fields, macro placement).
FFmpeg/include/libswresample/version.h Updates swresample version macros for FFmpeg 9.0.1.
FFmpeg/include/libswresample/version_major.h Bumps swresample major version macro.
FFmpeg/include/libavutil/version.h Updates libavutil version macros and FF_API toggles.
FFmpeg/include/libavutil/samplefmt.h Updates documentation text for av_get_sample_fmt_string().
FFmpeg/include/libavutil/raw_color_params.h Adds new FFmpeg 9 header for RAW color parameters.
FFmpeg/include/libavutil/opt.h Removes deprecated APIs/macros (e.g., av_opt_ptr, int-list helper macro).
FFmpeg/include/libavutil/hwcontext_vulkan.h Updates Vulkan hwcontext structures/types and internal-field placement.
FFmpeg/include/libavutil/hwcontext_amf.h Adds AMF HDR-related helpers and includes.
FFmpeg/include/libavutil/hdr_dynamic_metadata.h Adds SMPTE 2094-50 (App5) dynamic HDR metadata struct + APIs.
FFmpeg/include/libavutil/frame.h Adds new AVFrame side-data types (HDR App5, IAMF params, RAW color params) and improves EXIF description.
FFmpeg/include/libavutil/ffversion.h Updates FFMPEG_VERSION string to 9.0.1 build.
FFmpeg/include/libavutil/cpu.h Updates CPU flag definitions (adds/removes flags per 9.0).
FFmpeg/include/libavutil/common.h Removes deprecated av_mod_uintp2 API.
FFmpeg/include/libavutil/bswap.h Tightens casts in av_bswap64() implementation.
FFmpeg/include/libavutil/avutil.h Removes deprecated int-list length helpers.
FFmpeg/include/libavutil/attributes.h Adds av_fallthrough and adjusts av_flatten detection.
FFmpeg/include/libavformat/version.h Updates libavformat version macros for FFmpeg 9.0.1.
FFmpeg/include/libavformat/version_major.h Bumps libavformat major and updates FF_API toggles.
FFmpeg/include/libavformat/avformat.h Updates stream group structs (LayeredVideo/TREF), adds program copy APIs, new flags, and removes deprecated timing APIs.
FFmpeg/include/libavfilter/version.h Updates libavfilter version macros for FFmpeg 9.0.1.
FFmpeg/include/libavfilter/version_major.h Bumps libavfilter major and removes FF_API toggles.
FFmpeg/include/libavfilter/buffersrc.h Normalizes buffersrc flag values to explicit bit shifts.
FFmpeg/include/libavfilter/avfilter.h Removes deprecated public fields from AVFilterContext.
FFmpeg/include/libavdevice/version.h Updates libavdevice version macros for FFmpeg 9.0.1.
FFmpeg/include/libavdevice/version_major.h Bumps libavdevice major and removes FF_API toggles.
FFmpeg/include/libavcodec/version.h Updates libavcodec version macros for FFmpeg 9.0.1.
FFmpeg/include/libavcodec/version_major.h Bumps libavcodec major and updates FF_API toggles.
FFmpeg/include/libavcodec/packet.h Adds new packet side data types, removes deprecated AVPacketList, and const-corrects av_packet_pack_dictionary.
FFmpeg/include/libavcodec/exif.h Updates EXIF API docs and notes allocation behavior changes.
FFmpeg/include/libavcodec/codec.h Removes deprecated AVCodec capability fields and legacy layout list.
FFmpeg/include/libavcodec/codec_par.h Improves Doxygen grouping/wording and clarifies semantics.
FFmpeg/include/libavcodec/codec_id.h Updates codec IDs (removals/renumbering) and adds new IDs.
FFmpeg/include/libavcodec/avdct.h Adds missing standard includes for public header completeness.
FFmpeg/include/libavcodec/avcodec.h Adds AV_CODEC_FLAG2_FIXED_FRAME_SIZE, updates frame_size docs, and removes deprecated parser/codec fields.
FFmpeg.AutoGen/generated/vectors.g.cs Regenerates function-pointer delegates (adds new APIs, removes deprecated ones, signature updates).
FFmpeg.AutoGen/generated/Structs.g.cs Regenerates struct layouts (removes deprecated fields, adds new structs/unions/enums-related structs).
FFmpeg.AutoGen/generated/Enums.g.cs Regenerates enums (new/removed values; swscale backend/scaler enums; new side-data types).
FFmpeg.AutoGen/generated/Arrays.g.cs Regenerates fixed-array helper structs for new nested array shapes.
FFmpeg.AutoGen/generated/Delegates.g.cs Removes delegates for deprecated parser callbacks no longer in public API.
FFmpeg.AutoGen/generated/ffmpeg.macros.g.cs Regenerates macro constants/aliases, library version constants, and FF_API toggles.
FFmpeg.AutoGen/generated/ffmpeg.libraries.g.cs Updates SONAME major-version map for dynamic loading.
FFmpeg.AutoGen/generated/ffmpeg.functions.inline.g.cs Removes inline wrappers for deprecated APIs removed upstream.
FFmpeg.AutoGen/generated/ffmpeg.functions.facade.g.cs Adds facade wrappers for new APIs and removes wrappers for removed/deprecated APIs.
FFmpeg.AutoGen/generated/DynamicallyLoadedBindings.g.cs Updates dynamic resolver wiring for added/removed functions and signature updates.
FFmpeg.AutoGen.Bindings.DynamicallyLoaded/generated/DynamicallyLoadedBindings.libraries.g.cs Updates SONAME major-version map for dynamically loaded bindings package.
FFmpeg.AutoGen.Bindings.DynamicallyLoaded/generated/DynamicallyLoadedBindings.g.cs Updates dynamically loaded binding initializers for added/removed functions and signature updates.
FFmpeg.AutoGen.Bindings.StaticallyLinked/generated/StaticallyLinkedBindings.g.cs Updates statically linked P/Invoke surface for added/removed functions and signature updates.
FFmpeg.AutoGen.Abstractions/generated/vectors.g.cs Regenerates abstraction vectors to match new/removed APIs.
FFmpeg.AutoGen.Abstractions/generated/Structs.g.cs Regenerates abstraction structs to match updated headers.
FFmpeg.AutoGen.Abstractions/generated/Enums.g.cs Regenerates abstraction enums to match updated headers.
FFmpeg.AutoGen.Abstractions/generated/Arrays.g.cs Regenerates abstraction fixed-array helper structs for new nested array shapes.
FFmpeg.AutoGen.Abstractions/generated/Delegates.g.cs Removes abstraction delegates for deprecated parser callbacks no longer in public API.
FFmpeg.AutoGen.Abstractions/generated/ffmpeg.functions.inline.g.cs Removes abstraction inline wrappers for deprecated APIs removed upstream.
FFmpeg.AutoGen.Abstractions/generated/ffmpeg.functions.facade.g.cs Adds/removes abstraction facade wrappers in sync with core bindings.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread README.md
The basic example of the library usage: video decoding, conversion and frame extraction to jpeg is included in ```FFmpeg.AutoGen.Example``` project.
For the more sophisticated operations please refer to offical [ffmpeg Documentation](https://www.ffmpeg.org/documentation.html) expecially API section of it.
Nuget packages version uses [semantic versioning](https://semver.org/) and in sync with MAJOR and MINOR version of FFmpeg as PATCH incremets does not changing API.
Nuget packages version uses [semantic versioning](https://semver.org/) and is in sync with the FFmpeg release the bindings are generated from, e.g. package `9.0.1` targets FFmpeg 9.0.1.
Comment on lines +84 to +88
// Anonymous struct/union members carry no name in C; C# has no equivalent,
// so they are exposed as a regular nested field under a synthesized name.
var fieldName = string.IsNullOrEmpty(field.Name)
? $"{(IsUnion(field.Type) ? "union" : "struct")}{anonymousFieldCount++}"
: field.Name;
Ruslan-B added a commit that referenced this pull request Aug 16, 2026
Two text-only leftovers from the previous pull request:

- README said "Nuget" where the project and the ecosystem write "NuGet"
- the comment above the anonymous-member naming did not say what the
  synthesized names look like, so a reader had to unpick the ternary. It now
  names them: union0, union1, struct0, numbered per declaring struct in
  declaration order

Copilot reported the second as a mismatch between the comment and the code,
which was not quite it - the union{N} phrasing it quoted lives in the commit
message, not in the file. The underlying point stood, so the comment now
spells the scheme out.

No generated output changes; both edits are prose.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade FFmpeg 9.0.1 "Lei"

2 participants