[FFmpeg-user] Using a AMD Radeon RX5xx with ffmpeg

Dennis Mungai dmngaie at gmail.com
Mon Jul 23 23:51:17 EEST 2018


Hello there,

Here's something you can try:

ffmpeg -init_hw_device vaapi=amd:/dev/dri/renderD129 -hwaccel vaapi
-hwaccel_output_format vaapi -hwaccel_device amd -filter_hw_device amd -i
fs_experiental_method.avi -vf 'format=nv12|vaapi,hwupload' -y -c:v
h264_vaapi -qp:v 21 -sei +identifier+timing+recovery_point -profile:v main
-level 4 output.avi

Assumptions made:

1. You have another GPU on the system. See the DRI device you highlighted
(/dev/dri/card1) is implied to be the second render node because the first
ordinal device would have been /dev/dri/card0, mapped to
/dev/dri/renderD128.

Confirm this by providing the output of:

(a). vainfo
(b). ls -al /dev/dri/

2. We explicitly initialize and name the hardware device
(/dev/dri/renderD129) to 'amd' and pass it to both the decoder, encoder and
the video filtergraph.

3. Observe the video filter graph. Here's what it does: The decoder will
output either vaapi surfaces (if the hwaccel is usable) or software frames
(if it isn't). In the first case, it matches the vaapi format and hwupload
does nothing (it passes through hardware frames unchanged). In the second
case, it matches the nv12 format and converts whatever the input is to
that, then uploads.

This is done for safety reasons: Either way, the encoder will run. However,
depending on the path chosen (upload to memory vs native VAAPI hwdec), your
performance may vary.

Reference used:

1. The VAAPI entry on FFmpeg wiki:
https://trac.ffmpeg.org/wiki/Hardware/VAAPI

2. The VAAPI encoders entry in the docs:
http://www.ffmpeg.org/ffmpeg-codecs.html#VAAPI-encoders

On 23 July 2018 at 22:30, Lukas Obermann <obermann.lukas at gmail.com> wrote:

> Hi all,
>
> I want to use a RX570 for transcoding with ffmpeg. Have been looking into
> this for some time now and testing around various things.
> I use Ubuntu 18.04 and I have it running with VAAPI. But the performance
> is not good imo. For a 1080p file I only get like 1.8x speed. I was
> expecting something around 6x to 8x.
> Is VAAPI the right way to go here? I see that AMF is not yet ready for
> linux and VDPAU only support decoding, not encoding.
>
> Following is the command:
> ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/card1 -hwaccel_output_format
> vaapi -i fs_experiental_method.avi -y -c:v h264_vaapi -profile:v main
> output.avi
>
> ffmpeg version n4.0.2
> mesa 18
> amdgpu-pro-18.20-606296
> libva: VA-API version 1.1.0
>
> And here below the non-debug output of the command, to show the formats.
> I would appreciate any help on this.
>
> Thanks!
> Lukas
>
>
> ffmpeg version n4.0.2-2 Copyright (c) 2000-2018 the FFmpeg developers
>   built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
>   configuration: --prefix=/usr --extra-version=2 --toolchain=hardened
> --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu
> --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib
> --enable-gpl --disable-stripping --enable-avresample --enable-avisynth
> --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray
> --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite
> --enable-libfontconfig --enable-libfreetype --enable-libfribidi
> --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa
> --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse
> --enable-librubberband --enable-librsvg --enable-libshine
> --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh
> --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx
> --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2
> --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx
> --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394
> --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r
> --enable-libx264 --enable-shared --enable-vaapi --enable-vdpau
>   libavutil      56. 14.100 / 56. 14.100
>   libavcodec     58. 18.100 / 58. 18.100
>   libavformat    58. 12.100 / 58. 12.100
>   libavdevice    58.  3.100 / 58.  3.100
>   libavfilter     7. 16.100 /  7. 16.100
>   libavresample   4.  0.  0 /  4.  0.  0
>   libswscale      5.  1.100 /  5.  1.100
>   libswresample   3.  1.100 /  3.  1.100
>   libpostproc    55.  1.100 / 55.  1.100
> Input #0, avi, from 'fs_experiental_method.avi':
>   Metadata:
>     encoder         : Lavf57.83.100
>   Duration: 00:33:38.10, start: 0.000000, bitrate: 8133 kb/s
>     Stream #0:0: Video: h264 (Constrained Baseline) (H264 / 0x34363248),
> yuv420p(progressive), 1920x1080, 8057 kb/s, 30 fps, 30 tbr, 30 tbn, 60 tbc
>     Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 32000 Hz, mono, fltp,
> 64 kb/s
> Stream mapping:
>   Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_vaapi))
>   Stream #0:1 -> #0:1 (mp3 (mp3float) -> mp3 (libmp3lame))
> Press [q] to stop, [?] for help
> [h264_vaapi @ 0x55fcc47055c0] B frames are not supported (0x1) by the
> underlying driver.
> [h264_vaapi @ 0x55fcc47055c0] Warning: some packed headers are not
> supported (want 0xd, got 0).
> Output #0, avi, to 'output.avi':
>   Metadata:
>     ISFT            : Lavf58.12.100
>     Stream #0:0: Video: h264 (h264_vaapi) (Main) (H264 / 0x34363248),
> vaapi_vld, 1920x1080, q=0-31, 30 fps, 30 tbn, 30 tbc
>     Metadata:
>       encoder         : Lavc58.18.100 h264_vaapi
>     Stream #0:1: Audio: mp3 (libmp3lame) (U[0][0][0] / 0x0055), 32000 Hz,
> mono, fltp
>     Metadata:
>       encoder         : Lavc58.18.100 libmp3lame
> frame=  202 fps= 52 q=-0.0 Lsize=    4309kB time=00:00:06.80
> bitrate=5187.5kbits/s speed=1.74x
> video:4249kB audio:40kB subtitle:0kB other streams:0kB global headers:0kB
> muxing overhead: 0.444606%
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-user mailing list