[Cin] 10bit av1 and h264 QSV and VAAPI encoding

Andrew Randrianasulu randrianasulu at gmail.com
Sun Nov 17 19:53:23 CET 2024


вс, 17 нояб. 2024 г., 20:50 Terje J. Hanssen <terjejhanssen at gmail.com>:

>
>
>
> Den 17.11.2024 11:53, skrev Andrew Randrianasulu:
>
>
>
> вс, 17 нояб. 2024 г., 13:24 Terje J. Hanssen <terjejhanssen at gmail.com>:
>
>>
>> Den 16.11.2024 23:24, skrev Terje J. Hanssen:
>>
>>
>>
>>
>> Den 16.11.2024 22:20, skrev Andrew Randrianasulu:
>>
>>
>>
>> вс, 17 нояб. 2024 г., 00:02 Terje J. Hanssen <terjejhanssen at gmail.com>:
>>
>>>
>>>
>>>
>>> Den 16.11.2024 20:36, skrev Terje J. Hanssen:
>>>
>>>
>>>
>>>
>>> Den 16.11.2024 19:00, skrev Andrew Randrianasulu:
>>>
>>>
>>>
>>> сб, 16 нояб. 2024 г., 20:56 Terje J. Hanssen via Cin <
>>> cin at lists.cinelerra-gg.org>:
>>>
>>>> Now when 10bit hevc_qsv and hevc_vaapi accelerated encoding looks to be
>>>> in box, I wonder if something prohibits us to get accelerated encoding for
>>>> av1 and h264?
>>>>
>>>
>>> I think av1 was complaining about invalid picture structure?
>>>
>>>
>>> feel free to experiment. You can also try vp9 ....
>>>
>>>
>>>
>>>> According to ffmpeg help the following support should be available:
>>>>
>>>> av1_qsv
>>>>     Supported pixel formats: nv12 p010le qsv
>>>>   -profile           <int>        E..V....... (from 0 to INT_MAX)
>>>> (default unknown)
>>>>      unknown         0            E..V.......
>>>>      main            1            E..V.......
>>>>
>>>> av1_vaapi
>>>>     Supported pixel formats: vaapi
>>>>   -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.......
>>>>
>>> ..........h264 snip
>>>>
>>> =============================
>>>
>>> Starting tests with
>>>
>>> /Cin # bin/cin
>>> Cinelerra Infinity - built: Nov 15 2024 20:29:14
>>>
>>>
>>> 1) AV1_QSV
>>> -----------
>>>
>>> av1_qsv.mp4
>>>
>>> mp4 av1_qsv
>>> # only usable with ext. ffmpeg
>>> cin_pix_fmt=nv12
>>>
>>> DV input renders ok to yuv420p
>>> ** rendered 2832 frames in 5.475 secs, 517.260 fps
>>>
>>> HDV input fails:
>>> [av1_qsv @ 0x7ff7cca8b9c0] Current picture structure is unsupported
>>> [av1_qsv @ 0x7ff7cca8b9c0] some encoding parameters are not supported by
>>> the QSV runtime. Please double check the input parameters.
>>> FFMPEG::open_encoder  err: Function not implemented
>>> int FFMPEG::open_encoder(const char*, const char*):
>>> open failed av1_qsv:/Videoklipp/QSV/hdv09_04_av1_qsv.mp4
>>>
>>> FHD input fails
>>> [av1_qsv @ 0x7ff7918e82c0] Current picture structure is unsupported
>>> [av1_qsv @ 0x7ff7918e82c0] some encoding parameters are not supported by
>>> the QSV runtime. Please double check the input parameters.
>>> FFMPEG::open_encoder  err: Function not implemented
>>> int FFMPEG::open_encoder(const char*, const char*):
>>> open failed av1_qsv:/Videoklipp/QSV/hd01_av1_qsv.mp4
>>>
>>>
>> After this overview:
>>
>> I modified ffmpeg/encode.opts to loglevel=debug and tried to render HDV
>> (and FHD) again:
>>
>> [AVHWDeviceContext @ 0x7f99881fee40] Trying to use DRM render node for
>> device 0.
>> [AVHWDeviceContext @ 0x7f99881fee40] libva: VA-API version 1.22.0
>> [AVHWDeviceContext @ 0x7f99881fee40] libva: User requested driver 'iHD'
>> [AVHWDeviceContext @ 0x7f99881fee40] libva: Trying to open
>> /usr/lib64/dri/iHD_drv_video.so
>> [AVHWDeviceContext @ 0x7f99881fee40] libva: Found init function
>> __vaDriverInit_1_22
>> [AVHWDeviceContext @ 0x7f99881fee40] libva: va_openDriver() returns 0
>> [AVHWDeviceContext @ 0x7f99881fee40] Initialised VAAPI connection:
>> version 1.22
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x41524742 -> bgra.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x41424752 -> rgba.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x58524742 -> bgr0.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x58424752 -> rgb0.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x30335241 -> unknown.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x30334241 -> unknown.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x30335258 -> x2rgb10le.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x30334258 -> unknown.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x36314752 -> unknown.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x56555941 -> unknown.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x56555958 -> vuyx.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x30303859 -> gray.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x3231564e -> nv12.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x3132564e -> unknown.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x32595559 -> yuyv422.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x59565955 -> uyvy422.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x32315659 -> yuv420p.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x30323449 -> yuv420p.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x50313134 -> yuv411p.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x48323234 -> yuv422p.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x56323234 -> yuv440p.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x50343434 -> yuv444p.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x33434d49 -> unknown.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x30313050 -> p010le.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x32313050 -> p012le.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x36313050 -> unknown.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x30313259 -> y210le.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x32313259 -> y212le.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x36313259 -> unknown.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x30313459 -> xv30le.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x32313459 -> xv36le.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x36313459 -> unknown.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x50424752 -> unknown.
>> [AVHWDeviceContext @ 0x7f99881fee40] Format 0x50524742 -> unknown.
>> [AVHWDeviceContext @ 0x7f99881fee40] VAAPI driver: Intel iHD driver for
>> Intel(R) Gen Graphics - 24.4.0 ().
>> [AVHWDeviceContext @ 0x7f99881fee40] Driver not found in known
>> nonstandard list, using standard behaviour.
>> [av1_qsv @ 0x7f99880565c0] Initialized an internal MFX session using
>> hardware accelerated implementation
>> [av1_qsv @ 0x7f99880565c0] 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 @ 0x7f99880565c0] Using the constant quantization parameter
>> (CQP) ratecontrol method
>> [av1_qsv @ 0x7f99880565c0] Current picture structure is unsupported
>> [av1_qsv @ 0x7f99880565c0] some encoding parameters are not supported by
>> the QSV runtime. Please double check the input parameters.
>> FFMPEG::open_encoder  err: Function not implemented
>> int FFMPEG::open_encoder(const char*, const char*):
>> open failed av1_qsv:/Videoklipp/QSV/hdv09_04_av1_qsv.mp4
>> Render::render_single: Session finished.
>>
>
> Sorry, but even with additional msgs  root case of this problem is not
> clearer at all for me.
>
> You tried with progressive/deinterlaced source, with everything set to
> progressive?
>
> Isn't point of this thread to get 10bit, 10bit + yuv422 encoder presets
> working? I suggest to put aside obviously failing ones for now.
>
>
>
> I think AV1-10bit yuv422 is only supported by librav1e software encoding
> yet.
>
> But av1_qsv encoding 8bit (nv12) and 10bit 420 (p010)  is supported by
> ffmpeg.
> The following command works for me for me with HDV and FHD interlaced
> input:
>
> HDV --> av1_qsv -global_quality 25
> -----------------------------------
> ffmpeg -hide_banner -qsv_device /dev/dri/renderD128 -i hdv09_04.m2t
> -pix_fmt nv12 -c:v av1_qsv -global_quality 25
> hdv09_04_av1_qsv_format_nv12_gq25.mp4
>
> ffprobe -hide_banner hdv09_04_av1_qsv_format_nv12_gq25.mp4
>   Stream #0:0[0x1](und): Video: av1 (libdav1d) (Main) (av01 / 0x31307661),
> yuv420p(tv, bt709, top coded first (swapped)), 1440x1080, 7902 kb/s, SAR
> 4:3 DAR 16:9, 24.99 fps, 25 tbr, 12800 tbn (default)
>
>
> FHD --> av1_qsv -global_quality 25
> -----------------------------------
> ffmpeg -hide_banner -qsv_device /dev/dri/renderD128 -i cfhd01.mkv -pix_fmt
> p010 -c:v av1_qsv -global_quality 25 cfhd01_av1_qsv_format_p010_gq25.mp4
>
> ffprobe -hide_banner cfhd01_av1_qsv_format_p010_gq25.mp4
>   Stream #0:0[0x1](eng): Video: av1 (libdav1d) (Main) (av01 / 0x31307661),
> yuv420p10le(tv, bt709, progressive), 1920x1080, 5761 kb/s, SAR 1:1 DAR
> 16:9, 25 fps, 25 tbr, 12800 tbn (default)
>
>
> ffmpeg output some mpeg warnings in the HDV file, but renders it seemingly
> ok
>
> [mpegts @ 0x560dbed1b800] PES packet size mismatch0:03:56.16
> bitrate=8036.6kbits/s speed=22.5x
> [mpegts @ 0x560dbed1b800] Packet corrupt (stream = 1, dts = 258142320).
> [mpeg2video @ 0x560dbec663c0] ac-tex damaged at 10 61
> [mpeg2video @ 0x560dbec663c0] Warning MVs not available
> [mpeg2video @ 0x560dbec663c0] concealing 630 DC, 630 AC, 630 MV errors in
> P frame
> [vist#0:0/mpeg2video @ 0x560dbedd2f40] [dec:mpeg2video @ 0x560dbecb4140]
> corrupt decoded frame
> [out#0/mp4 @ 0x560dbec67440] video:230191KiB audio:3787KiB subtitle:0KiB
> other streams:0KiB global headers:0KiB muxing overhead: 0.051687%
> frame= 5963 fps=561 q=-0.0 Lsize=  234099KiB time=00:03:58.77
> bitrate=8031.5kbits/s speed=22.5x
>
>
> I tried to adapt my hevc_qsv preset for av1_qsv as follows
>
> av1_qsv_8b420.mp4
>
> mp4 av1_qsv
> # av1_qsv_8b420
> # usable with Pixels: nv12
> profile=main
> global_quality=25
>
>
> but attempt to render the same HDV file fails with the following output
>
> [av1_qsv @ 0x7fd604299600] Encoder: input is system memory surface
> [av1_qsv @ 0x7fd604299600] Use Intel(R) oneVPL to create MFX session, the
> required implementation version is 1.1
> libva info: VA-API version 1.22.0
> libva info: Trying to open /usr/lib64/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/lib64/dri/iHD_drv_video.so
> libva info: Found init function __vaDriverInit_1_22
> libva info: va_openDriver() returns 0
> [AVHWDeviceContext @ 0x7fd60408bd40] Trying to use DRM render node for
> device 0.
> [AVHWDeviceContext @ 0x7fd60408bd40] libva: VA-API version 1.22.0
> [AVHWDeviceContext @ 0x7fd60408bd40] libva: User requested driver 'iHD'
> [AVHWDeviceContext @ 0x7fd60408bd40] libva: Trying to open
> /usr/lib64/dri/iHD_drv_video.so
> [AVHWDeviceContext @ 0x7fd60408bd40] libva: Found init function
> __vaDriverInit_1_22
> [AVHWDeviceContext @ 0x7fd60408bd40] libva: va_openDriver() returns 0
> [AVHWDeviceContext @ 0x7fd60408bd40] Initialised VAAPI connection: version
> 1.22
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x41524742 -> bgra.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x41424752 -> rgba.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x58524742 -> bgr0.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x58424752 -> rgb0.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x30335241 -> unknown.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x30334241 -> unknown.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x30335258 -> x2rgb10le.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x30334258 -> unknown.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x36314752 -> unknown.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x56555941 -> unknown.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x56555958 -> vuyx.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x30303859 -> gray.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x3231564e -> nv12.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x3132564e -> unknown.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x32595559 -> yuyv422.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x59565955 -> uyvy422.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x32315659 -> yuv420p.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x30323449 -> yuv420p.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x50313134 -> yuv411p.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x48323234 -> yuv422p.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x56323234 -> yuv440p.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x50343434 -> yuv444p.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x33434d49 -> unknown.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x30313050 -> p010le.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x32313050 -> p012le.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x36313050 -> unknown.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x30313259 -> y210le.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x32313259 -> y212le.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x36313259 -> unknown.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x30313459 -> xv30le.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x32313459 -> xv36le.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x36313459 -> unknown.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x50424752 -> unknown.
> [AVHWDeviceContext @ 0x7fd60408bd40] Format 0x50524742 -> unknown.
> [AVHWDeviceContext @ 0x7fd60408bd40] VAAPI driver: Intel iHD driver for
> Intel(R) Gen Graphics - 24.4.0 ().
> [AVHWDeviceContext @ 0x7fd60408bd40] Driver not found in known nonstandard
> list, using standard behaviour.
> [av1_qsv @ 0x7fd604299600] Initialized an internal MFX session using
> hardware accelerated implementation
> [av1_qsv @ 0x7fd604299600] Using the intelligent constant quality (ICQ)
> ratecontrol method
> [av1_qsv @ 0x7fd604299600] Current picture structure is unsupported
>

I think this error comes from

http://git.ffmpeg.org/gitweb/ffmpeg.git/blob/refs/heads/release/7.0:/libavcodec/qsvenc.c

     if (UNMATCH(FrameInfo.PicStruct))
 689               av_log(avctx, AV_LOG_ERROR, "Current picture structure
is unsupported\n");

    if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
 850         // it is important that PicStruct be setup correctly from the
 851         // start--otherwise, encoding doesn't work and results in a
bunch
 852         // of incompatible video parameter errors
 853         q->param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_TFF;
 854         // height alignment always must be 32 for interlaced video
 855         q->height_align = 32;
 856     } else {
 857         q->param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
 858         // for progressive video, the height should be aligned to 16
for
 859         // H.264.  For HEVC, depending on the version of MFX, it
should be
 860         // either 32 or 16.  The lower number is better if possible.
 861         // For AV1, it is 32
 862         q->height_align = (avctx->codec_id == AV_CODEC_ID_HEVC ||
 863                            avctx->codec_id == AV_CODEC_ID_AV1) ? 32 :
16;
 864     }
 865     q->param.mfx.FrameInfo.Height = FFALIGN(avctx->height,
q->height_align);


2030
2031         qf->surface.Info.PicStruct =
2032             !(frame->flags & AV_FRAME_FLAG_INTERLACED) ?
MFX_PICSTRUCT_PROGRESSIVE :
2033             (frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ?
MFX_PICSTRUCT_FIELD_TFF :
2034                                        MFX_PICSTRUCT_FIELD_BFF;



i.e. common code for all qsv encoders?

so *I think* it only test  for either bff or tff and fails if +ildct flag
actually set.

you can try to add it ffmpeg line and see if it starts to fail

BUT


can you test progressive or bff source in cingg ??

i do not ask just for lulz, I want to understand *where* it fails, and does
this mean we need to ask ffmpeg guys todo something or alter ourselves.

So, *PLEASE* do progressive/bff test!




[av1_qsv @ 0x7fd604299600] some encoding parameters are not supported by
> the QSV runtime. Please double check the input parameters.
> FFMPEG::open_encoder  err: Function not implemented
> int FFMPEG::open_encoder(const char*, const char*):
> open failed av1_qsv:/Videoklipp/QSV/hdv09_04_av1_qsv.mp4
> Render::render_single: Session finished.
> Connection failure: Connection refused
> pa_context_connect() failed: Connection refused
>
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cinelerra-gg.org/pipermail/cin/attachments/20241117/7cbd5e72/attachment-0001.htm>


More information about the Cin mailing list