Dune Libvpx Extra Quality May 2026
In the world of open-source video codecs, libvpx (maintained by the WebM Project) remains the gold standard reference implementation for VP8, VP9, and AV1. However, as any encoding engineer will tell you, integrating libvpx into a modern, scalable, or cross-platform build system can be a nightmare. Enter Dune .
(rule (target libvpx-commit.tar.gz) (action (run curl -L https://github.com/webmproject/libvpx/archive/v1.13.1.tar.gz -o %target))) (rule (target extracted) (deps libvpx-commit.tar.gz) (action (progn (run tar -xzf libvpx-commit.tar.gz) (run mv libvpx-1.13.1 libvpx-src) (write-file extracted "done")))) Now, we invoke libvpx’s own build system but redirect the output to Dune’s artifact cache. The trick is to set the --prefix and --libdir to Dune’s _build/default/libvpx/install . dune libvpx
(rule (target libvpx.a) (deps (source_tree libvpx-src)) (action (progn (chdir libvpx-src (progn (run ./configure --target=x86_64-linux-gcc ; Change per host --disable-shared --enable-static --disable-examples --disable-tools --disable-docs --disable-unit-tests --size-limit=4096x2160 --enable-postproc --enable-vp9-postproc --enable-runtime-cpu-detect --prefix=%workspace_root/_build/default/libvpx/install) (run make -j4) (run make install))) (copy %workspace_root/_build/default/libvpx/install/lib/libvpx.a libvpx.a)))) Finally, create a dune file in your project’s root or a stubs directory: In the world of open-source video codecs, libvpx
The real power of "Dune libvpx" is not about replacing ./configure , but about . Once you have a Dune rule that produces libvpx.a , you can version-control that rule, share it across projects, and even publish it as an opam package. (rule (target libvpx-commit
(let ((target (ocaml-config target_triplet))) (cond ((string= target "aarch64-linux-gnu") (run ./configure --target=arm64-linux-gcc ...)) ((string= target "x86_64-w64-mingw32") (run ./configure --target=x86_64-win64-gcc ...)))) libvpx includes many legacy codecs (VP8, VP9 high bit-depth, real-time only modes). Use Dune’s (select ...) to conditionally compile only the features you need. For example, to disable VP8 entirely, pass --disable-vp8-encoder to ./configure . Symbol Hiding for Safer Linking Add this to your libvpx configure step to prevent symbol leaks:
Try it yourself: Clone this example repository (hypothetical) and run dune build @install . You’ll have a VP9 encoder binary that is completely independent of your system’s multimedia libraries. Have you integrated libvpx with an unconventional build system? Share your war stories in the comments below.