-
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 does work, someone has done it. Not sure if pkg-config
is a dead end, but using the FFMPEG_DIR
env var should work.
At some point a guide will probably be provided (when I get around to try to build this on Windows myself)... But contributions here are very welcome.
In the meantime, you can find some tips on the issue tracker. See for instance #7 and #9.