1
0
Эх сурвалжийг харах

mac-videotoolbox: Enforce non-zero keyframe interval in CRF mode

derrod 2 жил өмнө
parent
commit
3fed2e081e

+ 11 - 0
plugins/mac-videotoolbox/encoder.c

@@ -596,6 +596,17 @@ static bool create_encoder(struct vt_encoder *enc)
 
 	if (enc->codec_type == kCMVideoCodecType_H264 ||
 	    enc->codec_type == kCMVideoCodecType_HEVC) {
+		/* Apple's documentation states that a keyframe interval of 0 will result in
+		 * the encoder automatically picking times to insert them; However, Apple's
+		 * encoder, when in CRF mode, will never actually insert any keyframes past
+		 * the very first one, rendering the files near-unusable in editors or
+		 * video players. So to avoid that happening, enforce a reasonable default
+		 * of 10 seconds in CRF mode. */
+		if (enc->keyint == 0 && strcmp(enc->rate_control, "CRF") == 0) {
+			VT_BLOG(LOG_INFO,
+				"Enforcing non-zero keyframe interval in CRF mode");
+			enc->keyint = 10;
+		}
 
 		// This can fail when using GPU hardware encoding
 		code = session_set_prop_int(