GPUOpen-LibrariesAndSDKs / AMF

The Advanced Media Framework (AMF) SDK provides developers with optimal access to AMD devices for multimedia processing
Other
606 stars 152 forks source link

[Bug]: <B-Frames introducing motion blur> #433

Open hxzael opened 9 months ago

hxzael commented 9 months ago

Describe the bug The more b-frames utilized on the current H264 encoder with OBS, the more motion blur is introduced to the image in motion. To the point where visual quality subjectively drops because of the use of b-frames. This blur or ghosting effect is especially noticed in foliage and buildings in-game. This issue is present regardless of whether components such as high motion quality boost, pre-analysis, PA high motion quality boost, adaptive mini-gop, perceptual AQ, temporal AQ, or VBAQ are used or not.

To Reproduce Steps to reproduce the behavior:

  1. Set the Max B-Frames to any number >0, effect is increased the more b-frames used. This can also be achieved by manipulating the MaxConsecutiveBPictures and BPicturesPattern parameters in the AMF/FFmpeg options section of the encoder settings.
  2. Record or Stream scenes with medium to high amounts of motion.

Setup (please complete the following information):

Expected behavior B-Frames increasing the efficiency of the encoder without any motion blur added.

Screenshots 0 B-Frames 0BF 1 B-Frame 1BF 2 B-Frames 2BF 3 B-Frames 3BF

Screenshot 2023-12-29 021219 Configuration used in these screenshots, with only Max B-Frames changing

Additional context Add any other context about the problem here.

MikhailAMD commented 9 months ago

From these JPEGs I can only see that images with B-frames have less details. Could you please share the actual videos with B-frames and without?

hxzael commented 9 months ago

From these JPEGs I can only see that images with B-frames have less details. Could you please share the actual videos with B-frames and without?

Absolutely. I have also provided versions with a setup using pre-analysis (EnableVBAQ=true EnablePreAnalysis=true PASceneChangeDetectionEnable=false AdaptiveMiniGOP=true PAPerceptualAQMode=1 PATemporalAQMode=0 PACAQStrength=0 PAHighMotionQualityBoostMode=1) as samples.

Note that these clips were all recorded with OBS to simulate actual streaming or recording so they won't be exactly in sync but it's still pretty easy to compare the differences. It's especially noticeable by looking at the foliage during the horse-riding sections of the clip.

https://drive.google.com/drive/folders/1yLxXsId3O00DrXflmzLXcCTEUZvBhSBw?usp=sharing

MikhailAMD commented 9 months ago

Thanks, I created an internal ticket for bitrate rate control folks. I assume they will look into it after holidays.

hxzael commented 9 months ago

Thank you!

rhutsAMD commented 9 months ago

I have opened a pull request with the fix inside the OBS repo.

Linking it here: obsproject/obs-studio #1076

hxzael commented 9 months ago

I appreciate you addressing this issue. One question though.

I have experienced that even while using adaptiveminigop and preanalysis this blurring issue persists, although significantly reduced compared to using a fixed b-frame pattern. Is this issue related to max consecutive b frames being hard coded to 3? Is there a way for me to simulate the fix by forcing MaxConsecutiveBPictures to a lower number? I haven't been able to reproduce the fix this way personally.

Thank you

rhutsAMD commented 9 months ago

Thank you for following up on this. It may be the case that the heuristics in AdaptiveMiniGOP don't serve your content well, and we will work on improving this. However from the clips you sent, it is hard for us to say that the blur is worsened between the 0 B-frames and PA clips. Ideally, when AdaptiveMiniGOP is enabled, then B-frames are inserted only to improve quality and MaxConsecutiveBPictures serves as a maximum where the actual number of B-frames can be much lower regardless.

Additionally, if you would like to experiment and track down the best settings for your particular setup and content, you may try to tweak the settings with playback of a short recording in uncompressed format. This uncompressed input can be added as a source in the OBS scene and you can recreate a consistent input source for testing various settings this way.

hxzael commented 9 months ago

Maybe I'll get more samples of the blur in the future with a different game including ones using Adaptiveminigop as well. The method you mention is how I got to compare clips and share the samples I provided in the first place. It's just confusing at times because I'm not sure how certain components are expected to behave despite reading the documentation.

Thank you for still actively supporting and working on improving the H264 encoder!

rhutsAMD commented 9 months ago

Just a quick update, the B-frame blur fix has been merged into OBS. It will be present in one of their latest builds and will eventually be included in a release if you wish to wait a little.

hxzael commented 9 months ago

That's exciting to hear. I personally still have been experiencing some blur with 1-3 b frames even with adaptiveminigop enabled on every single game I test it with. I'll proceed with testing once the future release comes out. Thank you Rhuts.

CortexReaver commented 8 months ago

Is this still not being fixed in OBS 30.1.0-beta3? Because I still have ghosting artifacts... This is way more noticeable in grainy static games, like Open Red Alert: https://youtu.be/miAUGIbqFbE Look how units leaving traces behind them while moving. Also take a look at the shroud disappearing. None of these options has any effect for me: AdaptiveMiniGOP, BPicturesPattern, MaxConsecutiveBPictures, BReferenceEnable. I've tried literally everything just to fix this... VBR seems like doesn't have this bug, but the whole screen is blinking there like its refreshing - from top to bottom (this is might be a different bug though). This or rather just the bottom half of the screen does blinking and its compressed more then the other half of the screen.

scotuss commented 7 months ago

Just a quick update, the B-frame blur fix has been merged into OBS. It will be present in one of their latest builds and will eventually be included in a release if you wish to wait a little.

Do us a big favor and do change your job with something easier like selling icecream ! Why B-frames intel had it for decades and amd promoted last year and even now is not fixed ? Why AMD likes to humiliate it's customers so much and when AMD will give a DAMN about hire some decent programmers that do know video encoding? Is it too much to ask? Is it?