Cross platform FFI bindings for FFmpeg inner libraries. This is a crate that:
- Links FFmpeg libraries for you.
- Generates Rust binding for FFmpeg libraries.
To use this crate, you need to set several environment variables.
Build ffmpeg statically and set FFMPEG_PKG_CONFIG_PATH
to the path of the generated FFmpeg pkg-config
files. And you don't need to set other environment variables for static linking.
(Hint: setting FFMPEG_PKG_CONFIG_PATH
to some placeholder value will leave a rusty_ffmpeg
probing system library.)
rusty_ffmpeg
can link FFmpeg using vcpkg
. Install vcpkg
, check documentation of the vcpkg crate for the environment variables to set, then it works.
You need to set several environment variables for both linking and binding generating procedures.
-
Dynamic linking with pre-built dylib: Set
FFMPEG_DLL_PATH
to the path ofdll
orso
. (Windows: Put corresponding.lib
file next to the.dll
file.) -
Static linking with pre-built staticlib: Set
FFMPEG_LIBS_DIR
to the path of the FFmpeg pre-built libs directory.
-
Compile-time binding generation(requires the
Clang
dylib): SetFFMPEG_INCLUDE_DIR
to the path to the header files for binding generation. -
Use your pre-built binding: Set
FFMPEG_BINDING_PATH
to the pre-built binding file. The pre-built binding is usually copied from theOUT_DIR
of the compile-time binding generation, by using it you don't need to regenerate the same binding file again and again.
You can enable system-wide FFmpeg linking by enabling feature link_system_ffmpeg
.
- Do nothing when you are using FFmpeg
4.*
- Enable
ffmpeg5
feature when you are using FFmpeg5.*
- Enable
ffmpeg6
feature when you are using FFmpeg6.*
- Enable
ffmpeg7
feature when you are using FFmpeg7.*
FFI is not that easy, especially when you are dealing with a big old C project. Don't feel depressed when there are some problems. The CI check already has some typical ffmpeg compilation and use cases for you to check. File an issue if you still have any problem.