[Cin] HW Accel

Andrea paz gamberucci.andrea at gmail.com
Sat Apr 26 11:22:18 CEST 2025


A few silly questions on topics already addressed several times. I was
reading about hardware acceleration in ffmpeg.
In my system ffmpeg I have:

$ ffmpeg -hwaccels
ffmpeg version n7.1 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 14.2.1 (GCC) 20250207
  configuration: --prefix=/usr --disable-debug --disable-static
--disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm
--enable-lto --enable-fontconfig --enable-frei0r --enable-gmp
--enable-gnutls --enable-gpl --enable-ladspa --enable-libaom
--enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d
--enable-libdrm --enable-libdvdnav --enable-libdvdread
--enable-libfreetype --enable-libfribidi --enable-libglslang
--enable-libgsm --enable-libharfbuzz --enable-libiec61883
--enable-libjack --enable-libjxl --enable-libmodplug
--enable-libmp3lame --enable-libopencore_amrnb
--enable-libopencore_amrwb --enable-libopenjpeg --enable-libopenmpt
--enable-libopus --enable-libplacebo --enable-libpulse
--enable-librav1e --enable-librsvg --enable-librubberband
--enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt
--enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2
--enable-libvidstab --enable-libvmaf --enable-libvorbis
--enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264
--enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid
--enable-libzimg --enable-libzmq --enable-nvdec --enable-nvenc
--enable-opencl --enable-opengl --enable-shared --enable-vapoursynth
--enable-version3 --enable-vulkan
  libavutil      59. 39.100 / 59. 39.100
  libavcodec     61. 19.100 / 61. 19.100
  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
Hardware acceleration methods:
vdpau
cuda
vaapi
qsv
drm
opencl
vulkan


If I try the same command with ffmpeg contained in
.../thirdparty/ffmpeg-7.0 I get:

./ffmpeg -hwaccels
Hardware acceleration methods:
vdpau
cuda
vaapi
vulkan


So I guess OpenCL; Qsv and drm can only be obtained by manually
compiling them. With what exact options in ./configure? (I never know
when to use “--with-” and when to use “--enable-”).

“drm” can serve in CinGG?

Another thing: vulkan is already included in CinGG, but I have never
been able to activate the device and get it working. How to do that?
With system ffmpeg I can activate it without any problems.

I am attaching the part of ffmpeg's documentation regarding hardware
acceleration.
The following part (regarding decoding) seems important to me:
"Note that most acceleration methods are intended for playback and
will not be faster than software decoding on modern CPUs.
Additionally, ffmpeg will usually need to copy the decoded frames from
the GPU memory into the system memory, resulting in further
performance loss. This option is thus mainly useful for testing."

As usual, I thought it would be a good thing to have playback in
hardware but it is not. (However, there is a video of Adam where he
manages to get better decoding with his Nvidia:
https://www.youtube.com/watch?v=IZdJqrObnik).
-------------- next part --------------
-init_hw_device type[=name][:device[,key=value...]]

    Initialise a new hardware device of type type called name, using the given device parameters. If no name is specified it will receive a default name of the form "type%d".

    The meaning of device and the following arguments depends on the device type:

    cuda

        device is the number of the CUDA device.

        The following options are recognized:

        primary_ctx

            If set to 1, uses the primary device context instead of creating a new one.

        Examples:

        -init_hw_device cuda:1

            Choose the second device on the system.
        -init_hw_device cuda:0,primary_ctx=1

            Choose the first device and use the primary device context.

    dxva2

        device is the number of the Direct3D 9 display adapter.
    d3d11va

        device is the number of the Direct3D 11 display adapter. If not specified, it will attempt to use the default Direct3D 11 display adapter or the first Direct3D 11 display adapter whose hardware VendorId is specified by ‘vendor_id’.

        Examples:

        -init_hw_device d3d11va

            Create a d3d11va device on the default Direct3D 11 display adapter.
        -init_hw_device d3d11va:1

            Create a d3d11va device on the Direct3D 11 display adapter specified by index 1.
        -init_hw_device d3d11va:,vendor_id=0x8086

            Create a d3d11va device on the first Direct3D 11 display adapter whose hardware VendorId is 0x8086.

    vaapi

        device is either an X11 display name, a DRM render node or a DirectX adapter index. If not specified, it will attempt to open the default X11 display ($DISPLAY) and then the first DRM render node (/dev/dri/renderD128), or the default DirectX adapter on Windows.

        The following options are recognized:

        kernel_driver

            When device is not specified, use this option to specify the name of the kernel driver associated with the desired device. This option is available only when the hardware acceleration method drm and vaapi are enabled.
        vendor_id

            When device and kernel_driver are not specified, use this option to specify the vendor id associated with the desired device. This option is available only when the hardware acceleration method drm and vaapi are enabled and kernel_driver is not specified.

        Examples:

        -init_hw_device vaapi

            Create a vaapi device on the default device.
        -init_hw_device vaapi:/dev/dri/renderD129

            Create a vaapi device on DRM render node /dev/dri/renderD129.
        -init_hw_device vaapi:1

            Create a vaapi device on DirectX adapter 1.
        -init_hw_device vaapi:,kernel_driver=i915

            Create a vaapi device on a device associated with kernel driver ‘i915’.
        -init_hw_device vaapi:,vendor_id=0x8086

            Create a vaapi device on a device associated with vendor id ‘0x8086’.

    vdpau

        device is an X11 display name. If not specified, it will attempt to open the default X11 display ($DISPLAY).
    qsv

        device selects a value in ‘MFX_IMPL_*’. Allowed values are:

        auto
        sw
        hw
        auto_any
        hw_any
        hw2
        hw3
        hw4

        If not specified, ‘auto_any’ is used. (Note that it may be easier to achieve the desired result for QSV by creating the platform-appropriate subdevice (‘dxva2’ or ‘d3d11va’ or ‘vaapi’) and then deriving a QSV device from that.)

        The following options are recognized:

        child_device

            Specify a DRM render node on Linux or DirectX adapter on Windows.
        child_device_type

            Choose platform-appropriate subdevice type. On Windows ‘d3d11va’ is used as default subdevice type when --enable-libvpl is specified at configuration time, ‘dxva2’ is used as default subdevice type when --enable-libmfx is specified at configuration time. On Linux user can use ‘vaapi’ only as subdevice type.

        Examples:

        -init_hw_device qsv:hw,child_device=/dev/dri/renderD129

            Create a QSV device with ‘MFX_IMPL_HARDWARE’ on DRM render node /dev/dri/renderD129.
        -init_hw_device qsv:hw,child_device=1

            Create a QSV device with ‘MFX_IMPL_HARDWARE’ on DirectX adapter 1.
        -init_hw_device qsv:hw,child_device_type=d3d11va

            Choose the GPU subdevice with type ‘d3d11va’ and create QSV device with ‘MFX_IMPL_HARDWARE’.
        -init_hw_device qsv:hw,child_device_type=dxva2

            Choose the GPU subdevice with type ‘dxva2’ and create QSV device with ‘MFX_IMPL_HARDWARE’.
        -init_hw_device qsv:hw,child_device=1,child_device_type=d3d11va

            Create a QSV device with ‘MFX_IMPL_HARDWARE’ on DirectX adapter 1 with subdevice type ‘d3d11va’.
        -init_hw_device vaapi=va:/dev/dri/renderD129 -init_hw_device qsv=hw1 at va

            Create a VAAPI device called ‘va’ on /dev/dri/renderD129, then derive a QSV device called ‘hw1’ from device ‘va’.

    opencl

        device selects the platform and device as platform_index.device_index.

        The set of devices can also be filtered using the key-value pairs to find only devices matching particular platform or device strings.

        The strings usable as filters are:

        platform_profile
        platform_version
        platform_name
        platform_vendor
        platform_extensions
        device_name
        device_vendor
        driver_version
        device_version
        device_profile
        device_extensions
        device_type

        The indices and filters must together uniquely select a device.

        Examples:

        -init_hw_device opencl:0.1

            Choose the second device on the first platform.
        -init_hw_device opencl:,device_name=Foo9000

            Choose the device with a name containing the string Foo9000.
        -init_hw_device opencl:1,device_type=gpu,device_extensions=cl_khr_fp16

            Choose the GPU device on the second platform supporting the cl_khr_fp16 extension.

    vulkan

        If device is an integer, it selects the device by its index in a system-dependent list of devices. If device is any other string, it selects the first device with a name containing that string as a substring.

        The following options are recognized:

        debug

            If set to 1, enables the validation layer, if installed.
        linear_images

            If set to 1, images allocated by the hwcontext will be linear and locally mappable.
        instance_extensions

            A plus separated list of additional instance extensions to enable.
        device_extensions

            A plus separated list of additional device extensions to enable.

        Examples:

        -init_hw_device vulkan:1

            Choose the second device on the system.
        -init_hw_device vulkan:RADV

            Choose the first device with a name containing the string RADV.
        -init_hw_device vulkan:0,instance_extensions=VK_KHR_wayland_surface+VK_KHR_xcb_surface

            Choose the first device and enable the Wayland and XCB instance extensions.

-init_hw_device type[=name]@source

    Initialise a new hardware device of type type called name, deriving it from the existing device with the name source.
-init_hw_device list

    List all hardware device types supported in this build of ffmpeg.
-filter_hw_device name

    Pass the hardware device called name to all filters in any filter graph. This can be used to set the device to upload to with the hwupload filter, or the device to map to with the hwmap filter. Other filters may also make use of this parameter when they require a hardware device. Note that this is typically only required when the input is not already in hardware frames - when it is, filters will derive the device they require from the context of the frames they receive as input.

    This is a global setting, so all filters will receive the same device.
-hwaccel[:stream_specifier] hwaccel (input,per-stream)

    Use hardware acceleration to decode the matching stream(s). The allowed values of hwaccel are:

    none

        Do not use any hardware acceleration (the default).
    auto

        Automatically select the hardware acceleration method.
    vdpau

        Use VDPAU (Video Decode and Presentation API for Unix) hardware acceleration.
    dxva2

        Use DXVA2 (DirectX Video Acceleration) hardware acceleration.
    d3d11va

        Use D3D11VA (DirectX Video Acceleration) hardware acceleration.
    vaapi

        Use VAAPI (Video Acceleration API) hardware acceleration.
    qsv

        Use the Intel QuickSync Video acceleration for video transcoding.

        Unlike most other values, this option does not enable accelerated decoding (that is used automatically whenever a qsv decoder is selected), but accelerated transcoding, without copying the frames into the system memory.

        For it to work, both the decoder and the encoder must support QSV acceleration and no filters must be used.
    videotoolbox

        Use Video Toolbox hardware acceleration.

    This option has no effect if the selected hwaccel is not available or not supported by the chosen decoder.

    Note that most acceleration methods are intended for playback and will not be faster than software decoding on modern CPUs. Additionally, ffmpeg will usually need to copy the decoded frames from the GPU memory into the system memory, resulting in further performance loss. This option is thus mainly useful for testing.
-hwaccel_device[:stream_specifier] hwaccel_device (input,per-stream)

    Select a device to use for hardware acceleration.

    This option only makes sense when the -hwaccel option is also specified. It can either refer to an existing device created with -init_hw_device by name, or it can create a new device as if ‘-init_hw_device’ type:hwaccel_device were called immediately before.
-hwaccels

    List all hardware acceleration components enabled in this build of ffmpeg. Actual runtime availability depends on the hardware and its suitable driver being installed.


More information about the Cin mailing list