[Cin] ffmpeg -hwaccel AV1 QSV encoding on Arc GPU executes rapid, but commands?

Terje J. Hanssen terjejhanssen at gmail.com
Thu Jun 20 00:02:06 CEST 2024



On 6/19/24 02:44, Andrew Randrianasulu wrote:
> ------------ skip
>
>
>     -------------
>
>     In short, I have tested the same SD-DV 576i and HDV 1080i video
>     files as with SVT-AV1 (CPU based) in another resent post.
>
>         ffmpeg -hide_banner -hwaccel qsv -qsv_device
>         /dev/dri/renderD128 -i dv01_07.dv -c:v av1_qsv -preset 4
>         dv01_07_av1_qsv_pr4.webm
>         frame= 2832 fps=2106 q=-0.0 Lsize=   10554KiB time=00:01:53.24
>         bitrate= 763.5kbits/s speed=84.2x
>
>         fmpeg -hide_banner -hwaccel qsv -qsv_device
>         /dev/dri/renderD128 -i hdv09_04.m2t -c:v av1_qsv -preset 4
>         hdv09_04.m2t_av1_qsv_pr4.webm
>         frame= 5913 fps=700 q=-0.0 Lsize=   48022KiB time=00:03:58.77
>         bitrate=1647.6kbits/s dup=0 drop=4 speed=28.3x
>
>     ....skip
>

>     A warning output in both command lines is:
>
>         [vist#0:0/dvvideo @ 0x556a3f679100] WARNING: defaulting
>         hwaccel_output_format to qsv for compatibility with old
>         commandlines. This behaviour is DEPRECATED and will be removed
>         in the future. Please explicitly set "-hwaccel_output_format qsv".
>
>     I tried to add this without success, so suggestion is welcome !?
>

I got this succesful now and avoided this warning, see command lines below

>
>
>     And possibly suggestions regarding the more seriously errors
>     "Cannot allocate memory" that arised from the second command
>     transcoding the hdv file?
>
>
>
> well, you tried to add -extra_hw_frames 16 for example to your ffmpeg 
> line? I think mpeg2 is not most popular input codec nowadays ....

Yes, thank you. This worked, see below (not unlike previous extending 
the bufsize for transcoding to mpg(2) for DVD)


> .I attach also the "complete" ffmpeg output FWIW for both files, 
> though skipping repeated error lines:
>
>
>         ffmpeg -hide_banner -hwaccel qsv -qsv_device
>         /dev/dri/renderD128 -i dv01_07.dv -c:v av1_qsv -preset 4
>         dv01_07_av1_qsv_pr4.webm
>         ........skip
>

>         frame= 2832 fps=2106 q=-0.0 Lsize=   10554KiB time=00:01:53.24
>         bitrate= 763.5kbits/s speed=84.2x 
>
> bitrate= 763.5kbits/s
>
> sounds a bit low even for av1, so may be try to set -b to some higher 
> value as suggested?

As suggested where? bitrate= 763.5kbits/s was for SD-DV  which was 
viewable and not quite bad in my eyes.

>
> ====
>
> av1_qsv @ 0x556a3f653040] 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.
> ====
>
>


To make a direct speed performance comparison between this GPU -Hwaccel 
AV1_QSV encoding and my previou CPU based SVT-AV1 encoding, I have used 
the same ffmpeg command line  parameters and preset 4, and iterated 
similar bitrate and file size as follows:

SD-DV -> AV1
------------

    SVT-AV1:
    ffmpeg -hide_banner -i dv01_07.dv -c:v libsvtav1 -preset 4 -crf 35
    -c:a libvorbis dv01_07_svt-av1_pr4.webm
    frame= 2832 fps= 50 q=35.0 Lsize=   24159KiB time=00:01:53.24
    bitrate=1747.7kbits/s speed=   2x

    AV1_QSV:
    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
    -crf 35 -c:a libvorbis dv01_07_av1_qsv_pr4_b1570k.webm
    frame= 2832 fps=1891 q=-0.0 Lsize=   24166KiB time=00:01:53.24
    bitrate=1748.2kbits/s speed=75.6x


That is, AV1_QSV DV transcoding speed 75.6x/2x ~ 38x or fps 1891/50 ~ 38 
faster than corresponding with SVT-AV1.

File sizes:

    389M dv01_07.dv
    24M    dv01_07_svt-av1_pr4.webm
    24M    dv01_07_av1_qsv_pr4_b1557k.webm


HDV -> AV1
----------

    SVT-AV1:
    ffmpeg -hide_banner -i hdv09_04.m2t -c:v libsvtav1 -preset 4 -crf 35
    -c:a libvorbis hdv09_04_svt-av1_pr4.webm
    frame= 5963 fps= 24 q=35.0 Lsize=  113663KiB time=00:03:58.77
    bitrate=3899.6kbits/s speed=0.948x

    AV1_QSV:
    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 3700k hdv09_04_av1_qsv_pr4_bv3700k.webm
    frame= 5963 fps=482 q=-0.0 Lsize=  113271KiB time=00:03:58.77
    bitrate=3886.1kbits/s speed=19.3x


That is, AV1_QSV HDV transcoding speed 19.3x/0.948x ~ 20x or fps 482/24 
~ 20 faster than corresponding with SVT-AV1

File sizes:

    745M hdv09_04.m2t
    111M    hdv09_04_svt-av1_pr4.webm
    111M    hdv09_04_av1_qsv_pr4_bv3700k.webm

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

FFmpeg output for the latest QSV_AV1 transcoding follows.
As seen the error messages messages are gone, though not quite clean as 
there are still some "disturbing" mpeg2video messages.

SD-DV -> AV1
----------
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 -crf 
35 -c:a libvorbis dv01_07_av1_qsv_pr4_b1570k.webm

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
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
[dv @ 0x5614ce553080] Estimating duration from bitrate, this may be 
inaccurate
Input #0, dv, from 'dv01_07.dv':
   Metadata:
     timecode        : 01:09:35:09
   Duration: 00:01:53.28, start: 0.000000, bitrate: 28800 kb/s
   Stream #0:0: Video: dvvideo, yuv420p, 720x576 [SAR 16:15 DAR 4:3], 
28800 kb/s, 60k fps, 25 tbr, 60k tbn
   Stream #0:1: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[out#0/webm @ 0x5614ce3ea640] Codec AVOption crf (Select the quality for 
constant quality mode) 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 encoder which was not actually 
used for any stream.
Stream mapping:
   Stream #0:0 -> #0:0 (dvvideo (native) -> av1 (av1_qsv))
   Stream #0:1 -> #0:1 (pcm_s16le (native) -> vorbis (libvorbis))
Press [q] to stop, [?] for help
Output #0, webm, to 'dv01_07_av1_qsv_pr4_b1570k.webm':
   Metadata:
     timecode        : 01:09:35:09
     encoder         : Lavf61.1.100
   Stream #0:0: Video: av1, nv12(bottom coded first (swapped)), 720x576 
[SAR 16:15 DAR 4:3], q=2-31, 1570 kb/s, 25 fps, 1k tbn
       Metadata:
         encoder         : Lavc61.3.100 av1_qsv
   Stream #0:1: Audio: vorbis, 48000 Hz, stereo, fltp
       Metadata:
         encoder         : Lavc61.3.100 libvorbis
[out#0/webm @ 0x5614ce3ea640] video:22613KiB audio:1495KiB subtitle:0KiB 
other streams:0KiB global headers:4KiB muxing overhead: 0.244968%
frame= 2832 fps=1891 q=-0.0 Lsize=   24166KiB time=00:01:53.24 
bitrate=1748.2kbits/s speed=75.6x


HDV->AV1
---------
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 3700k hdv09_04_av1_qsv_pr4_bv3700k.webm

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
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
[mpeg2video @ 0x5607564ea600] Invalid frame dimensions 0x0.
     Last message repeated 3 times
[mpegts @ 0x56075643ee00] PES packet size mismatch
[mpegts @ 0x56075643ee00] Packet corrupt (stream = 1, dts = 258142320).
[mpegts @ 0x56075643ee00] Could not find codec parameters for stream 2 
(Unknown: none ([160][0][0][0] / 0x00A0)): unknown codec
Consider increasing the value for the 'analyzeduration' (0) and 
'probesize' (5000000) options
[mpegts @ 0x56075643ee00] Could not find codec parameters for stream 3 
(Unknown: none ([161][0][0][0] / 0x00A1)): unknown codec
Consider increasing the value for the 'analyzeduration' (0) and 
'probesize' (5000000) options
Input #0, mpegts, from 'hdv09_04.m2t':
   Duration: 00:03:59.06, start: 2629.496000, bitrate: 26110 kb/s
   Program 100
   Stream #0:0[0x810]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), 
yuv420p(tv, bt709, top first), 1440x1080 [SAR 4:3 DAR 16:9], 25000 kb/s, 
25 fps, 25 tbr, 90k tbn
       Side data:
         cpb: bitrate max/min/avg: 25000000/0/0 buffer size: 7340032 
vbv_delay: N/A
   Stream #0:1[0x814]: Audio: mp2 (mp3float) ([3][0][0][0] / 0x0003), 
48000 Hz, stereo, fltp, 384 kb/s
   Stream #0:2[0x815]: Unknown: none ([160][0][0][0] / 0x00A0)
   Stream #0:3[0x811]: Unknown: none ([161][0][0][0] / 0x00A1)
Stream mapping:
   Stream #0:0 -> #0:0 (mpeg2video (native) -> av1 (av1_qsv))
   Stream #0:1 -> #0:1 (mp2 (native) -> opus (libopus))
Press [q] to stop, [?] for help
[libopus @ 0x560756595f80] No bit rate set. Defaulting to 96000 bps.
Output #0, webm, to 'hdv09_04_av1_qsv_pr4_bv3700k.webm':
   Metadata:
     encoder         : Lavf61.1.100
   Stream #0:0: Video: av1, nv12(tv, bt709, top coded first (swapped)), 
1440x1080 [SAR 4:3 DAR 16:9], q=2-31, 3700 kb/s, 25 fps, 1k tbn
       Metadata:
         encoder         : Lavc61.3.100 av1_qsv
   Stream #0:1: Audio: opus, 48000 Hz, stereo, s16, 96 kb/s
       Metadata:
         encoder         : Lavc61.3.100 libopus
[mpegts @ 0x56075643ee00] PES packet size mismatch0:03:51.36 
bitrate=3834.3kbits/s speed=19.3x
[mpegts @ 0x56075643ee00] Packet corrupt (stream = 1, dts = 258142320).
[mpeg2video @ 0x560756595500] ac-tex damaged at 10 61
[mpeg2video @ 0x560756595500] Warning MVs not available
[mpeg2video @ 0x560756595500] concealing 630 DC, 630 AC, 630 MV errors 
in P frame
[vist#0:0/mpeg2video @ 0x5607564f6940] [dec:mpeg2video @ 0x560756440480] 
corrupt decoded frame
[out#0/webm @ 0x5607565b2040] video:110669KiB audio:2490KiB 
subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 
0.098391%
frame= 5963 fps=482 q=-0.0 Lsize=  113271KiB time=00:03:58.77 
bitrate=3886.1kbits/s speed=19.3x


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cinelerra-gg.org/pipermail/cin/attachments/20240620/d33bfad1/attachment-0001.htm>


More information about the Cin mailing list