AMF
AMF copied to clipboard
[GNU/Linux] Anyone been able to successfully record gameplay?
Howdy all! I have been testing AMF via FFMPEG all day using various parameters, flags, and values/integers. I have had very little luck thus far on recording games with no frameloss in the video.
My system specs
- GPU - AMD Radeon VII [AMDGPU]
- CPU - Ryzen 5 1600
- RAM - 8GB Ram
- Distro/Kernel - arch 5.10.7-zen1-1-zen
So far, here is my best try
ffmpeg -vaapi_device /dev/dri/renderD128 -f x11grab -video_size 1920x1080 -framerate 60 -i :0 -c:v h264_amf -rc cqp -qp_p 10 -qp_i 10 -vsync 2 -threads 11 output.mp4
This can record a lower end game, like TF2 just find, some loss in fps but it is good enough. However in a higher-end game like Mordhau, it's incredibly lossy. Anyone have any suggestions to balance this out?
For anyone who want, here is every option for AMF.
h264_amf AVOptions:
-usage <int> E..V...... Encoder Usage (from 0 to 3) (default transcoding)
transcoding 0 E..V...... Generic Transcoding
ultralowlatency 1 E..V......
lowlatency 2 E..V......
webcam 3 E..V...... Webcam
-profile <int> E..V...... Profile (from 66 to 257) (default main)
main 77 E..V......
high 100 E..V......
constrained_baseline 256 E..V......
constrained_high 257 E..V......
-level <int> E..V...... Profile Level (from 0 to 62) (default auto)
auto 0 E..V......
1.0 10 E..V......
1.1 11 E..V......
1.2 12 E..V......
1.3 13 E..V......
2.0 20 E..V......
2.1 21 E..V......
2.2 22 E..V......
3.0 30 E..V......
3.1 31 E..V......
3.2 32 E..V......
4.0 40 E..V......
4.1 41 E..V......
4.2 42 E..V......
5.0 50 E..V......
5.1 51 E..V......
5.2 52 E..V......
6.0 60 E..V......
6.1 61 E..V......
6.2 62 E..V......
-quality <int> E..V...... Quality Preference (from 0 to 2) (default speed)
speed 1 E..V...... Prefer Speed
balanced 0 E..V...... Balanced
quality 2 E..V...... Prefer Quality
-rc <int> E..V...... Rate Control Method (from -1 to 3) (default -1)
cqp 0 E..V...... Constant Quantization Parameter
cbr 1 E..V...... Constant Bitrate
vbr_peak 2 E..V...... Peak Contrained Variable Bitrate
vbr_latency 3 E..V...... Latency Constrained Variable Bitrate
-enforce_hrd <boolean> E..V...... Enforce HRD (default false)
-filler_data <boolean> E..V...... Filler Data Enable (default false)
-vbaq <boolean> E..V...... Enable VBAQ (default false)
-frame_skipping <boolean> E..V...... Rate Control Based Frame Skip (default false)
-qp_i <int> E..V...... Quantization Parameter for I-Frame (from -1 to 51) (default -1)
-qp_p <int> E..V...... Quantization Parameter for P-Frame (from -1 to 51) (default -1)
-qp_b <int> E..V...... Quantization Parameter for B-Frame (from -1 to 51) (default -1)
-preanalysis <boolean> E..V...... Pre-Analysis Mode (default false)
-max_au_size <int> E..V...... Maximum Access Unit Size for rate control (in bits) (from 0 to INT_MAX) (default 0)
-header_spacing <int> E..V...... Header Insertion Spacing (from -1 to 1000) (default -1)
-bf_delta_qp <int> E..V...... B-Picture Delta QP (from -10 to 10) (default 4)
-bf_ref <boolean> E..V...... Enable Reference to B-Frames (default true)
-bf_ref_delta_qp <int> E..V...... Reference B-Picture Delta QP (from -10 to 10) (default 4)
-intra_refresh_mb <int> E..V...... Intra Refresh MBs Number Per Slot in Macroblocks (from 0 to INT_MAX) (default 0)
-coder <int> E..V...... Coding Type (from 0 to 2) (default auto)
auto 0 E..V...... Automatic
cavlc 2 E..V...... Context Adaptive Variable-Length Coding
cabac 1 E..V...... Context Adaptive Binary Arithmetic Coding
-me_half_pel <boolean> E..V...... Enable ME Half Pixel (default true)
-me_quarter_pel <boolean> E..V...... Enable ME Quarter Pixel (default true)
-aud <boolean> E..V...... Inserts AU Delimiter NAL unit (default false)
-log_to_dbg <boolean> E..V...... Enable AMF logging to debug output (default false)
On Linux you are forced to capture frames into system memory and then AMF has to transfer them to video memory. On Linux AMF run via Vulkan. There is a performance improvement in this area coming with the next Linux driver. It is already released in Windows driver.
I cannot comment on upcoming release dates but you can check frequency for Linux. Your GPU should be good for game streaming. You may want to test it on Windows.
Nope. On Windows capture APIs are usually more effective and doesn't require video memory->cpu memory->video memory transfers as Linux capture does.
Issue has been open for nearly a year, do we have a way to capture and encode in the GPU level on Linux?
Hi I only recently figured out how to get AMF useable on my system with OBS thanks to a different project (https://github.com/xaymar/obs-streamfx)

AMF is better, like heck lot better.
I only recorded my idle desktop but that short clip already speaks much I figure. VAAPI H.264 - https://www.youtube.com/watch?v=LP80KfycmM0 AMF H.264 - https://www.youtube.com/watch?v=TGmuZb3Sjt8
Really unfortunate that only H.264 is supported on Linux. With my particular AMD GPU recording anything higher than 1080p30 really needs HEVC. The H.264 always quickly overloads, even on Windows.
EDIT: Here is some footage I casually did - https://youtu.be/UBL9f_RkT4M
@Snaggly we hear you, please stay tuned.
@MikhailAMD thank you for your updates and effort on the matter! Speaking of which, are there any news from the driver front regarding this?
21.50 Linux Pro driver was released recently. It has full HEVC encoder support via AMF for Navi (RX 5xxx and RX 6xxx).
21.50 Linux Pro driver was released recently. It has full HEVC encoder support via AMF for Navi (RX 5xxx and RX 6xxx).
@MikhailAMD Can you confirm if 21.50 Linux Pro driver supports HEVC encoder for RX 4xx cards? Is there a official page where this support list is maintained? I've been trying to encode hevc via amf in linux without any success. h264 via amf works. My card is rx 480.
Issue has been open for nearly a year, do we have a way to capture and encode in the GPU level on Linux?
If anyone finds this issue, the way you're supposed to do this is by using the DRM layer of the linux kernel if you're on linux or whatever the appropriate WinAPI is, the reason for the misconception is that NV doesn't have open drivers and foregoes the DRM layer to just provide their own proprietary API, if you want to capture and encode the screen on a modern AMD GPU you can get a dmabuf of the GPUs framebuffer and feed that into the AMF encoder. This is a good starting point.
@sarim HEVC encoder is now supported on 5xxx and 6xxx only
@gitautas capture desktop via libdrm and submit to encoder: wait till 21.50 for Windows is released and AMF here updated.