CCExtractor / rusty_ffmpeg

FFI bindings for FFmpeg inner libraries.
https://crates.io/crates/rusty_ffmpeg
MIT License
164 stars 26 forks source link

Unable to add dependency on MacOS 15.1 #121

Closed KevinvOosterhout closed 3 weeks ago

KevinvOosterhout commented 3 weeks ago

I've added rusty_ffmpeg as a dependency to one of my projects, but i can't get it to build. it outputs avcodec not found but i've got ffmpeg 7.0.2 installed using homebrew. Am i missing a dependency?

I've also got the following environment variables set in my .zshrc

export FFMPEG_INCLUDE_DIR=/opt/homebrew/Cellar/ffmpeg/7.0.2/include
export FFMPEG_LIBS_DIR=/opt/homebrew/Cellar/ffmpeg/7.0.2/lib

Cargo.toml

[dependencies.rusty_ffmpeg]
features = ["ffmpeg7", "link_system_ffmpeg"]
version = "0.14.1"

Console

error: failed to run custom build command for `rusty_ffmpeg v0.14.1+ffmpeg.7.0`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.
Caused by:
  process didn't exit successfully: `/Users/kevin.oosterhout/Downloads/srt-rs-main/target/debug/build/rusty_ffmpeg-7e92b9cf8e864be8/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=DOCS_RS
  cargo:rerun-if-env-changed=OUT_DIR
  cargo:rerun-if-env-changed=FFMPEG_INCLUDE_DIR
  cargo:rerun-if-env-changed=FFMPEG_DLL_PATH
  cargo:rerun-if-env-changed=FFMPEG_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=FFMPEG_LIBS_DIR
  cargo:rerun-if-env-changed=FFMPEG_BINDING_PATH
  cargo:rerun-if-env-changed=LIBAVCODEC_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  --- stderr
  thread 'main' panicked at /Users/kevin.oosterhout/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rusty_ffmpeg-0.14.1+ffmpeg.7.0/build.rs:306:37:
  avcodec not found!
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panicking.rs:652:5
     1: core::panicking::panic_fmt
               at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/panicking.rs:72:14
     2: build_script_build::non_windows::static_linking_with_pkg_config::{{closure}}
     3: core::result::Result<T,E>::unwrap_or_else
     4: build_script_build::non_windows::static_linking_with_pkg_config
     5: build_script_build::static_linking::link_and_bindgen
     6: build_script_build::static_linking
     7: build_script_build::main
     8: core::ops::function::FnOnce::call_once
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
ldm0 commented 3 weeks ago

There is a known issue with system FFmpeg linking on macOS, but it's fixed on current master branch. Try using current master commit.

[dependencies.rusty_ffmpeg]
git = "https://github.com/CCExtractor/rusty_ffmpeg"
rev = "4011018dacd67e0651c5118d9f698e37bd80ac68"
features = ["ffmpeg7", "link_system_ffmpeg"]

Then remove the FFMPEG_INCLUDE_DIR, FFMPEG_LIBS_DIR env variables(if you enabled the link_system_ffmpeg feature, rusty_ffmpeg will invoke pkg-config to find the FFmpeg directory and it's dependencies). Things should work.

KevinvOosterhout commented 3 weeks ago

Works perfectly, Thank you!

ldm0 commented 3 weeks ago

@KevinvOosterhout I published a new version (almost forgotten 😓 ), you can use 0.15.0 now.

[dependencies.rusty_ffmpeg]
features = ["ffmpeg7", "link_system_ffmpeg"]
version = "0.15.0"
KevinvOosterhout commented 3 weeks ago

Confirmed working!