Compiling FFmpeg on the Raspberry Pi (original) (raw)

This tutorial will show you how to compile FFmpeg on your Raspberry Pi.

Raspberry Pi FFmpeg

FFmpeg is an open-source project that consists of a considerable range of libraries.

These libraries are designed to deal with a variety of multimedia formats, whether that be an image, video, or audio format.

One of the best things about FFmpeg is that it can be compiled across a wide variety of devices, including the Raspberry Pi.

Using FFmpeg, you will be able to encode and decode a large variety of video and audio codecs.

Over the next few sections, we will show you how to install or compile FFmpeg on both a 32-bit and 64-bitt operating system.

Equipment List

Here is a list of the equipment we recommend for this tutorial on compiling FFmpeg on your Raspberry Pi.

Optional

We tested this guide on a Raspberry Pi 4 running an up to date version of Raspberry Pi OS Bullseye.

You can obtain Raspberry Pi OS Bullseye from our downloads page or upgrade to it from an older version of Raspbian.

If you are using a newer version of Raspbian and this tutorial fails to work, please leave a comment below.

Installing the Packages Needed for FFmpeg

In this section. we will be preparing your Raspberry Pi by installing all the required libraries for compiling FFmpeg.

1. Before we begin, you should first update both the package list and the installed packages.

To update everything, all you need to do is run the following two commands.

Copy

2. Now we need to install the packages that we need to compile FFmpeg and its additional libraries.

As there are quite a few, the installation process may take some time to complete.

Run the following command to install all of the required packages to your Raspberry Pi.

Copy

Compiling the Additional Libraries on the Raspberry Pi

This section will show you how to compile the additional libraries required by FFmpeg.

1. Before we get started, let’s create a directory where we will store the code for each of these libraries.

Copy

Before proceeding, please note that each of the following steps will take some time to complete.

2. The first library that we are going to compile is the Fraunhofer FDK AAC library.

Compiling this library will allow FFmpeg to have support for the AAC sound format.

Run the following command to download and compile the source code to your Raspberry Pi.

Copy

3. The next library we are going to compile is the “dav1d” library.

This library will add support for decoding the AV1 video format into FFmpeg. This codec is considered the successor of the VP9 codec and as a competitor to the x265 codec.

Run the following command to compile and install the dav1d” library to your Raspberry Pi.

Copy

4. This library that we are going to compile next is an HEVC encoder called “kvazaar“.

Using the following command, you can clone and compile the Kvazaar library on your Raspberry Pi.

Copy

5. We can now compile the library that we need for FFmpeg to be able to support the VP8 and VP9 video codecs on our Raspberry Pi.

This library we are compiling is called LibVPX and is developed by Google.

The following command will clone, configure, and compile the library to our Pi.

Copy

6. We now need to compile the library called “AOM.

This library will allow us to add support for encoding to the AP1 video codec on your Raspberry Pi. This still will differ slightly depending if you are using a 32-bit or 64-bit operating system.

If you are running a 32-bit release of Raspberry Pi OS, please follow step a. However, if you are using a 64-bit release, follow step b.

a. If you are using a 32-bit operating system on your Raspberry Pi, then you can clone and compile AOM by using the following command.

Copy

b. Alternatively, if you are running a 64-bit OS, you will need to utilize the following adjusted command.

Copy

7. The final library we need to compile is the zimg” library.

This library implements a range of image processing features, dealing with the basics of scaling, colorspace, and depth.

Clone and compile the code by running the command below.

Copy

8. Now, run the command below to update the link cache.

This command ensures we won’t run into linking issues because the compiler can’t find a library.

Copy

In this section, we will show you how to put everything together and finally compile FFmpeg.

1. We can finally compile FFmpeg on our Raspberry Pi.

During the compilation, we will be enabling all the extra libraries that we compiled and installed in the previous two sections.

We will also be enabling features that help with the Raspberry Pi’s hardware. Please note these steps will differ slightly depending if you are using a 32-bit (Follow step a) or 64-bit OS (Follow step b).

a. On your 32-bit operating system, you can utilize the following command to compile everything.

This command is reasonably large, as there is a considerable amount of features that we need to enable.

Copy

b. Below is the command that you will need to run if you are using a 64-bit operating system on your Raspberry Pi.

The main difference between this and the previous command is that this one doesn’t have “mmal” enabled. Additionally, the architecture is set to “arm64” rather than “armel”.

Copy

2. Compiling FFmpeg can take significant time on the Raspberry Pi, so be patient.

At this point in the guide, you should now have FFmpeg successfully compiled on your Raspberry Pi.

If you have run into any issues with compiling the software, feel free to drop a comment below.