Browse Source

obs-ffmpeg: Fix issue with B-frames introducing motion blur

If a user sets both AdaptiveMiniGOP=true and EnablePreAnalysis=true
in the AMF/FFmpeg options field, AMF will adaptively insert
B-pictures, and no longer uses the fixed B pattern.

For a fixed B-frames pattern, it is expected that increasing B-frames
can cause a quality drop for certain content such as with high motion.
AdaptiveMiniGOP is recommended when using B-frames to improve the
quality in such cases. AdaptiveMiniGOP is dependent on PreAnalysis
which means that trying to enable it without having PreAnalysis turned
ON will have no negative effect (AdaptiveMiniGOP won't be enabled).
rhutsAMD 1 year ago
parent
commit
e657e62c29
1 changed files with 9 additions and 1 deletions
  1. 9 1
      plugins/obs-ffmpeg/texture-amf.cpp

+ 9 - 1
plugins/obs-ffmpeg/texture-amf.cpp

@@ -1396,9 +1396,17 @@ static bool amf_avc_init(void *data, obs_data_t *settings)
 	int64_t bf = obs_data_get_int(settings, "bf");
 
 	if (enc->bframes_supported) {
-		set_avc_property(enc, MAX_CONSECUTIVE_BPICTURES, 3);
+		set_avc_property(enc, MAX_CONSECUTIVE_BPICTURES, bf);
 		set_avc_property(enc, B_PIC_PATTERN, bf);
 
+		/* AdaptiveMiniGOP is suggested for some types of content such
+		 * as those with high motion. This only takes effect if
+		 * Pre-Analysis is enabled.
+		 */
+		if (bf > 0) {
+			set_avc_property(enc, ADAPTIVE_MINIGOP, true);
+		}
+
 	} else if (bf != 0) {
 		warn("B-Frames set to %lld but b-frames are not "
 		     "supported by this device",