For some reasons, a customer links his application statically to libavcodec. It turns out many people link ffmpeg statically and there is a docker image to do that. We can use it to get the static libraries.

# Get the compilation script
$ git clone https://github.com/markus-perl/ffmpeg-build-script.git
$ cd ffmpeg-build-script

# Ensure build files are not removed
$ sed '/RUN \/app\/build-ffmpeg --cleanup/d' -i Dockerfile

# Spawn the build
$ docker build . -t ffmpeg-static-image

# Export the libraries from the docker
$ docker run --rm -ti -v$(pwd):/export --entrypoint /bin/bash ffmpeg-static-image -c "cp -r /app/workspace/lib /export"

A lib folder will appear in the current directory.

Here is a sample Makefile:

AVCODECLIBS=-lavformat -lavcodec -lavutil -lavfilter -lswresample -lpthread\
	-lz -lsrt -ltheora -lssl -lx264 -lx265 -lvpx\
	-lcrypto -ldl -lstdc++ -logg -lvorbis -lvorbisenc -lvorbisfile -lopus\
	-lopencore-amrnb -lopencore-amrwb -laom -lmp3lame -lfdk-aac\
	-lpostproc -lsrt -lm

audiodec: audiodec.c Makefile
	gcc $< -o $@ ${AVCODECLIBS}