Intel Battlemage GPU Support In FFmpeg: A Compatibility Gap

Alex Johnson
-
Intel Battlemage GPU Support In FFmpeg: A Compatibility Gap

This article dives into a compatibility issue between different FFmpeg builds and Intel's Battlemage GPUs. Specifically, it addresses why the BtbN builds of FFmpeg appear to lack support for these GPUs, while Jellyfin-ffmpeg readily supports them. Understanding the nuances behind these builds and their configurations can shed light on the discrepancy and potential solutions.

Understanding the Issue: Intel Battlemage GPU Incompatibility

When using FFmpeg to harness the power of your Intel Arc Battlemage GPUs, like the Intel Arc Pro B50, you might encounter a frustrating problem: the BtbN builds don't seem to work. However, Jellyfin-ffmpeg handles these GPUs just fine. This difference likely stems from how each build is configured and compiled. Let's explore what might be causing this issue.

The core issue appears to be rooted in the way each FFmpeg build is configured and compiled, particularly concerning hardware acceleration libraries and driver support. FFmpeg relies on external libraries like VA-API (Video Acceleration API) to interface with the GPU for hardware-accelerated video encoding and decoding. The BtbN builds, despite aiming for comprehensive functionality, might be missing certain configurations or library versions necessary for the latest Intel Battlemage GPUs. These GPUs require updated drivers and specific VA-API implementations to function correctly. In contrast, Jellyfin-ffmpeg, tailored for media streaming and transcoding, likely includes these necessary updates and configurations to ensure compatibility with a broader range of hardware, including the newer Intel Arc series. This discrepancy highlights the importance of build configurations and library dependencies in achieving optimal hardware acceleration support within FFmpeg.

FFmpeg's versatility stems from its ability to be compiled with various configurations and external libraries, allowing it to support a wide range of codecs, formats, and hardware acceleration technologies. However, this flexibility also means that different builds of FFmpeg can have varying levels of support for specific hardware. The BtbN builds, for example, might prioritize stability or compatibility with older hardware, potentially sacrificing support for the latest GPUs. On the other hand, Jellyfin-ffmpeg, optimized for media streaming, tends to incorporate the latest hardware acceleration features to enhance transcoding performance. This difference in focus can explain why Jellyfin-ffmpeg readily supports Intel Battlemage GPUs, while BtbN builds may require manual configuration or recompilation to achieve the same level of support. Understanding these build-specific differences is crucial for users seeking to leverage the full potential of their hardware within FFmpeg.

The error messages generated during FFmpeg execution provide valuable clues about the underlying issues. In the case of the BtbN builds, the "Failed to initialise VAAPI connection: 18 (invalid parameter)" error suggests a mismatch between the VA-API version or implementation and the requirements of the Intel Battlemage GPU. This error typically arises when FFmpeg is unable to establish a proper connection with the VA-API driver, indicating that the driver is either missing, incompatible, or not correctly configured. Further investigation may involve checking the installed VA-API version, ensuring that the correct driver is installed for the Intel Battlemage GPU, and verifying that the FFmpeg build is linked against the appropriate VA-API libraries. Resolving this error often involves updating the VA-API driver, recompiling FFmpeg with the correct VA-API configuration, or using a different FFmpeg build that includes the necessary support for the target GPU.

Reproducing the Issue: Command-Line Examples

Let's examine the commands used to trigger the issue and the different outputs obtained from the two FFmpeg builds.

Command Used

The following command is used to transcode a video file (omd.mkv) using the Intel Quick Sync Video (QSV) encoder for AV1, aiming for high quality and a specific encoding profile:

/opt/ffmpeg-uranite-static/bin/ffmpeg -i omd.mkv \
  -init_hw_device qsv=hw:/dev/dri/renderD128 \
  -c:v av1_qsv \
  -preset veryslow \
  -global_quality 20 \
  -look_ahead 1 \
  -an \
  -y omd_output.mkv
  • -i omd.mkv: Specifies the input video file.
  • -init_hw_device qsv=hw:/dev/dri/renderD128: Initializes the QSV hardware acceleration, pointing to the render node for the GPU.
  • -c:v av1_qsv: Sets the video codec to AV1 using QSV.
  • -preset veryslow: Uses the veryslow preset for maximum quality (at the expense of encoding speed).
  • -global_quality 20: Sets the global quality level for the encoding.
  • -look_ahead 1: Enables look-ahead for better rate control.
  • -an: Disables audio.
  • -y: Overwrites the output file without prompting.

Output from BtbN Build

When running the command with the BtbN build, the following error occurs:

root@880e054792a3:/app/Data# ./test.sh 
ffmpeg version N-121735-gbe99d2c0b2-20251111 Copyright (c) 2000-2025 the FFmpeg developers
  built with gcc 15.2.0 (crosstool-NG 1.28.0.1_403899e)
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-ffbuild-linux-gnu- --arch=x86_64 --target-os=linux --enable-gpl --enable-version3 --disable-debug --enable-iconv --enable-zlib --enable-libxml2 --enable-libsoxr --enable-openssl --enable-libvmaf --enable-fontconfig --enable-libharfbuzz --enable-libfreetype --enable-libfribidi --enable-vulkan --enable-libshaderc --enable-libvorbis --enable-libxcb --enable-xlib --enable-libpulse --enable-opencl --enable-gmp --enable-lzma --enable-amf --enable-libaom --enable-libaribb24 --enable-avisynth --enable-chromaprint --enable-libdav1d --enable-libdavs2 --enable-libdvdread --enable-libdvdnav --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libkvazaar --enable-libaribcaption --enable-libass --enable-libbluray --enable-libjxl --enable-libmp3lame --enable-libopus --enable-libplacebo --enable-librist --enable-libssh --enable-libtheora --enable-libvpx --enable-libwebp --enable-libzmq --enable-lv2 --enable-libvpl --enable-openal --enable-liboapv --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --disable-schannel --enable-sdl2 --enable-libsnappy --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libdrm --enable-vaapi --enable-libvidstab --enable-libvvenc --enable-whisper --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-libs='-lgomp -ldl' --extra-ldflags=-pthread --extra-ldexeflags=-pie --cc=x86_64-ffbuild-linux-gnu-gcc --cxx=x86_64-ffbuild-linux-gnu-g++ --ar=x86_64-ffbuild-linux-gnu-gcc-ar --ranlib=x86_64-ffbuild-linux-gnu-gcc-ranlib --nm=x86_64-ffbuild-linux-gnu-gcc-nm --extra-version=20251111
  libavutil      60. 17.100 / 60. 17.100
  libavcodec     62. 19.100 / 62. 19.100
  libavformat    62.  6.101 / 62.  6.101
  libavdevice    62.  2.100 / 62.  2.100
  libavfilter    11.  9.100 / 11.  9.100
  libswscale      9.  3.100 /  9.  3.100
  libswresample   6.  2.100 /  6.  2.100
[VAAPI @ 0x5c00aea52c00] libva: /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so init failed
[VAAPI @ 0x5c00aea52c00] Failed to initialise VAAPI connection: 18 (invalid parameter).
Device creation failed: -5.
Failed to set value 'qsv=hw:/dev/dri/renderD128' for option 'init_hw_device': Input/output error
Error parsing global options: Input/output error

The key error messages are:

  • libva: /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so init failed: Indicates that the VA-API driver (iHD_drv_video.so) failed to initialize.
  • Failed to initialise VAAPI connection: 18 (invalid parameter): Suggests an issue with the parameters passed during the VA-API initialization.
  • Device creation failed: -5: Device creation failed.
  • Error parsing global options: Input/output error: Suggests an issue with the overall command-line syntax or options.

Output from Jellyfin-ffmpeg

When running the same command with Jellyfin-ffmpeg, the process starts successfully:

ffmpeg version 7.1.2-Jellyfin Copyright (c) 2000-2025 the FFmpeg developers
  built with gcc 13 (Ubuntu 13.3.0-6ubuntu2~24.04)
  configuration: --prefix=/usr/lib/jellyfin-ffmpeg --target-os=linux --extra-version=Jellyfin --disable-doc --disable-ffplay --disable-static --disable-libxcb --disable-sdl2 --disable-xlib --enable-lto=auto --enable-gpl --enable-version3 --enable-shared --enable-gmp --enable-gnutls --enable-chromaprint --enable-opencl --enable-libdrm --enable-libxml2 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libfontconfig --enable-libharfbuzz --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libopenmpt --enable-libdav1d --enable-libsvtav1 --enable-libwebp --enable-libvpx --enable-libx264 --enable-libx265 --enable-libzvbi --enable-libzimg --enable-libfdk-aac --arch=amd64 --enable-libshaderc --enable-libplacebo --enable-vulkan --enable-vaapi --enable-amf --enable-libvpl --enable-ffnvcodec --enable-cuda --enable-cuda-llvm --enable-cuvid --enable-nvdec --enable-nvenc
  libavutil      59. 39.100 / 59. 39.100
  libavcodec     61. 19.101 / 61. 19.101
  libavformat    61.  7.100 / 61.  7.100
  libavdevice    61.  3.100 / 61.  3.100
  libavfilter    10.  4.100 / 10.  4.100
  libswscale      8.  3.100 /  8.  3.100
  libswresample   5.  3.100 /  5.  3.100
  libpostproc    58.  3.100 / 58.  3.100
libva info: VA-API version 1.22.0
libva info: Trying to open /usr/lib/jellyfin-ffmpeg/lib/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_22
libva info: va_openDriver() returns 0
libva info: VA-API version 1.22.0
libva info: Trying to open /usr/lib/jellyfin-ffmpeg/lib/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_22
libva info: va_openDriver() returns 0
Input #0, matroska,webm, from 'omd.mkv':
  Metadata:
    DATE            : 2025
    MAJOR_BRAND     : mp42
    MINOR_VERSION   : 0
    COMPATIBLE_BRANDS: isommp42
    ENCODER         : Lavf61.7.100
  Duration: 00:01:00.02, start: 0.000000, bitrate: 127947 kb/s
  Stream #0:0: Video: h264 (High), yuv420p(tv, smpte170m, progressive), 3440x1440 [SAR 1:1 DAR 43:18], 119.36 fps, 119.36 tbr, 1k tbn (default)
      Metadata:
        HANDLER_NAME    : VideoHandle
        VENDOR_ID       : [0][0][0][0]
        DURATION        : 00:01:00.000000000
  Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp (default)
      Metadata:
        HANDLER_NAME    : SoundHandle
        VENDOR_ID       : [0][0][0][0]
        DURATION        : 00:01:00.020000000
[out#0/matroska @ 0x5f2aed8b6180] Codec AVOption look_ahead (Use VBR algorithm with look ahead) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some decoder which was not actually used for any stream.
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> av1 (av1_qsv))
Press [q] to stop, [?] for help
Output #0, matroska, to 'omd_output.mkv':
  Metadata:
    DATE            : 2025
    MAJOR_BRAND     : mp42
    MINOR_VERSION   : 0
    COMPATIBLE_BRANDS: isommp42
    encoder         : Lavf61.7.100
  Stream #0:0: Video: av1 (AV01 / 0x31305641), nv12(tv, smpte170m, progressive), 3440x1440 [SAR 1:1 DAR 43:18], q=2-31, 119.36 fps, 1k tbn (default)
      Metadata:
        HANDLER_NAME    : VideoHandle
        VENDOR_ID       : [0][0][0][0]
        DURATION        : 00:01:00.000000000
        encoder         : Lavc61.19.101 av1_qsv
[out#0/matroska @ 0x5f2aed8b6180] video:20386KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 0.014424%
frame=  347 fps=105 q=-0.0 Lsize=   20389KiB time=00:00:02.89 bitrate=57621.2kbits/s dup=0 drop=1 speed=0.874x    
Exiting normally, received signal 2.

Here, the key observations are:

  • libva info: The VA-API initialization is successful, indicating that the driver is found and loaded correctly.
  • The process proceeds with reading the input file and starts encoding.

Potential Causes and Solutions

Several factors could contribute to the discrepancy in Intel Battlemage GPU support between BtbN builds and Jellyfin-ffmpeg. Here's a breakdown of potential causes and corresponding solutions:

1. VA-API Driver Compatibility

  • Cause: The VA-API (Video Acceleration API) driver used by FFmpeg might be outdated or incompatible with the Intel Battlemage GPU. Newer GPUs often require updated drivers to function correctly.
  • Solution: Ensure that you have the latest VA-API drivers installed for your Intel Arc Pro B50. These drivers are typically available from the Intel website or through your operating system's package manager. Update mesa libraries, as they often contain crucial VA-API updates.

2. FFmpeg Configuration and Compilation

  • Cause: The BtbN builds might not be compiled with the necessary flags or libraries to support the Intel Battlemage GPU. FFmpeg requires specific configurations to enable hardware acceleration.
  • Solution: Recompile FFmpeg from source with the appropriate flags to enable VA-API and QSV (Quick Sync Video) support. Ensure that the build process links against the correct VA-API libraries. Check the FFmpeg documentation for the recommended configuration options.

3. Library Dependencies

  • Cause: Missing or outdated library dependencies can prevent FFmpeg from properly utilizing the Intel Battlemage GPU. VA-API relies on various libraries to function correctly.
  • Solution: Verify that all necessary library dependencies are installed and up to date. This includes libraries like libva, libva-intel-driver, and mesa. Use your operating system's package manager to install or update these libraries.

4. Build-Specific Optimizations

  • Cause: Jellyfin-ffmpeg is specifically optimized for media streaming and transcoding, which might include specific patches or configurations to enhance compatibility with newer hardware. The BtbN builds might prioritize stability or compatibility with a broader range of hardware, potentially sacrificing support for the latest GPUs.
  • Solution: Consider using Jellyfin-ffmpeg if its specific optimizations align with your use case. Alternatively, investigate the configuration differences between Jellyfin-ffmpeg and the BtbN builds to identify potential areas for improvement.

5. Kernel Version

  • Cause: An outdated kernel might lack the necessary drivers or support for the Intel Battlemage GPU to function correctly with VA-API.
  • Solution: Update to a newer kernel version that includes improved support for Intel's newer GPUs. Check your operating system's documentation for instructions on how to update the kernel.

Detailed Troubleshooting Steps

  1. Verify VA-API Installation:
    • Use the vainfo command to check if VA-API is properly installed and configured. If vainfo fails or reports errors, it indicates a problem with the VA-API installation.
  2. Check Driver Version:
    • Ensure that you have the latest Intel graphics drivers installed. You can typically find these drivers on the Intel website or through your operating system's update mechanism.
  3. Recompile FFmpeg:
    • Download the FFmpeg source code and compile it with the following configuration options:

      ./configure --enable-vaapi --enable-qsv --enable-libdrm
      make
      sudo make install
      
  4. Environment Variables:
    • Set the LIBVA_DRIVER_NAME environment variable to iHD to force FFmpeg to use the Intel VA-API driver:

      export LIBVA_DRIVER_NAME=iHD
      
  5. Permissions:
    • Ensure that the user running FFmpeg has the necessary permissions to access the /dev/dri/renderD128 device. You might need to add the user to the video group.

Conclusion

In summary, the discrepancy in Intel Battlemage GPU support between BtbN builds and Jellyfin-ffmpeg likely stems from differences in configuration, driver support, and build-specific optimizations. By ensuring that you have the latest VA-API drivers, properly configuring FFmpeg, and addressing any library dependencies, you can potentially resolve the issue and harness the full power of your Intel Arc Pro B50 for video transcoding. Always refer to the official documentation and community resources for the most up-to-date information and troubleshooting tips.

For more in-depth information about FFmpeg and hardware acceleration, visit the FFmpeg official website. This resource provides comprehensive documentation, guides, and community support to help you optimize your video processing workflows.

You may also like