Installing FFmpeg on Raspbian starts with updating your system:
sudo apt update && sudo apt upgrade -y
Skip the default binary if you need custom codecs or hardware acceleration. Build from source with flags tuned for the Pi’s ARM architecture.
sudo apt install git build-essential yasm cmake pkg-config libx264-dev libx265-dev libvpx-dev libfdk-aac-dev
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
./configure --enable-gpl --enable-nonfree --enable-libx264 --enable-libx265 --enable-libvpx --enable-libfdk-aac --arch=arm --target-os=linux
make -j$(nproc)
sudo make install
Hardware acceleration matters. For Raspberry Pi 4, enable --enable-mmal or --enable-rpi depending on your GPU driver. This lowers CPU usage during video encoding and playback.
Test the build: