-
Notifications
You must be signed in to change notification settings - Fork 220
Notes on building
On *nix systems, clang
, pkg-config
and FFmpeg libraries (including development headers) are required.
On macOS:
brew install pkg-config ffmpeg
On Debian-based systems:
apt install -y clang libavcodec-dev libavformat-dev libavutil-dev pkg-config
Other libav*-dev
and libsw*-dev
packages may be required if you enable the corresponding features, e.g., libavdevice-dev
for the device
feature.
README contains a table with the supported FFmpeg versions and corresponding feature flags. The appropriate ffmpeg$version
feature flag needs to be specified and all feature flags for later versions need to be disabled in order to build against a non-latest FFmpeg version. This usually entails using --no-default-features
, then selectively enable other disabled default features in addition to the proper ffmpeg$version
feature.
Note that at the moment codec
and format
have to be enabled to successfully build ffmpeg-sys-next
. That is to say, for instance, to build against FFmpeg 4.2, at a minimum we need
cargo build --no-default-features --features ffmpeg42,codec,format
See #16.
Here's a sample Makefile snippet for FFmpeg version detection (up to v4.3):
LIBAVCODEC_VERSION=$(shell pkg-config --modversion libavcodec)
$(info detected lavc $(LIBAVCODEC_VERSION))
LIBAVCODEC_VERSION_MAJOR := $(word 1,$(subst ., ,$(LIBAVCODEC_VERSION)))
LIBAVCODEC_VERSION_MINOR := $(word 2,$(subst ., ,$(LIBAVCODEC_VERSION)))
ifeq ($(LIBAVCODEC_VERSION_MAJOR),)
$(error cannot determine libavcodec version with pkg-config)
else ifeq ($(shell test $(LIBAVCODEC_VERSION_MAJOR) -gt 58; echo $$?),0)
$(warning unknown libavcodec version, possibly from FFmpeg >4; use at own risk)
FEATURES += ffmpeg43
else ifeq ($(LIBAVCODEC_VERSION_MAJOR),58)
ifeq ($(shell test $(LIBAVCODEC_VERSION_MINOR) -ge 91; echo $$?),0)
FEATURES += ffmpeg43
else ifeq ($(shell test $(LIBAVCODEC_VERSION_MINOR) -ge 54; echo $$?),0)
FEATURES += ffmpeg42
else ifeq ($(shell test $(LIBAVCODEC_VERSION_MINOR) -ge 35; echo $$?),0)
FEATURES += ffmpeg41
else
FEATURES += ffmpeg4
endif
endif
It works with GNU toolchain(haven't checked with MSVC), so you should:
- Install MSYS2
- In
.cargo/config
add ``` [target.x86_64-pc-windows-gnu] linker = "C:\msys64\mingw64\bin\gcc.exe"
3. Install these packages: `pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-ffmpeg mingw-w64-x86_64-clang`
4. Add `C:\msys64\mingw64\bin` to your `PATH` environment variable
## Building on Raspberry Pi
To build against an FFmpeg with rpi-specific patches (tell: `rpi` can be found in `ffmpeg -hwaccels`), the `rpi` feature needs to be enabled.