[Cin] ffmpeg -hwaccel AV1_VAAPI vs AV1_QSV encoding on Arc GPU

Terje J. Hanssen terjejhanssen at gmail.com
Tue Jun 25 14:38:15 CEST 2024


After posting some recent ffmpeg  SVT-AV1 vs -hwaccel AV1_QSV encoding 
tests, here follows a simple comparison with AV1_VAAPI (and opus audio 
default).
Comparable bitrates are used. The higher bitrate is selected on VAAPI's 
default bitrate premise. Preset 4 quality setting is used for QSV 
encoding, no other tuning or optimization is applied.
The first visual quality is so far reasonable IMO, while there may be 
differences at a closer study.

The ffmpeg command line syntax I got working for AV1_VAAPI is based on 
an VP9 encode (only) example at
https://trac.ffmpeg.org/wiki/Hardware/VAAPI#Encode-only

So far I didn't succeed trying to apply the Hardware-only Transcode 
examples. So the DV and HDV decode parts have possibly taken place in 
the CPU rather than in the GPU(?)
https://trac.ffmpeg.org/wiki/Hardware/VAAPI#Transcode

--------------------------

576i SD-DV -> AV1_VAAPI at bv1570k VBR
ffmpeg -hide_banner -vaapi_device /dev/dri/renderD128 -i dv01_07.dv -vf 
'format=nv12,hwupload' -c:v av1_vaapi -b:v 1570k 
dv01_07_av1_vaapi_bv1570k.webm
frame= 2832 fps=1959 q=-0.0 Lsize=   28133KiB time=00:01:53.28 
bitrate=2034.5kbits/s speed=78.3x

576i SD-DV->AV1_QSV at bv1570k
ffmpeg -hide_banner -hwaccel_output_format qsv -qsv_device 
/dev/dri/renderD128 -i dv01_07.dv -c:v av1_qsv -preset 4 -b:v 1570k 
dv01_07_av1_qsv_pr4_bv1570k.webm
frame= 2832 fps=1746 q=-0.0 Lsize=   23852KiB time=00:01:53.24 
bitrate=1725.5kbits/s speed=69.8x
..........

576i SD-DV -> AV1_VAAPI at default VBR
ffmpeg -hide_banner -vaapi_device /dev/dri/renderD128 -i dv01_07.dv -vf 
'format=nv12,hwupload' -c:v av1_vaapi dv01_07_av1_vaapi.webm
frame= 2832 fps=1324 q=-0.0 Lsize=   81317KiB time=00:01:53.28 
bitrate=5880.6kbits/s speed=  53x

576i SD-DV->AV1_QSV at bv5600k
ffmpeg -hide_banner -hwaccel_output_format qsv -qsv_device 
/dev/dri/renderD128 -i dv01_07.dv -c:v av1_qsv -preset 4 -b:v 5600k 
dv01_07_av1_qsv_pr4_bv5600k.webm
frame= 2832 fps=1713 q=-0.0 Lsize=   81600KiB time=00:01:53.24 
bitrate=5903.1kbits/s speed=68.5x
.......

du -sh dv*.dv dv*vaapi*.webm dv*qsv*.webm
389M    dv01_07.dv
28M    dv01_07_av1_vaapi_bv1570k.webm
80M    dv01_07_av1_vaapi.webm
24M    dv01_07_av1_qsv_pr4_bv1570k.webm
80M    dv01_07_av1_qsv_pr4_bv5600k.webm


In this SD-DV case, VAAPI encoding is 12% faster than QSV with 15% 
smaller file size at bv1570k bitrate, while QSV is 29% faster than VAAPI 
at bv5600k bitrate.


----------------------------

1080i HDV -> AV1_VAAPI at 3700k VBR
ffmpeg -hide_banner -vaapi_device /dev/dri/renderD128 -i hdv09_04.m2t 
-vf 'format=nv12,hwupload' -c:v av1_vaapi -b:v 3700k 
hdv09_04_av1_vaapi_bv3700k.webm
frame= 5963 fps=631 q=-0.0 Lsize=  153106KiB time=00:03:58.77 
bitrate=5252.8kbits/s speed=25.3x

1080i HDV->AV1_QSV at 3700k
fmpeg -hide_banner -hwaccel_output_format qsv -qsv_device 
/dev/dri/renderD128 -extra_hw_frames 16 -i hdv09_04.m2t -c:v av1_qsv 
-preset 4 -b:v 3700k hdv09_04_av1_qsv_pr4_bv3700k.webm
frame= 5963 fps=473 q=-0.0 Lsize=  113271KiB time=00:03:58.77 
bitrate=3886.1kbits/s speed=18.9x
.......

1080i HDV -> AV1_VAAPI at default VBR
ffmpeg -hide_banner -vaapi_device /dev/dri/renderD128 -i hdv09_04.m2t 
-vf 'format=nv12,hwupload' -c:v av1_vaapi hdv09_04_av1_vaapi.webm
frame= 5963 fps=629 q=-0.0 Lsize=  153106KiB time=00:03:58.77 
bitrate=5252.8kbits/s speed=25.2x

1080i HDV->AV1_QSV at 12600k
ffmpeg -hide_banner -hwaccel_output_format qsv -qsv_device 
/dev/dri/renderD128 -extra_hw_frames 16 -i hdv09_04.m2t -c:v av1_qsv 
-preset 4 -b:v 12600k hdv09_04_av1_qsv_pr4_bv12600k.webm
frame= 5963 fps=476 q=-0.0 Lsize=  370043KiB time=00:03:58.77 
bitrate=12695.6kbits/s speed=  19x


du -sh *.m2t hdv*vaapi*.webm hdv*qsv*.webm
745M    hdv09_04.m2t
150M    hdv09_04_av1_vaapi_bv3700k.webm
375M    hdv09_04_av1_vaapi.webm
362M    hdv09_04_av1_qsv_pr4_bv12600k.webm
111M    hdv09_04_av1_qsv_pr4_bv3700k.webm


In this HDV case, VAAPI encoding is about 33% faster than QSV with 25% - 
4% smaller file sizes.



Background info:
----------------

How to Identify & Find Graphics Drivers for Linux
https://www.intel.com/content/www/us/en/support/articles/000005520/graphics.html?wapkw=intel%20graphics%20installer%20for%20linux

lspci -k | grep -EA3 'VGA|3D|Display'
03:00.0 VGA compatible controller: Intel Corporation DG2 [Arc A750] (rev 08)
     Subsystem: ASRock Incorporation Device 6002
     Kernel driver in use: i915
     Kernel modules: i915, xe


Vaapi and libva packages installed:


S  | Name               | Type    | Version              | Arch | Repository
---+--------------------+---------+----------------------+--------+----------------------
i  | intel-vaapi-driver | package | 2.4.1-5.13           | x86_64 | 
openSUSE-Slowroll-Oss
i  | libva-drm2         | package | 2.21.0-1.1           | x86_64 | 
openSUSE-Slowroll-Oss
i  | libva-glx2         | package | 2.21.0-1.1           | x86_64 | 
openSUSE-Slowroll-Oss
i+ | libva-utils        | package | 2.20.1-1.3           | x86_64 | 
openSUSE-Slowroll-Oss
i  | libva-wayland2     | package | 2.21.0-1.1           | x86_64 | 
openSUSE-Slowroll-Oss
i  | libva-x11-2        | package | 2.21.0-1.1           | x86_64 | 
openSUSE-Slowroll-Oss
i  | libva2             | package | 2.21.0-1.1           | x86_64 | 
openSUSE-Slowroll-Oss
i  | Mesa-libva         | package | 24.0.8-1699.384.pm.1 | x86_64 | Packman



Information for package intel-vaapi-driver:
-------------------------------------------
Summary        : Intel Driver for Video Acceleration (VA) API for Linux
Description    :
     Intel Driver for Libva is a library providing the VA API video 
acceleration API.


Information for package libva-drm2:
-----------------------------------
Summary        : DRM backend for the Video Acceleration API
Description    :
     The libva library implements the Video Acceleration API.
     The library loads a hardware dependendent driver.
     This is the VA/DRM runtime library.


Information for package libva-glx2:
-----------------------------------
Summary        : GLX backend for the Video Acceleration API
Description    :
     The libva library implements the Video Acceleration API.
     The library loads a hardware dependendent driver.

     This is the VA/GLX runtime library.


Information for package libva-utils:
------------------------------------
Summary        : A collection of utilities and examples to exercise VA-API
Description    :
     libva-utils is a collection of utilities and examples to exercise
     VA-API in accordance with the libva project.
     A driver implementation is necessary to properly operate.


Information for package libva-wayland2:
---------------------------------------
Summary        : Wayland backend for the Video Acceleration API
Description    :
     The libva library implements the Video Acceleration API.
     The library loads a hardware dependendent driver.


Information for package libva-x11-2:
------------------------------------
Summary        : X11 backend for the Video Acceleration API
Description    :
     The libva library implements the Video Acceleration API.
     The library loads a hardware dependendent driver.
     This is the VA/X11 runtime library.


Information for package libva2:
-------------------------------
Summary        : Video Acceleration API
Description    :
     The libva library implements the Video Acceleration API.
     The library loads a hardware dependendent driver.
     This is the core runtime library.


Information for package Mesa-libva:
-----------------------------------
Summary        : Mesa VA-API implementation
Description    :
     This package contains the Mesa VA-API implementation provided 
through gallium.


vainfo
Trying display: wayland
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
Trying display: x11
libva info: VA-API version 1.21.0
libva info: Trying to open /usr/lib64/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_20
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.21 (libva 2.20.1)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 
24.1.3 ()
vainfo: Supported profile and entrypoints
       VAProfileNone                   :    VAEntrypointVideoProc
       VAProfileNone                   :    VAEntrypointStats
       VAProfileMPEG2Simple            :    VAEntrypointVLD
       VAProfileMPEG2Main              :    VAEntrypointVLD
       VAProfileH264Main               :    VAEntrypointVLD
       VAProfileH264Main               :    VAEntrypointEncSliceLP
       VAProfileH264High               :    VAEntrypointVLD
       VAProfileH264High               :    VAEntrypointEncSliceLP
       VAProfileJPEGBaseline           :    VAEntrypointVLD
       VAProfileJPEGBaseline           :    VAEntrypointEncPicture
       VAProfileH264ConstrainedBaseline:    VAEntrypointVLD
       VAProfileH264ConstrainedBaseline:    VAEntrypointEncSliceLP
       VAProfileHEVCMain               :    VAEntrypointVLD
       VAProfileHEVCMain               :    VAEntrypointEncSliceLP
       VAProfileHEVCMain10             :    VAEntrypointVLD
       VAProfileHEVCMain10             :    VAEntrypointEncSliceLP
       VAProfileVP9Profile0            :    VAEntrypointVLD
       VAProfileVP9Profile0            :    VAEntrypointEncSliceLP
       VAProfileVP9Profile1            :    VAEntrypointVLD
       VAProfileVP9Profile1            :    VAEntrypointEncSliceLP
       VAProfileVP9Profile2            :    VAEntrypointVLD
       VAProfileVP9Profile2            :    VAEntrypointEncSliceLP
       VAProfileVP9Profile3            :    VAEntrypointVLD
       VAProfileVP9Profile3            :    VAEntrypointEncSliceLP
       VAProfileHEVCMain12             :    VAEntrypointVLD
       VAProfileHEVCMain422_10         :    VAEntrypointVLD
       VAProfileHEVCMain422_10         :    VAEntrypointEncSliceLP
       VAProfileHEVCMain422_12         :    VAEntrypointVLD
       VAProfileHEVCMain444            :    VAEntrypointVLD
       VAProfileHEVCMain444            :    VAEntrypointEncSliceLP
       VAProfileHEVCMain444_10         :    VAEntrypointVLD
       VAProfileHEVCMain444_10         :    VAEntrypointEncSliceLP
       VAProfileHEVCMain444_12         :    VAEntrypointVLD
       VAProfileHEVCSccMain            :    VAEntrypointVLD
       VAProfileHEVCSccMain            :    VAEntrypointEncSliceLP
       VAProfileHEVCSccMain10          :    VAEntrypointVLD
       VAProfileHEVCSccMain10          :    VAEntrypointEncSliceLP
       VAProfileHEVCSccMain444         :    VAEntrypointVLD
       VAProfileHEVCSccMain444         :    VAEntrypointEncSliceLP
       VAProfileAV1Profile0            :    VAEntrypointVLD
       VAProfileAV1Profile0            :    VAEntrypointEncSliceLP
       VAProfileHEVCSccMain444_10      :    VAEntrypointVLD
       VAProfileHEVCSccMain444_10      :    VAEntrypointEncSliceLP


FFmpeg
-------

ffmpeg -hide_banner -buildconf | grep vaapi
     --enable-vaapi


ffmpeg -hide_banner -encoders | grep av1
  V....D libaom-av1           libaom AV1 (codec av1)
  V....D librav1e             librav1e AV1 (codec av1)
  V..... libsvtav1            SVT-AV1(Scalable Video Technology for AV1) 
encoder (codec av1)
  V....D av1_nvenc            NVIDIA NVENC av1 encoder (codec av1)
  V..... av1_qsv              AV1 (Intel Quick Sync Video acceleration) 
(codec av1)
  V....D av1_amf              AMD AMF AV1 encoder (codec av1)
  V....D av1_vaapi            AV1 (VAAPI) (codec av1)
  A....D wmav1                Windows Media Audio 1


ffmpeg -hide_banner -h encoder=av1_vaapi
Encoder av1_vaapi [AV1 (VAAPI)]:
     General capabilities: dr1 delay hardware
     Threading capabilities: none
     Supported hardware devices: vaapi
     Supported pixel formats: vaapi
av1_vaapi AVOptions:
   -low_power         <boolean>    E..V....... Use low-power encoding 
mode (only available on some platforms; may not support all encoding 
features) (default false)
   -idr_interval      <int>        E..V....... Distance (in I-frames) 
between IDR frames (from 0 to INT_MAX) (default 0)
   -b_depth           <int>        E..V....... Maximum B-frame reference 
depth (from 1 to INT_MAX) (default 1)
   -async_depth       <int>        E..V....... Maximum processing 
parallelism. Increase this to improve single channel performance. This 
option doesn't work if driver doesn't implement vaSyncBuffer function. 
(from 1 to 64) (default 2)
   -max_frame_size    <int>        E..V....... Maximum frame size (in 
bytes) (from 0 to INT_MAX) (default 0)
   -rc_mode           <int>        E..V....... Set rate control mode 
(from 0 to 6) (default auto)
      auto            0            E..V....... Choose mode automatically 
based on other parameters
      CQP             1            E..V....... Constant-quality
      CBR             2            E..V....... Constant-bitrate
      VBR             3            E..V....... Variable-bitrate
      ICQ             4            E..V....... Intelligent constant-quality
      QVBR            5            E..V....... Quality-defined 
variable-bitrate
      AVBR            6            E..V....... Average variable-bitrate
   -blbrc             <boolean>    E..V....... Block level based bitrate 
control (default false)
   -profile           <int>        E..V....... Set profile (seq_profile) 
(from -99 to 255) (default -99)
      main            0            E..V.......
      high            1            E..V.......
      professional    2            E..V.......
   -tier              <int>        E..V....... Set tier (seq_tier) (from 
0 to 1) (default main)
      main            0            E..V.......
      high            1            E..V.......
   -level             <int>        E..V....... Set level (seq_level_idx) 
(from -99 to 31) (default -99)
      2.0             0            E..V.......
      2.1             1            E..V.......
      3.0             4            E..V.......
      3.1             5            E..V.......
      4.0             8            E..V.......
      4.1             9            E..V.......
      5.0             12           E..V.......
      5.1             13           E..V.......
      5.2             14           E..V.......
      5.3             15           E..V.......
      6.0             16           E..V.......
      6.1             17           E..V.......
      6.2             18           E..V.......
      6.3             19           E..V.......
   -tiles             <image_size> E..V....... Tile columns x rows (Use 
minimal tile column/row number automatically by default)
   -tile_groups       <int>        E..V....... Number of tile groups for 
encoding (from 1 to 4096) (default 1)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cinelerra-gg.org/pipermail/cin/attachments/20240625/eeb9b60a/attachment-0001.htm>


More information about the Cin mailing list