Skip to main content

Build MPV and FFmpeg with JACK+portaudio+ASIO support on Windows

C-Play depends on the great mpv media player library, which indeed depends on the great ffmpeg library. It is usually straight-forward to build in many ways, but normally we want to modify the standard build by including JACK, to go from maximum 8-channel audio support, to support ASIO and other low-latency audio frameworks. Choose one of the two below options (after the pre-setup). After building, check further below for creating a linkable library.

Pre-setup: Install JACK + portaudio (also for NDI audio) with vcpkg​

This pre-setup is relevant for NDI and/or OMT audio support.

In the options below, we will compile FFmpeg and MPV with MINGW64, which is standard and usually the easiest practice for building a customized library on Windows. However, MINGW64 headers are extensive and the include folder often makes compilation fail. As we are also using the excellent 'vcpkg' functionality for many packages, we can use that as well to install packages that can be included when building C-Play.

Install the ASIO SDK through 'vcpkg', and then install portaudio with the asio feature enabled. In the C-Play repository, there are some portaudio vcpkg files to make 'portaudio' compile with 'asio', which is not in the standard package included in 'vcpkg'. Finally, install 'jack2' as well.

vcpkg install asiosdk
vcpkg install portaudio[asio]:x64-windows
vcpkg install jack2

Option 1: Build mpv and ffmpeg from MINGW-packages​

The checked-in package recipes were recorded on 2026-09-01 for mpv 0.41 and FFmpeg 9.0.1. Upstream package versions change; these numbers do not identify the libraries in every C-Play release.

This is easiest if you want the latest libraries. However, Option 2 gives you more control and can therefore maximize performance in C-Play for specific configurations.

Here are the steps:

Download MSYS from official website. Install it and then run ucrt64.exe.

Install development packages.

pacman -S base-devel git mingw-w64-ucrt-x86_64-toolchain

Then clone "https://github.com/msys2/MINGW-packages" into your home folder.

git clone "https://github.com/msys2/MINGW-packages"

1.1 (Optional) Install JACK with PortAudio + ASIO support for the MINGW64 environment​

The UCRT64 package of jack2 should contain the dependency of portaudio. And portaudio should be dependent on asiosdk.

pacman -S mingw-w64-ucrt-x86_64-jack2

1.2 Build FFmpeg with custom options (supporting jack2, nvdec etc)​

FFmpeg is highly customizable, but here are the preferred settings for using it with C-Play.

cd MINGW-packages/mingw-w64-ffmpeg

Edit the PKGBUILD file to include ${MINGW_PACKAGE_PREFIX}-jack2 and --enable-libjack. It is also preferable to include the missing --enable-nvdec after --enable-nvenc. Here are my mingw-w64-ffmpeg-pkgbuild configuration file.

Then install dependencies for packing and perform the new packing:

pacman -S binutils base-devel mingw-w64-ucrt-x86_64-gcc
updpkgsums
makepkg-mingw -sCLf

If you get a problem with the public key during the packing, run this:

gpg --recv-key <KEYID>
gpg --lsign <KEYID>

After packing, run:

pacman -U mingw-w64-*-ffmpeg-*-any.pkg.tar.zst

1.3 Build MPV with custom options.​

When you are happy with the ffmpeg build, continue with the mpv build. We want shared library so you need to change the PKGBUILD here as well. CD to mingw-w64-mpv, then add the line below (before -Dlibmpv=true).

-Ddefault_library=shared \

Here are my mingw-w64-mpv-pkgbuild configuration file.

After packing, according to the same steps as for ffmpeg above, run:

pacman -U mingw-w64-*-mpv-*-any.pkg.tar.zst

Create an environmental variable called "PKG_CONFIG_PATH" and add the path "MSYS64_INSTALL_ROOT\ucrt64\lib\pkgconfig". Also add the "MSYS64_INSTALL_ROOT\ucrt64\bin" to your environment "Path".

Go to MSVC linking below to create library for compiling.

Option 2: Build custom mpv and ffmpeg with m-ab-s​

This compilation takes much more time, since you are checking out all dependency sources for ffmpeg from git, but it offers easier and more flexible configuration options.

This guide assumes you use Media Build Suite to get a free setup of dependencies to build ffmpeg and mpv.

Run the batch script after unzipping it in a short path, but quit after MSYS has been setup (i.e. do not run the configure yet).

Install jack2 (see below), after MINGW64 has installed other packages during "Media Build Suite" setup.

pacman -S mingw-w64-ucrt-x86_64-jack2
  • Change the MPV git path from master to release if you want, by opening the file build\media-suite_deps.sh and replace in line 73 "https://github.com/mpv-player/mpv.git" with "https://github.com/mpv-player/mpv.git#release/0.36".

  • My setup: Just copy over these FFmpeg Options, MPV Options and Media Build Suite Configuration to the build folder. This historical configuration pins FFmpeg to the release/5.1 branch; it does not track the current FFmpeg release.

    • Alternatively, do not copy over these files, but during configuration, disable as many encoder as possible, as we want focus on decoding for the player. Also, choose to build ffmpeg with shared libs only, do not strip build files. When asked to edit the FFmpeg options file, add 'jack' to the configuration file.
# Enable JACK
--enable-libjack
  • For the 'mpv_options.txt' the important part to add is this:
# Build libmpv
-Ddefault_library=shared
-Dlibmpv=true
  • Run "Media Build Suite" batch script again, and do not remove the JACK package when asked. Continue and compile everything.

  • Notice: If the ffmpeg build fails, it is most likely because newer dependency packages have changed and caused the build to fail. If you are lucky, you can download an older one and try again. Below is an example:

wget https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-texinfo-7.1.1-2-any.pkg.tar.zst
pacman -U mingw-w64-x86_64-texinfo-7.1.1-2-any.pkg.tar.zst
  • Create an environmental variable called "PKG_CONFIG_PATH" and add the path "(Media Build Suite location)\local64\lib\pkgconfig". Also add the "(Media Build Suite location)\local64\bin-video" to your environmental "Path".

3. After MPV compilation, linking mpv with MSVC programs​

According to the Native compilation with MSYS2, you need to create an import library for the mpv DLL. Launch a Visual Studio command prompt (latest 2022 or later), and cd to the bin directory where mpv-2.dll is located. To create the library, you need a definition file (.def).

If you have a mpv.def file(Option 2 normally gives that), you can already do this:

lib /def:mpv.def /name:mpv-2.dll /out:mpv.lib /MACHINE:X64

or

lib /def:libmpv.def /name:libmpv-2.dll /out:mpv.lib /MACHINE:X64

If the build hasn't generated one (normally it does not), we need to generate one. Install gendef, as part of -tools in your MINGW64 environment and then generate the definition file (From the VS prompt).

pacman -S mingw-w64-x86_64-tools
cd M-AB-S/local64/bin-video
gendef.exe - mpv-2.dll > mpv.def

or

cd MSYS64_INSTALL_ROOT/mingw64/bin/
gendef.exe - libmpv-2.dll > libmpv.def

With the new libmpv.def file, generate the lib by running the command below in a Visual Studio 2022 Developer Command Prompt:

lib /def:mpv.def /name:mpv-2.dll /out:mpv.lib /MACHINE:X64

or

lib /def:libmpv.def /name:libmpv-2.dll /out:mpv.lib /MACHINE:X64

3.1 Library creation for JACK2​

If you compiled and included 'jack2', you might need to go through the same process with 'libjack64.dll' as stated in point above to create a library.

As we have compiled PortAudio with asio support using the vcpkg in the 'pre-setup', we do not need to create a library with MINGW64. But the JACK2 within 'vcpkg' does not seem to have 'asio' support in there, so we want to stick with the MINGW64 version of JACK2.