[Cin] ffmpeg -hwaccel AV1 QSV encoding on Arc GPU executes rapid, but commands?
Terje J. Hanssen
terjejhanssen at gmail.com
Wed Jun 19 02:30:34 CEST 2024
Late last year I posted a thread "[Cin] Prepping HW upgrade options for
AV1 de-/encoding"
https://www.mail-archive.com/cin@lists.cinelerra-gg.org/msg06626.html
and there have also been other threads about hardware acceleration
So here again, I also wanted to give it a first try with ffmpeg -hwaccel
AV1 QSV encoding.
First some system specifications:
inxi -CGS
System:
Host: localhost.localdomain Kernel: 6.9.4-1-default arch: x86_64
bits: 64
Desktop: GNOME v: 46.2 Distro: openSUSE Tumbleweed-Slowroll 20240605
CPU:
Info: 12-core (8-mt/4-st) model: 12th Gen Intel Core i7-12700KF
bits: 64
type: MST AMCP cache: L2: 12 MiB
Speed (MHz): avg: 800 min/max: 800/4900:5000:3800 cores: 1: 800
2: 800
3: 800 4: 800 5: 800 6: 800 7: 800 8: 800 9: 800 10: 800 11:
800 12: 800
13: 800 14: 800 15: 800 16: 800 17: 800 18: 800 19: 800 20: 800
Graphics:
Device-1: Intel DG2 [Arc A750] driver: i915 v: kernel
Device-2: Microdia Camera driver: snd-usb-audio,uvcvideo type: USB
Display: wayland server: X.org v: 1.21.1.12 with: Xwayland v: 24.1.0
compositor: gnome-shell driver: gpu: i915 resolution:
2560x1440~60Hz
API: OpenGL v: 4.6 vendor: intel mesa v: 24.0.8 renderer: Mesa
Intel Arc
A750 Graphics (DG2)
API: EGL Message: EGL data requires eglinfo. Check --recommends.
ls /dev/dri
by-path card1 renderD128
ffmpeg -hide_banner -hwaccels
Hardware acceleration methods:
vdpau
cuda
vaapi
qsv
drm
vulkan
ffmpeg -hide_banner -h encoder=av1_qsv
Encoder av1_qsv [AV1 (Intel Quick Sync Video acceleration)]:
General capabilities: delay hybrid
Threading capabilities: none
Supported hardware devices: qsv qsv qsv
Supported pixel formats: nv12 p010le qsv
av1_qsv encoder AVOptions:
-async_depth <int> E..V....... Maximum processing
parallelism (from 1 to INT_MAX) (default 4)
-preset <int> E..V....... (from 0 to 7) (default 0)
veryfast 7 E..V.......
faster 6 E..V.......
fast 5 E..V.......
medium 4 E..V.......
slow 3 E..V.......
slower 2 E..V.......
veryslow 1 E..V.......
-forced_idr <boolean> E..V....... Forcing I frames as IDR
frames (default false)
-low_power <boolean> E..V....... enable low power
mode(experimental: many limitations by mfx version, BRC modes, etc.)
(default auto)
-b_strategy <int> E..V....... Strategy to choose between
I/P/B-frames (from -1 to 1) (default -1)
-adaptive_i <int> E..V....... Adaptive I-frame placement
(from -1 to 1) (default -1)
-adaptive_b <int> E..V....... Adaptive B-frame placement
(from -1 to 1) (default -1)
-extbrc <int> E..V....... Extended bitrate control (from
-1 to 1) (default -1)
-low_delay_brc <boolean> E..V....... Allow to strictly obey
avg frame size (default auto)
-max_frame_size <int> E..V....... Maximum encoded frame
size in bytes (from -1 to INT_MAX) (default -1)
-max_frame_size_i <int> E..V....... Maximum encoded I
frame size in bytes (from -1 to INT_MAX) (default -1)
-max_frame_size_p <int> E..V....... Maximum encoded P
frame size in bytes (from -1 to INT_MAX) (default -1)
-profile <int> E..V....... (from 0 to INT_MAX) (default
unknown)
unknown 0 E..V.......
main 1 E..V.......
-tile_cols <int> E..V....... Number of columns for tiled
encoding (from 0 to 65535) (default 0)
-tile_rows <int> E..V....... Number of rows for tiled
encoding (from 0 to 65535) (default 0)
-look_ahead_depth <int> E..V....... Depth of look ahead in
number frames, available when extbrc option is enabled (from 0 to
100) (default 0)
--------------
So far I have not found any detailed user guide for this, so suggestions
are welcome.
I have tried to apply a sample command line from the FFmpeg
wiki:Hardware/QuickSync
https://trac.ffmpeg.org/wiki/Hardware/QuickSync#Transcode
ffmpeg -hwaccel qsv -qsv_device /dev/dri/renderD128 -c:v h264_qsv -i
input.mp4 -c:v h264_qsv output.mp4
I added -preset 4 (medium) from above (which gives much more compression
and smaller file size than with -preset 4 for av1_svt).
This didn't seem to change the file size compression compared with the
defaults (without setting preset)
Some visible artifacts (mosaic and stuttering ) is seen during zoom and
pan in the hdv file; probably due to hard compression and/or the memory
allocation error messages, I would guess.
-------------
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
du -sh dv01_07*
389M dv01_07.dv
11M dv01_07_av1_qsv_pr4.webm
24M dv01_07_svt-av1_pr4.webm
27M dv01_07_svt-av1_pr6.webm
28M dv01_07_svt-av1_pr8.webm
31M dv01_07_svt-av1_pr10.webm
33M dv01_07_svt-av1_pr12.webm
du -sh hdv09_04*
745M hdv09_04.m2t
47M hdv09_04.m2t_av1_qsv_pr4.webm
111M hdv09_04_m2t_svt-av1_pr4.webm
119M hdv09_04_m2t_svt-av1_pr6.webm
118M hdv09_04_m2t_svt-av1_pr8.webm
125M hdv09_04_m2t_svt-av1_pr10.webm
134M hdv09_04_m2t_svt-av1_pr12.webm
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 !?
And possibly suggestions regarding the more seriously errors "Cannot
allocate memory" that arised from the second command transcoding the hdv
file?
[mpeg2_qsv @ 0x5596ba3d1500] Failed to allocate a qsv/nv12 frame
from a fixed pool of hardware frames.
[mpeg2_qsv @ 0x5596ba3d1500] Consider setting extra_hw_frames to a
larger value (currently set to 8, giving a pool size of 32).
[mpeg2_qsv @ 0x5596ba3d1500] get_buffer() failed
[vist#0:0/mpeg2video @ 0x5596ba394d00] [dec:mpeg2_qsv @
0x5596ba3921c0] Error submitting packet to decoder: Cannot allocate
memory
[mpeg2_qsv @ 0x5596ba3d1500] get_buffer() failed
[vist#0:0/mpeg2video @ 0x5596ba394d00] [dec:mpeg2_qsv @
0x5596ba3921c0] Error submitting packet to decoder: Cannot allocate
memory
....... skip
[mpegts @ 0x5596ba48c000] PES packet size mismatch0:03:46.20
bitrate=1650.3kbits/s speed=28.3x
[mpegts @ 0x5596ba48c000] Packet corrupt (stream = 1, dts = 258142320).
[mpeg2_qsv @ 0x5596ba3d1500] get_buffer() failed
[vist#0:0/mpeg2video @ 0x5596ba394d00] [dec:mpeg2_qsv @
0x5596ba3921c0] Decoding error: Cannot allocate memory
[mpeg2_qsv @ 0x5596ba3d1500] get_buffer() failed
[vist#0:0/mpeg2video @ 0x5596ba394d00] [dec:mpeg2_qsv @
0x5596ba3921c0] Decoding error: Cannot allocate memory
.......... skip
[mpeg2_qsv @ 0x5596ba3d1500] get_buffer() failed
[mpeg2_qsv @ 0x5596ba3d1500] Too many errors when draining, this is
a bug. Stop draining and force EOF.
[vist#0:0/mpeg2video @ 0x5596ba394d00] [dec:mpeg2_qsv @
0x5596ba3921c0] Decoding error: Internal bug, should not have happened
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
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 @ 0x556a3f643000] Estimating duration from bitrate, this may be
inaccurate
[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".
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
Stream mapping:
Stream #0:0 -> #0:0 (dvvideo (native) -> av1 (av1_qsv))
Stream #0:1 -> #0:1 (pcm_s16le (native) -> opus (libopus))
Press [q] to stop, [?] for help
[libopus @ 0x556a3f656580] No bit rate set. Defaulting to 96000 bps.
[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.
Output #0, webm, to 'dv01_07_av1_qsv_pr4.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, 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
[out#0/webm @ 0x556a3f4da5c0] video:9315KiB audio:1186KiB
subtitle:0KiB other streams:0KiB global headers:0KiB muxing
overhead: 0.505196%
frame= 2832 fps=2106 q=-0.0 Lsize= 10554KiB time=00:01:53.24
bitrate= 763.5kbits/s speed=84.2x
------------------
ffmpeg -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
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 @ 0x5596ba391500] Invalid frame dimensions 0x0.
Last message repeated 3 times
[mpegts @ 0x5596ba48c000] PES packet size mismatch
[mpegts @ 0x5596ba48c000] Packet corrupt (stream = 1, dts = 258142320).
[mpegts @ 0x5596ba48c000] 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 @ 0x5596ba48c000] 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
[vist#0:0/mpeg2video @ 0x5596ba394d00] 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".
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 (mpeg2_qsv) -> av1 (av1_qsv))
Stream #0:1 -> #0:1 (mp2 (native) -> opus (libopus))
Press [q] to stop, [?] for help
[libopus @ 0x5596ba448cc0] No bit rate set. Defaulting to 96000 bps.
[av1_qsv @ 0x5596ba39f1c0] 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.
Output #0, webm, to 'hdv09_04.m2t_av1_qsv_pr4.webm':
Metadata:
encoder : Lavf61.1.100
Stream #0:0: Video: av1, qsv(tv, bt709, top coded first
(swapped)), 1440x1080 [SAR 4:3 DAR 16:9], q=2-31, 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
[mpeg2_qsv @ 0x5596ba3d1500] Failed to allocate a qsv/nv12 frame
from a fixed pool of hardware frames.
[mpeg2_qsv @ 0x5596ba3d1500] Consider setting extra_hw_frames to a
larger value (currently set to 8, giving a pool size of 32).
[mpeg2_qsv @ 0x5596ba3d1500] get_buffer() failed
[vist#0:0/mpeg2video @ 0x5596ba394d00] [dec:mpeg2_qsv @
0x5596ba3921c0] Error submitting packet to decoder: Cannot allocate
memory
[mpeg2_qsv @ 0x5596ba3d1500] get_buffer() failed
[vist#0:0/mpeg2video @ 0x5596ba394d00] [dec:mpeg2_qsv @
0x5596ba3921c0] Error submitting packet to decoder: Cannot allocate
memory
[mpeg2_qsv @ 0x5596ba3d1500] get_buffer() failed
............skip
[mpegts @ 0x5596ba48c000] PES packet size mismatch0:03:46.20
bitrate=1650.3kbits/s speed=28.3x
[mpegts @ 0x5596ba48c000] Packet corrupt (stream = 1, dts = 258142320).
[mpeg2_qsv @ 0x5596ba3d1500] get_buffer() failed
[vist#0:0/mpeg2video @ 0x5596ba394d00] [dec:mpeg2_qsv @
0x5596ba3921c0] Decoding error: Cannot allocate memory
[mpeg2_qsv @ 0x5596ba3d1500] get_buffer() failed
[vist#0:0/mpeg2video @ 0x5596ba394d00] [dec:mpeg2_qsv @
0x5596ba3921c0] Decoding error: Cannot allocate memory
[mpeg2_qsv @ 0x5596ba3d1500] get_buffer() failed
[vist#0:0/mpeg2video @ 0x5596ba394d00] [dec:mpeg2_qsv @
0x5596ba3921c0] Decoding error: Cannot allocate memory
.......skip
[vist#0:0/mpeg2video @ 0x5596ba394d00] [dec:mpeg2_qsv @
0x5596ba3921c0] Decoding error: Cannot allocate memory
[mpeg2_qsv @ 0x5596ba3d1500] get_buffer() failed
[mpeg2_qsv @ 0x5596ba3d1500] Too many errors when draining, this is
a bug. Stop draining and force EOF.
[vist#0:0/mpeg2video @ 0x5596ba394d00] [dec:mpeg2_qsv @
0x5596ba3921c0] Decoding error: Internal bug, should not have happened
[out#0/webm @ 0x5596ba3cc400] video:45422KiB audio:2490KiB
subtitle:0KiB other streams:0KiB global headers:0KiB muxing
overhead: 0.230717%
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cinelerra-gg.org/pipermail/cin/attachments/20240619/5403f292/attachment-0001.htm>
More information about the Cin
mailing list