Installing the Latest avifenc on Debian 12 (Bookworm)

This guide details how to install the latest avifenc (from libavif) on Debian 12 by building from source, resolving the libyuv dependency by building it locally.

Prerequisites

  • Ensure you have root or sudo access.
  • A working internet connection to download source code and dependencies.
  • Optional: Exit any Python virtual environment to avoid tool conflicts (deactivate if in a (venv)).

Steps

  1. Install Build Dependencies
    Install the necessary tools and libraries for compiling libavif and its dependencies.

    sudo apt update
    sudo apt install -y build-essential cmake ninja-build libpng-dev libjpeg-dev yasm pandoc git libaom-dev
    
  2. Clone the libavif Repository
    Download the latest libavif source code from GitHub.

    git clone https://github.com/AOMediaCodec/libavif.git
    cd libavif
    
  3. Create a Build Directory
    Create a directory for building libavif and navigate into it.

    mkdir build
    cd build
    
  4. Configure the Build with CMake
    Configure the build to include avifenc, use the system libaom, and build libyuv locally.

    cmake -DCMAKE_INSTALL_PREFIX=/usr \
          -DCMAKE_BUILD_TYPE=Release \
          -DAVIF_CODEC_AOM=SYSTEM \
          -DAVIF_BUILD_APPS=ON \
          -DAVIF_BUILD_MAN_PAGES=ON \
          -DAVIF_LIBYUV=LOCAL \
          -G Ninja ..
    
    • -DAVIF_LIBYUV=LOCAL: Fetches and builds libyuv locally to resolve the missing dependency.
    • -DAVIF_BUILD_APPS=ON: Ensures avifenc and avifdec binaries are built.
    • -G Ninja: Uses the Ninja build system for faster compilation.
  5. Build and Install
    Compile the source code and install the binaries.

    ninja
    sudo ninja install
    
  6. Verify Installation
    Check the installed version of avifenc to confirm success.

    avifenc --version
    

    Expected output: avifenc 1.3.0 (or the latest version from the repository, e.g., 1.3.0 as of May 2025), with libyuv: available.

  7. Clean Up (Optional)
    Remove the source code and build files to free up space.

    cd ../..
    rm -rf libavif
    

Notes

  • Existing libavif-bin Package: If you previously installed libavif-bin (e.g., version 0.11.1-1) from Debian repositories or backports, the source-built avifenc will overwrite it in /usr/bin. To avoid conflicts, remove the Debian package first:
    sudo apt remove libavif-bin
  • Version Check: If avifenc --version shows an older version (e.g., 0.11.1), verify the binary path:
    which avifenc

    It should point to /usr/bin/avifenc. If not, ensure the installation completed correctly.
  • Troubleshooting: If the build fails, check for missing dependencies or clear the build directory and retry:
    cd libavif
    rm -rf build
    mkdir build
    cd build

    Then repeat the cmake and ninja steps.
  • Dependencies: The above steps assume libaom-dev is used for AV1 encoding. Other codecs like rav1e or svt-av1 can be enabled with additional flags if needed (e.g., -DAVIF_CODEC_RAV1E=SYSTEM).

Expected Outcome

After following these steps, you’ll have the latest avifenc installed (e.g., version 1.3.0 or newer), with libyuv support enabled, ready for encoding AVIF images.

评论

还没有人评论,抢个沙发吧...

Viagle Blog

欢迎来到我的个人博客网站