How to Compile FFmpeg with Libbluray

Compiling FFmpeg with libbluray allows you to directly read, decode, and convert unencrypted Blu-ray discs or decrypted BDMV folder structures. This guide walks you through the step-by-step process of preparing your build environment, installing the necessary libbluray development libraries, configuring FFmpeg with the appropriate build flags, compiling the binaries, and verifying the installation for disc playback.

1. Install Prerequisites and Dependencies

Before compiling, update your package manager and install the core build tools alongside the libbluray development headers. On Debian or Ubuntu-based distributions, run:

sudo apt update
sudo apt install -y build-essential pkg-config yasm nasm git libbluray-dev libbluray2

For Fedora, RHEL, or CentOS systems, use:

sudo dnf install -y gcc gcc-c++ make pkgconfig yasm nasm git libbluray-devel

2. Clone the FFmpeg Source Code

Retrieve the latest source code from the official FFmpeg Git repository:

git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg-source
cd ffmpeg-source

If you prefer a stable release over the cutting-edge master branch, check out a specific release tag:

git checkout release/6.1

3. Configure the Build

Run the ./configure script to prepare the build files. Include the --enable-libbluray flag to enable Blu-ray reading capabilities, along with --enable-gpl which is required by FFmpeg for certain features and dependencies.

./configure --prefix=/usr/local --enable-gpl --enable-libbluray --enable-nonfree

Note: You can add other optional libraries here as needed (such as --enable-libx264 or --enable-libx265).

Ensure that the configure script completes without errors. If libbluray is not detected, verify that pkg-config can locate it by running pkg-config --modversion libbluray.

4. Compile and Install

Compile the source code using make. You can accelerate the process by utilizing all available CPU cores with the -j flag:

make -j$(nproc)

Once the compilation finishes successfully, install the newly built binaries:

sudo make install

Update your system's shared library cache:

sudo ldconfig

5. Verify the Installation

Confirm that the newly compiled binary includes libbluray support by checking the configuration output:

ffmpeg -version

Look for --enable-libbluray in the configuration lines printed in the terminal.

6. Accessing Blu-ray Media

With FFmpeg compiled, you can now stream, inspect, or transcode Blu-ray content using the bluray: protocol:

  • Inspect disc details or structure:

    ffprobe bluray:/path/to/disc/or/directory
  • Transcode the main title to MP4:

    ffmpeg -i bluray:/path/to/disc/or/directory -c:v libx264 -crf 20 -c:a aac output.mp4

Note: Commercial Blu-ray discs protected with AACS or BD+ encryption require external decryption keys (such as KEYDB.cfg) placed in ~/.config/aacs/ to allow libbluray to read the encrypted content.