Den 03.11.2024 00:52, skrev Terje J. Hanssen:



Den 03.11.2024 00:09, skrev Andrew Randrianasulu:


On Sat, Nov 2, 2024 at 8:15 PM Terje J. Hanssen via Cin <cin@lists.cinelerra-gg.org> wrote:

Den 01.11.2024 19:34, skrev Phyllis Smith:
Terje, thank you for this comprehensive list of vaapi supported encodings.

On Thu, Oct 31, 2024 at 5:38 PM Terje J. Hanssen via Cin <cin@lists.cinelerra-gg.org> wrote:
In hope it may be of some use for Cingg next, I make a summary and supplement to the guide in https://trac.ffmpeg.org/wiki/Hardware/VAAPI#Encoding
And instead of adding a tail to already too long recent threads, I start a new thread here.

Two additional references are used
Developer Reference: Media Capabilities Supported by Intel Hardware
https://www.intel.com/content/www/us/en/docs/onevpl/developer-reference-media-intel-hardware/1-1/features-and-formats.html
Supported Encoding Input Format and Max Resolution
https://github.com/intel/media-driver/blob/master/docs/media_features.md#supported-encoding-input-format-and-max-resolution

to clarify the Encode Features for my own Intel Arc A-series Discrete Graphics

HEVC (fixed-function hardware + shader-based)
 8-bit, 4:2:0 (NV12)
10-bit, 4:2:0 (P010)
 8-bit, 4:2:2 (YUY2, Windows only)
10-bit, 4:2:2 (Y210)

AV1
 8-bit, 4:2:0 (NV12)
10-bit, 4:2:0 (P010)


A short reminder:
8-bit vs 10-bit color depths is 256 vs 1024 color levels of each RGB color, or 16.7 mill. vs 1.0 bill colors.
4:2:0 vs 4:2:2 color sub-sampling is keeping 1/4 vs 1/2 of all 4:4:4 colors or the precision of color compression.
https://fujifilm-x.com/en-us/series/the-filmmakers-handbook/8-bit-or-10-bit-video-color-explained/


An important point to notice is that the VAAPI encoding 'formats' are based on those in the parentheses () above.

Three simplified ffmpeg code lines with default bit-rates and without audio are used in the following three examples.
Resulting fps encoding counts or speeds are the same in all cases; I don't know why.


The input file used:

ffprobe -hide_banner cfhd01.mkv
Input #0, matroska,webm, from 'cfhd01.mkv':
  Metadata:
    ENCODER         : Lavf61.1.100
  Duration: 00:01:11.24, start: 0.000000, bitrate: 393480 kb/s
  Stream #0:0(eng): Video: cfhd (CFHD / 0x44484643), yuv422p10le(tv, bt709, top coded first (swapped)), 1920x1080, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 1k tbn (default)
      Metadata:
        HANDLER_NAME    : Apple Video Media Handler
        VENDOR_ID       : appl
        ENCODER         : Lavc61.3.100 cfhd
        DURATION        : 00:01:11.240000000


1)
8-bit yuv420p hevc vaapi encoding using -vf 'format=nv12,hwupload'
------------------------------------------------------------------
ffmpeg -hide_banner -vaapi_device /dev/dri/renderD128 -i cfhd01.mkv -vf 'format=nv12,hwupload' -c:v av1_vaapi cfhd01_av1_vaapi_format_nv12.mp4
............
frame= 1781 fps= 46 q=-0.0 Lsize=  104132KiB time=00:01:11.24 bitrate=11974.3kbits/s speed=1.83x


ffprobe -hide_banner cfhd01_av1_vaapi_format_nv12.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'cfhd01_av1_vaapi_format_nv12.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomav01iso2mp41
    encoder         : Lavf61.7.100
  Duration: 00:01:11.24, start: 0.000000, bitrate: 11974 kb/s
  Stream #0:0[0x1](eng): Video: av1 (libdav1d) (Main) (av01 / 0x31307661), yuv420p(tv, bt709, progressive), 1920x1080, 11973 kb/s, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 12800 tbn (default)
      Metadata:
        handler_name    : Apple Video Media Handler
        vendor_id       : [0][0][0][0]
        encoder         : Lavc61.19.100 av1_vaapi


2)
10-bit yuv420p10le hevc vaapi encoding using -vf 'format=p010,hwupload'
-----------------------------------------------------------------------
ffmpeg -hide_banner -vaapi_device /dev/dri/renderD128 -i cfhd01.mkv -vf 'format=p010,hwupload' -c:v av1_vaapi cfhd01_av1_vaapi_format_p010.mp4
.............
frame= 1781 fps= 46 q=-0.0 Lsize=  111924KiB time=00:01:11.24 bitrate=12870.3kbits/s speed=1.82x


ffprobe -hide_banner cfhd01_av1_vaapi_format_p010.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'cfhd01_av1_vaapi_format_p010.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomav01iso2mp41
    encoder         : Lavf61.7.100
  Duration: 00:01:11.24, start: 0.000000, bitrate: 12870 kb/s
  Stream #0:0[0x1](eng): Video: av1 (libdav1d) (Main) (av01 / 0x31307661), yuv420p10le(tv, bt709, progressive), 1920x1080, 12869 kb/s, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 12800 tbn (default)
      Metadata:
        handler_name    : Apple Video Media Handler
        vendor_id       : [0][0][0][0]
        encoder         : Lavc61.19.100 av1_vaapi

3)
10-bit yuv422p10le hevc_vaapi encoding using -vf 'format=y210,hwupload'
-----------------------------------------------------------------------
ffmpeg -hide_banner -vaapi_device /dev/dri/renderD128 -i cfhd01.mkv -vf 'format=y210,hwupload' -c:v hevc_vaapi cfhd01_hevc_vaapi_format_y210.mp4
frame= 1781 fps= 46 q=-0.0 Lsize=  105482KiB time=00:01:11.20 bitrate=12136.3kbits/s speed=1.83x


ffprobe -hide_banner cfhd01_hevc_vaapi_format_y210.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'cfhd01_hevc_vaapi_format_y210.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf61.7.100
  Duration: 00:01:11.24, start: 0.000000, bitrate: 12129 kb/s
  Stream #0:0[0x1](eng): Video: hevc (Rext) (hev1 / 0x31766568), yuv422p10le(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 12127 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
      Metadata:
        handler_name    : Apple Video Media Handler
        vendor_id       : [0][0][0][0]
        encoder         : Lavc61.19.100 hevc_vaapi  




It was also interesting to standardize that the corresponding ffmpeg syntax above works for both vaapi/qsv and hevc/av1:

- replace vaapi with qsv in 1) 2) and 3) above
- and if applicable: replace hevc with av1 in 1) and 2) above 


The default bitrates used do vary a lot as seen on listed output file sizes:
19M    cfhd01_hevc_qsv_format_nv12.mp4
92M    cfhd01_hevc_vaapi_format_nv12.mp4

224M   cfhd01_hevc_qsv_format_p010.mp4
90M    cfhd01_hevc_vaapi_format_p010.mp4

270M   cfhd01_hevc_qsv_format_y210.mp4
104M   cfhd01_hevc_vaapi_format_y210.mp4
----------------

9,1M   cfhd01_av1_qsv_format_nv12.mp4
102M   cfhd01_av1_vaapi_format_nv12.mp4

9,1M   cfhd01_av1_qsv_format_p010.mp4
110M   cfhd01_av1_vaapi_format_p010.mp4


yes, last four lines seem say that qsv and vaapi AV1 encoders use   wildly different defaults for bitrate ....
 

Yes, and it looks like especially av1_qsv is highly optimized, because it is not bad to look at. The 10x larger av1_vaapi is at bit sharper and smoother at pan/tilt movements (I used tripod for the original source camcording to a HDMI connected BD hyperdeck shuttle. Later I transcoded this test file to cfhd as intermediate format with ffmpeg).
Another thing I mentioned in my first post here, is that the encoding speed in all these cases independent of bitrate, looks to be about the same 45-46 fps

I add here the ffprobe outputs to compare for the two latter lines:

9,1M   cfhd01_av1_qsv_format_p010.mp4
ffprobe -hide_banner cfhd01_av1_qsv_format_p010.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'cfhd01_av1_qsv_format_p010.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomav01iso2mp41
    encoder         : Lavf61.7.100
  Duration: 00:01:11.24, start: 0.000000, bitrate: 1062 kb/s
  Stream #0:0[0x1](eng): Video: av1 (libdav1d) (Main) (av01 / 0x31307661), yuv420p10le(tv, bt709, progressive), 1920x1080, 1061 kb/s, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 12800 tbn (default)
      Metadata:
        handler_name    : Apple Video Media Handler
        vendor_id       : [0][0][0][0]
        encoder         : Lavc61.19.100 av1_qsv
-----------------

110M   cfhd01_av1_vaapi_format_p010.mp4
ffprobe -hide_banner cfhd01_av1_vaapi_format_p010.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'cfhd01_av1_vaapi_format_p010.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomav01iso2mp41
    encoder         : Lavf61.7.100
  Duration: 00:01:11.24, start: 0.000000, bitrate: 12870 kb/s
  Stream #0:0[0x1](eng): Video: av1 (libdav1d) (Main) (av01 / 0x31307661), yuv420p10le(tv, bt709, progressive), 1920x1080, 12869 kb/s, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 12800 tbn (default)
      Metadata:
        handler_name    : Apple Video Media Handler
        vendor_id       : [0][0][0][0]
        encoder         : Lavc61.19.100 av1_vaapi




Some quality option notices from the ffmpeg encoding outputs:

[hevc_vaapi@ 0x558fd14e9740] No quality level set; using default (25).

[av1_vaapi @ 0x559d44056740] No quality level set; using default (25).

-----------

[hevc_qsv @ 0x55834b200500] Using the constant quantization parameter (CQP) by default. Please use the global_quality option and other options for a quality-based mode or the b option and other options for a bitrate-based mode if the default is not the desired choice.

[av1_qsv @ 0x558ed655f400] Using the constant quantization parameter (CQP) by default. Please use the global_quality option and other options for a quality-based mode or the b option and other options for a bitrate-based mode if the default is not the desired choice.


And by listing other related parameter options from the ffmpeg help:

ffmpeg -hide_banner -h encoder=hevc_vaapi | egrep -i 'quality|global_quality|bitrate|profile|preset'
     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 (general_profile_idc) (from -99 to 255) (default -99)

ffmpeg -hide_banner -h encoder=av1_vaapi | egrep -i 'quality|global_quality|bitrate|profile|preset'
     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)

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

ffmpeg -hide_banner -h encoder=hevc_qsv | egrep -i 'quality|global_quality|bitrate|profile|preset'
  -preset            <int>        E..V....... (from 0 to 7) (default 0)
  -mbbrc             <int>        E..V....... MB level bitrate control (from -1 to 1) (default -1)
  -extbrc            <int>        E..V....... Extended bitrate control (from -1 to 1) (default -1)
  -profile           <int>        E..V....... (from 0 to INT_MAX) (default unknown)

ffmpeg -hide_banner -h encoder=av1_qsv | egrep -i 'quality|global_quality|bitrate|profile|preset'
  -preset            <int>        E..V....... (from 0 to 7) (default 0)
  -extbrc            <int>        E..V....... Extended bitrate control (from -1 to 1) (default -1)
  -profile           <int>        E..V....... (from 0 to INT_MAX) (default unknown)