Skip to content

fix(build): skip avfft.h for FFmpeg >= 8 (removed upstream)#125

Open
gaurav02081 wants to merge 1 commit intozmwangx:masterfrom
gaurav02081:gaurav-v1
Open

fix(build): skip avfft.h for FFmpeg >= 8 (removed upstream)#125
gaurav02081 wants to merge 1 commit intozmwangx:masterfrom
gaurav02081:gaurav-v1

Conversation

@gaurav02081
Copy link
Copy Markdown

Problem

libavcodec/avfft.h was deprecated in FFmpeg 6.0 (lavc 60.25.100) and
removed in FFmpeg 8.0. Building against FFmpeg ≥ 8 could fail depending
on include path resolution behavior.

The previous implementation relied on an exists() guard after
search_include, which depended on fallback filesystem behavior rather
than explicit version semantics.

Fixes #117.


Solution

  • Gate inclusion of libavcodec/avfft.h on ffmpeg_major_version < 8
  • Use the existing maybe_search_include helper for safe lookup
  • Follow the same version-gating pattern already used for vaapi.h

This removes reliance on filesystem fallback behavior and makes the
intent explicit and consistent with existing header guards.


Testing

Tested on macOS with FFmpeg 8.0.1 (Homebrew):

  • cargo build succeeds
  • avfft.h is not included in bindgen output
  • No avfft symbols appear in generated bindings.rs
  • No regressions observed

This preserves compatibility for users building against older FFmpeg
versions while ensuring clean builds with FFmpeg 8+.

 was deprecated in FFmpeg 6.0 and removed in FFmpeg 8.0.
The previous exists-based guard relied on search_include fallback behavior.

Gate inclusion on  and use
for safe lookup, matching the existing vaapi.h version guard pattern.

Fixes zmwangx#117.
@selvmaya
Copy link
Copy Markdown

Any known workarounds for this? For reference, I am trying to compile https://github.com/russelltg/wl-screenrec

@gaurav02081
Copy link
Copy Markdown
Author

Any known workarounds for this? For reference, I am trying to compile https://github.com/russelltg/wl-screenrec

Until this PR is merged, you can work around it by using my fork directly. In the Cargo.toml of wl-screenrec (or wherever ffmpeg-sys-next is depended on), add
a git override:

[patch.crates-io]
ffmpeg-sys-next = { git = "https://github.com/gaurav02081/rust-ffmpeg-sys", branch = "gaurav-v1" }

This will use the patched build.rs that skips avfft.h on FFmpeg >= 8.

@selvmaya
Copy link
Copy Markdown

selvmaya commented Mar 29, 2026

Unfortunately, I keep running into this obscure compilation error:
image
I'm not sure where to go from here. I am on up to date standard x86_64 Arch Linux, with the newest ffmpeg 8.1.3 (as well as 4.4 for some dependents).

Also, if I check the package without --release, this debug assert additionally fails:
image
Is my machine target specification malformed somehow?

@gaurav02081
Copy link
Copy Markdown
Author

Unfortunately, I keep running into this obscure compilation error: image I'm not sure where to go from here. I am on up to date standard x86_64 Arch Linux, with the newest ffmpeg 8.1.3 (as well as 4.4 for some dependents).

Also, if I check the package without --release, this debug assert additionally fails: image Is my machine target specification malformed somehow?


seems like the issue is with your clang/bindgen setup.

Try setting this before building: export BINDGEN_EXTRA_CLANG_ARGS="--target=x86_64-unknown-linux-gnu -D__float128='long double'"

This should fix both the __float128 error and the pointer width mismatch (4 vs 8).
If that doesn't work, make sure you have the 64-bit clang installed.

sudo pacman -S clang

@selvmaya
Copy link
Copy Markdown

selvmaya commented Mar 29, 2026

Try setting this before building: export BINDGEN_EXTRA_CLANG_ARGS="--target=x86_64-unknown-linux-gnu -D__float128='long double'"

$env.BINDGEN_EXTRA_CLANG_ARGS = "--target=x86_64-unknown-linux-gnu -D__float128='long double'"

This fixed the compilation issue :)
Leaving my fork here for anyone with the same issue in the meantime (I also made ffmpeg-sys-next use the 2024 edition, since it was unspecified): https://github.com/selvmaya/wl-screenrec

Unfortunately it seems my nvidia+intel laptop does not want to use libva/vaapi, but that's another issue.

vaapi errors image

After installing libva-nvidia-driver:
image

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.

libavcodec/avfft.h: removed in FFmpeg 8.0

3 participants