09. Encoder Configuration h264 AMF (AMD) - Moehammered/switch-remote-play GitHub Wiki
Encoder Configuration - h264 AMF (AMD)
This page will help explain some of the settings for the h264 AMF (AMD)
codec available on the Encoder Configuration screen.
This page will not be able to solve your performance issues. That is dependent on your hardware limitations. But you can use this page to understand the different settings and then experiment on your own to see what works best for you.
There is very little documentation out there for the h264 AMF codec settings. There are also many more parameters available for this codec. I have limited the parameters to the ones I've been able to test and see noticeable differences with. There are still some I've yet to test.
More parameters might be added in the future. Some parameters might be removed in the future.
To learn more in general about the h264 codec and encoding:
- ffmpeg documentation to learn more
- control rate factor guide
- understanding rate control modes
- encoder profiles
Important
- Make sure you have an AMD GPU installed in your PC before attempting to use this codec. It will not work otherwise.
- This might work on Ryzen CPUs that have integrated graphics. I just don't have one to test with.
- These CPUs are usually identified by having 'G' or 'GE' in their name. (For example Ryzen 3 5300G, Ryzen 3 5300GE)
- See this page to see if your Ryzen CPU has an integrated GPU
- Whether or not it will perform better than the h264 (CPU) codec I am not sure. Give it a try and see for yourself
- This codec will not guarantee fantastic performance, but should perform better than the CPU codec with the right settings
Table of Contents
General Codec Options
Make sure you have set the codec options to h264 AMF (AMD)
Then press left
or right
on the d-pad
to go to the H264 Codec - AMD GPU page
H264 Codec - AMD GPU Options
Usage Hint
This setting is a quality control setting to let the codec know how the video stream will be used or behave.
ultra low latency
- Tells the GPU to prioritise latency at all costs
- Can harm picture quality depending on settings (usually doesn't though)
low latency
- Similar to low latency, but lets the GPU have a bit more time to process a frame
- Can improve picture quality
transcoding
- Tells the GPU that more encoding will occur after it's done with the frame
- Haven't noticed major differences, and haven't used this much
- GPU can take its time processing a frame
webcam
- Tells the GPU that the video will be for a video conference, call, or stream
- Can harm picture quality
In general, prefer ultra low latency
or low latency
. I haven't used the other options as much. Feel free to try them out.
Profile
This setting controls the available encoding techniques the GPU can use when processing frames on your PC. See the wikipedia page on profiles to learn more about them or read the ffmpeg encode guide and look for the profile section.
constrained_baseline
- This is the fastest performing profile option
- Will limit the encoding techniques to keep the video output in a simple format
- Encodes video very quickly
- Produces poor picture quality
main
- This is a good medium between the
Baseline
andHigh
profiles - Produces video best suited for standard definition
- Encodes video quickly
- Produces average picture quality
- This is a good medium between the
high
- Best suited for high definition video
- Produces best picture quality
- Encodes video slower than the other options
constrained_high
- Almost the same as the
high
setting - Main difference is B-Frame slices aren't produced
- This should perform slightly faster than
high
- Almost the same as the
For best performance, choose constrained_baseline
or main
.
For best picture, choose high
or constrained_high
.
Quality Hint
This setting tells the GPU what it should prioritise when creating frames.
speed
- Tells the GPU to prioritise encoding as fast as it can
- Can harm picture quality
balanced
- Tells the GPU to treat encoding speed and picture quality with the same priority
quality
- Tells the GPU to prioritise picture quality instead of encoding speed
- Can cause latency
For best performance, choose speed
or balanced
.
For best picture, choose quality
.
Rate Control Method
This setting tells the GPU how it should handle quality and bitrate when encoding video data. See this guide on rate control modes to learn more.
constant_quantization_parameter
- Tells the GPU to try and maintain a constant level of quality
- Controlled directly by the
i-frame
,p-frame
, andb-frame
control factor parameters - Can produce almost perfect picture quality
- Results in excessively high bitrates, causing lots of latency, frameskips, and even crashing issues
- This is only here for completeness sake. If you can get this working in a very good state, please let me know.
constant_bitrate
- Tells the GPU to try and maintain a constant bitrate
- Controlled by the
Bitrate(KB/s)
option on the generic codec options page - Can produce a great balance of picture quality and framerate
peak_constrained_variable_bitrate
- Tells the GPU to try and use the specified bitrate as a guide
- Controlled by the
Bitrate(KB/s)
option on the generic codec options page - Produces similar results to
constant bitrate
latency_constrained_variable_bitrate
- Tells the GPU to try and use the specified bitrate as a guide
- Controlled by the
Bitrate(KB/s)
option on the generic codec options page - Also controlled by encoding speed latency, and will try to adjust its bitrate accordingly
- Produces similar results to
peak_constrained_variable_bitrate
I recommend using constant_bitrate
or latency_constrained_variable_bitrate
.
I-Frame P-Frame B-Frame Control Factor
These settings work similarly to the CRF setting for the CPU codec. See this guide to learn more about CRF.
Please note: modifying these settings causes large changes in the bitrate when using constant_quantization_parameter
.
- Range is
-1
to50
-1
means default (it is recommended to keep it at this value)0
means 'lossless' mode and will create stunning picture quality at the cost of bad latency and terrible frameskips depending on settings
- Keep these values at around
20
or set to-1
P-Frame
has the most dramatic effect in bitrate
In general, I don't recommend modifying these settings. BUT, please try and let me know if you do manage to find great settings for these options by posting it to the gbatemp release thread!
Frameskip
This setting tells the GPU it is allowed to skip frames if they're taking too long or drop frames.
- Can be set to
yes
orno
- Turning off frameskip doesn't guarantee no frames will be skipped, only that the GPU will not skip frames when encoding
- ffmpeg is still allowed to drop the frames if it wants depending on the settings (Vsync mode for example)
Sample Settings
Before I give examples, I'd like to remind everyone that these settings are still dependent on your machine and network. If the stream is slow, has latency, or doesn't capture at a desired framerate you'd like, that is a hardware limitation.
For the AMD hardware encoder, I've tested so many combinations of settings and could never find a configuration I was truly satisfied with. So please take these recommendations as a reference and explore on your own. If you find an amazing configuration profile, please share it in the gbatemp release thread.
My setup for reference:
- PC
- Ryzen 2600 @
3.4 GHz
- 5600XT Radeon GPU Tuning left on
Automatic
andDefault
profiles - 16 GB Ram @
2933 MHz
- 1TB Samsung Evo 840 SSD + ~500GB Transcend SSD
- Intel WiFi 6 AX 2600 160MHz
- Ryzen 2600 @
Best Performance
- General Codec Options Page
- Desktop Resolution:
1280x720
- Desired Framerate:
60
- Bitrate(KB/s):
5120 or less
- Vsync Mode:
variable frame rate
- HW Accel Mode:
Auto
- Codec:
h264 AMF (AMD)
- Desktop Resolution:
- h264 Codec - AMD GPU Options Page
- Usage Hint:
ultra low latency
- Profile:
contrained_baseline
- Quality Hint:
speed
- Rate Control Mode:
constant_bitrate
orlatency_constrained_variable_bitrate
- I-Frame Control Factor:
20 or higher
- P-Frame Control Factor:
-1
- B-Frame Control Factor:
20 or higher
- Frameskip:
yes
orno
- Usage Hint:
Best Picture
- General Codec Options Page
- Desktop Resolution:
1280x720
- Desired Framerate:
60
- Bitrate(KB/s):
5120 or higher
- Vsync Mode:
variable frame rate
- HW Accel Mode:
Auto
- Codec:
h264 AMF (AMD)
- Desktop Resolution:
- h264 Codec - AMD GPU Options Page
- Usage Hint:
low latency
- Profile:
contrained_high
- Quality Hint:
quality
- Rate Control Mode:
constant_bitrate
orconstant_quantization_parameter
- I-Frame Control Factor:
20 or lower
- P-Frame Control Factor:
-1
or0 if you can
- B-Frame Control Factor:
20 or lower
- Frameskip:
no
- Usage Hint:
Balanced Picture
- General Codec Options Page
- Desktop Resolution:
1280x720
- Desired Framerate:
60
- Bitrate(KB/s):
Around 5120
- Vsync Mode:
variable frame rate
- HW Accel Mode:
Auto
- Codec:
h264 AMF (AMD)
- Desktop Resolution:
- h264 Codec - AMD GPU Options Page
- Usage Hint:
ultra low latency
- Profile:
contrained_baseline
ormain
- Quality Hint:
balanced
orspeed
- Rate Control Mode:
constant_bitrate
orpeak_constrained_variable_bitrate
- I-Frame Control Factor:
20
- P-Frame Control Factor:
-1
- B-Frame Control Factor:
20
- Frameskip:
no
- Usage Hint: