#ffmpeg #ffi #binding #video #audio

sys rusty_ffmpeg

A library that provides Rust bindings for FFmpeg

14 releases (6 breaking)

0.7.0 May 13, 2021
0.5.0 Mar 19, 2021
0.3.1 Nov 3, 2020
0.2.5 Jul 14, 2020

#18 in Multimedia

Download history 179/week @ 2021-02-26 78/week @ 2021-03-05 52/week @ 2021-03-12 81/week @ 2021-03-19 366/week @ 2021-03-26 132/week @ 2021-04-02 134/week @ 2021-04-09 98/week @ 2021-04-16 80/week @ 2021-04-23 40/week @ 2021-04-30 355/week @ 2021-05-07 500/week @ 2021-05-14 730/week @ 2021-05-21 523/week @ 2021-05-28 755/week @ 2021-06-04 144/week @ 2021-06-11

626 downloads per month
Used in rsmpeg

MIT license

1.5MB
37K SLoC

Rusty FFmpeg

Doc Crates.io Downloads CI

Cross platform FFI bindings for FFmpeg inner libraries. This is a crate that:

  1. Linking FFmpeg libraries for you.
  2. Generates Rust binding for FFmpeg libraries.

Getting started:

To use this crate, you need to set several environment variables.

The simplest usage:

*nix

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: set FFMPEG_PKG_CONFIG_PATH to some placeholder value will let rusty_ffmpeg probing system library.)

Windows

rusty_ffmpeg can link FFmpeg using vcpkg. Install vcpkg, check documentation of the vcpkg crate for the environment variables to set, then it works.

Fine-grained usage:

You need to set several environment variables for both linking and binding generating procedure.

To link:

  1. Dynamic linking with pre-built dylib: Set FFMPEG_DLL_PATH to the path of dll or so. (Windows: Put corresponding .lib file next to the .dll file.)

  2. Static linking with pre-built staticlib: Set FFMPEG_LIB_DIR to the path of the FFmpeg pre-built libs directory.

To generate bindings:

  1. Compile-time binding generation(requires the Clang dylib): Set FFMPEG_INCLUDE_DIR to the path to the header files for binding generation.

  2. Use your pre-built binding: Set FFMPEG_BINDING_PATH to the pre-built binding file. The pre-built binding is usually copied from the OUT_DIR of the compile-time binding generation, by using it you don't need to regenerate the same binding file again and again.

Attention

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 have some typical ffmpeg compilation and use cases for you to check. File an issue if you still have any problem.

Dependencies

~0–1.4MB
~30K SLoC