-
-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
obs-ffmpeg: New default settings for AMD encoders #9352
base: master
Are you sure you want to change the base?
obs-ffmpeg: New default settings for AMD encoders #9352
Conversation
Testing this PR, and unfortunately I ran into a crash that seems to occur in the AMD drivers. Log: Occured when stopping the last recording (w hevc). I've tried reproducing it, but it seems to be somewhat intermittent, so I have not managed to find specific reproduction steps so far. Will update if I find a reliable repro. |
I am a little bit worried about these defaults. This is primarily because it enables Pre-Analysis (PA). In my opinion, people with older/weaker hardware, like rx4/500 series, or APUs, this is likely to cause some problems, which are not currently easily remedied. I would personally prefer one or a combination of the following:
This would allow rate controls where PA is less impactful (VBR, CQP etc) to be easily (and/or automatically) be used without the additional GPU load. I understand the reasoning and desire to have AMF look better by default for streaming, and at the very least be easier/simpler to achieve, and agree with that sentiment. Just my two cents. Thank you for the PR, it seems to work well for me outside of that one crash, which seems to have been a one off (cannot reproduce it). |
Also |
a4d1018
to
d83d845
Compare
Thank you for providing feedback on the PR and testing it. Older/weaker hardware such as RX 4/500 series do not support PA and will not be allowed to enable it. To clarify, PA is only supported on Radeon RX 5000 Series or newer GPUs as well as Ryzen 2000 U/H series or newer APUs. GPUOpen-LibrariesAndSDKs/AMF/blob/master/amf/doc/AMF_Video_PreAnalysis_API.md#13-supported-hardware The recommended quality settings are to improve the quality at 1080p60 or lower resolutions/throughput. PA is kept off/not set for higher than 1080p60. The same idea applies for the preset where balanced mode is applied for all codecs for higher than 1080p60. Since you mention having the RC method set to HQCBR for streaming, is there a way to identify the recording or streaming use case at the encoder plugin level? My understanding is that the AMF encoder plugin in OBS just receives textures and encodes them like the other encoders in OBS. It implements the encoder interface ( We are also interested in having a PA enable/disable checkbox but from past discussions it seems that UI/interface changes need to be done in a vendor agnostic way by OBS developers. |
PA support: I'm particularly worried about the APUs. They don't have a lot of GPU to play with, and I believe basically any game would lead to GPU contention, and ultimately encoder lag. HQCBR: I'm not certain, but I think you are correct. What I was envisioning was the defaults in the UI being different in streaming vs recording, but now that my memory has been jogged, that is not something that can be done in a simple manner. PA bool/checkbox: Which leaves us back at the issue of the UI/UX, which is tricky. I know they don't want more checkboxes, but I am failing to see any other way to neatly handle it. If it is just kept as is (PA enabled by default, no easy way to disable), then I truly believe that every APU user that tries streaming/recording gameplay will have a very poor experience, and be unlikely to figure it out on their own. There are a lot of APU users, and having the defaults be unusable(for gameplay), where the only solution is very arcane just really vexes me, personally. I think it would lead to substantially more support request as well. At this point, I am just retreading the same ground, so I don't really have anything more to add. Thank you for your time and effort :) |
OBS log: log.txt I figured it would be pertinent to add some data on my claims instead of people just having to take my word for it. Here is an example of the APUs I'm talking about. Its a simple older game (assault android cactus), running at 1366x768, targeting 60fps. All else equal between the two OBS sessions. Running stock, it hovers around 50fps, and is pretty pleasant to play. With the PR its hovering 40fps, but the lows are very noticable, quite jarring/stuttery (big fluctuations), a poor experience. Regarding OBS, as you can see in the log, current master/stock managed to stream/record without any render or encoder lag. With the PR it is unfortunately unusable Side thought regarding PA handling. If bool/checkbox is out of the question, then perhaps we could at least somehow exclude APUs somehow? |
I don't think having In ffmpeg, if OBS Log file with the suggested defaults above: |
I'm aware the log file I provided has a lot of clutter from other existing plugins, here is another log file from a clean Scene Collection where I reproduced the results I explained earlier. https://obsproject.com/logs/bX4QINZDD6lxtcen I have also attached a crash log that happened after stopping the recording. |
HQCBR and HQVBR are almost unusable, even on the 7900XTX. For 1080p60 recording, they are all overloaded. |
That is because rhuts forgot to tell you to use "Preset: Balanced" & "PASceneChangeDetectionEnable=false" |
@rhutsAMD Reason: x264 & NVENC both have their scenecut for cbr/vbr disabled because a fixed keyint is preferred for streaming and having it disabled gives the encoder more headroom. Also, use Reason: The image quality difference of Balanced & Quality is minimal, but Quality is really pushing the encoder and so to maximize compatibility, Balanced would be the better option. |
Yep, scenecut(scenehange) for real time livestreaming only hurt quality, also agree on bal preset, for higher end models qual is prob a no big deal but on my card for example(6650 xt), if i use PA stuff and bframes >2 qual preset can become quite a burden for the encoder, depending on the PA params in use. |
Hello,
|
Please refrain from comments asking why something hasn't been merged yet. We know this is here, we'll get to it as soon as we have time, in appropriate priority. |
To add some things ive noticed regarding some of the settings in this post. For the PA engine i would suggest either to use Vulkan or DX12, |
Where are you getting those values from? Nevermind found it |
Thank you for noticing this. The header and the PreAnalysis API doc on GPUOpen have now been updated to reflect the additional PAEngineType options. Regarding the new recommended defaults for AMF in OBS, there is still some internal testing going on and we expect to have an updated set of recommended defaults. I will update this PR with the new set once those are ready. |
The PR has been updated and the settings have been retested on the recent public driver version 24.2.1. |
I have a question regarding the recommended lookahead buffer-depth setting of 20 in these recommendations. The Preanalysis API (https://github.com/GPUOpen-LibrariesAndSDKs/AMF/blob/master/amf/doc/AMF_Video_PreAnalysis_API.pdf) specifies that AMF_PA_TAQ_MODE only works when AMF_PA_LOOKAHEAD_BUFFER_DEPTH is set to 11, 21 or 41. Do values other than these 3 work considering you're selecting 20 instead here? Would love some clarification on this, thank you. |
The three LAB depths ( short lookahead(11), medium lookahead(21) and long lookahead(41) ) are tested recommendations, rather than requirements as the original wording suggests. I have updated the doc to clarify the wording of the example values as being suggestions. |
6355128
to
2be502e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fourth commit ("@rhutsAMD
CI: Pull in latest submodules from master branch) is superfluous. Just rebasing the branch should be sufficient.
f176eff
to
9b8f0b5
Compare
9b8f0b5
to
cac06ed
Compare
495ed36
to
8392a7c
Compare
8392a7c
to
0b53378
Compare
ef95d8f
to
39c4751
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than two nits, do not use merge commits to fast-forward history. Use git rebase
.
1a234c6
to
fec9534
Compare
Rebased to bring in latest changes. |
fec9534
to
c67fb6f
Compare
hi @RytoEX , I addressed your requested changes. Could you please revisit this PR? |
hello my first time here just i am curious the "AMF_VIDEO_ENCODER_RATE_CONTROL_PREANALYSIS_ENABLE" default value is 0 in https://github.com/GPUOpen-LibrariesAndSDKs/AMF/blob/master/amf/doc/AMF_Video_Encode_API.md .but in the obs wiki:https://obsproject.com/wiki/AMF-Options , by default is'RateControlPreanalysisEnable=1' when the new default settings for amd encoders well be,will still enable by default 'RateControlPreanalysisEnable' ? and when it enbale it get alot stutter in obs and games thx and sorry for my bad english. |
PreAnalysis is enabled for
It has been this way forever. |
thx for response @lextra2 i am not talking about Preanalysis "AMF_VIDEO_ENCODER_PRE_ANALYSIS_ENABLE" ,ik it deafault disabled but i am talking about the "AMF_VIDEO_ENCODER_RATE_CONTROL_PREANALYSIS_ENABLE" the 'RateControlPreanalysisEnable' it enable without the Preanalysis and it hurts the performance. in the obs wiki it on by default just asking should leave it on by default or change it to off in the new default amd encoder |
98aad9a
to
8034c36
Compare
I have pushed some changes to the new default settings PR which help improve performance. These changes include removing the new cases where PA would be enabled by default, as well as removing the addition of enabling the PA-dependent features by default. Additionally, the B-picture pattern for AVC was updated from 3 to 2. |
Hello @rhutsAMD i did test the build and i have some feedback about it :
and my AMF option that i use to streaming twitch: i hope my feedback it well help improve the amd encoder quality and performance and sorry for my bad english.have good day. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made another pass and caught some things that I'd previously missed.
plugins/obs-ffmpeg/texture-amf.cpp
Outdated
"\trate_control: %s\n" | ||
"\tbitrate: %d\n" | ||
"\tcqp: %d\n" | ||
"\tkeyint: %d\n" | ||
"\tpreset: %s\n" | ||
"\tprofile: %s\n" | ||
"\tb-frames: %d\n" | ||
"\twidth: %d\n" | ||
"\theight: %d\n" | ||
"\toverriding params: %s", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pre-analysis state should be logged.
Normalize spacing so that the longest line uses one space after the colon:
label: %format_specifier
plugins/obs-ffmpeg/texture-amf.cpp
Outdated
"\trate_control: %s\n" | ||
"\tbitrate: %d\n" | ||
"\tcqp: %d\n" | ||
"\tkeyint: %d\n" | ||
"\tpreset: %s\n" | ||
"\tprofile: %s\n" | ||
"\tb-frames: %d\n" | ||
"\twidth: %d\n" | ||
"\theight: %d\n" | ||
"\toverriding params: %s", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why we need to rename params
to overriding params
.
plugins/obs-ffmpeg/texture-amf.cpp
Outdated
"\trate_control: %s\n" | ||
"\tbitrate: %d\n" | ||
"\tcqp: %d\n" | ||
"\tkeyint: %d\n" | ||
"\tpreset: %s\n" | ||
"\tprofile: %s\n" | ||
"\twidth: %d\n" | ||
"\theight: %d\n" | ||
"\toverriding params: %s", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See other comment about pre-analysis, spacing, and params.
plugins/obs-ffmpeg/texture-amf.cpp
Outdated
"\trate_control: %s\n" | ||
"\tbitrate: %d\n" | ||
"\tcqp: %d\n" | ||
"\tkeyint: %d\n" | ||
"\tpreset: %s\n" | ||
"\tprofile: %s\n" | ||
"\twidth: %d\n" | ||
"\theight: %d\n" | ||
"\tscreen content tools: %s\n" | ||
"\tpalette mode: %s\n" | ||
"\toverriding params: %s", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See other comment about pre-analysis, spacing, and params.
plugins/obs-ffmpeg/texture-amf.cpp
Outdated
rc_str, bitrate, qp, gop_size, preset, profile, enc->cx, enc->cy, | ||
ffmpeg_opts); | ||
"true", "true", ffmpeg_opts); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I'd previously resolved the thread, it seems that the original feedback on this line was never addressed. Don't hard-code logged settings values, even if you're hard-coding them when setting them. Just actually get the setting so that if the setting itself isn't hard-coded in the future, we don't have to wonder why the logs don't make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix property "ENABLE_VBAQ" always true even when using "rc=CBR" for AVC and HEVC
plugins/obs-ffmpeg/texture-amf.cpp
Outdated
if (rc != AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_CONSTANT_QP && | ||
rc != AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_HIGH_QUALITY_VBR && | ||
rc != AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_HIGH_QUALITY_CBR) | ||
set_avc_property(enc, ENABLE_VBAQ, true); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for working correctly
if (rc != AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_CONSTANT_QP && | |
rc != AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_HIGH_QUALITY_VBR && | |
rc != AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_HIGH_QUALITY_CBR) | |
set_avc_property(enc, ENABLE_VBAQ, true); | |
if (rc != AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_CONSTANT_QP && | |
rc != AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_HIGH_QUALITY_VBR && | |
rc != AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_HIGH_QUALITY_CBR) { | |
set_avc_property(enc, ENABLE_VBAQ, true); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
plugins/obs-ffmpeg/texture-amf.cpp
Outdated
if (rc != AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CONSTANT_QP && | ||
rc != AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_HIGH_QUALITY_VBR && | ||
rc != AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_HIGH_QUALITY_CBR) | ||
set_hevc_property(enc, ENABLE_VBAQ, true); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for HEVC
if (rc != AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CONSTANT_QP && | |
rc != AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_HIGH_QUALITY_VBR && | |
rc != AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_HIGH_QUALITY_CBR) | |
set_hevc_property(enc, ENABLE_VBAQ, true); | |
if (rc != AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CONSTANT_QP && | |
rc != AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_HIGH_QUALITY_VBR && | |
rc != AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_HIGH_QUALITY_CBR) { | |
set_hevc_property(enc, ENABLE_VBAQ, true); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
1f354ea
to
24bff6c
Compare
24bff6c
to
afa9401
Compare
Description
Introducing new default AMD encoder settings for improved perceptual quality for AVC/HEVC/AV1. These new default settings have been tuned to target stable recording on RX 5700 XT and up on the recent driver.
Motivation and Context
This PR provides new recommended defaults for the AMD encoders that have been optimized for perceptual quality. The settings are automatically applied depending on the resolution and framerate. The default settings can be overridden as expected and only provide an improved base foundation for encoder settings targeted at improving perceptual quality.
How Has This Been Tested?
Tested on RX 5000, 6000, and 7000 series cards using public driver version 24.2.1.
Types of changes
Checklist: