From 81b86c3688049ca15352ba4ee66a5989928b8861 Mon Sep 17 00:00:00 2001
From: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
Date: Tue, 19 Jul 2022 13:18:20 -0300
Subject: [PATCH] ios disable b frames

---
 libavcodec/videotoolboxenc.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 418ff00b8d..9fab30fd69 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -1434,6 +1434,20 @@ static int vtenc_configure_encoder(AVCodecContext *avctx)
 
     vtctx->codec_id = avctx->codec_id;
 
+    CFBooleanRef   has_b_frames_cfbool;
+
+    int error = VTSessionCopyProperty(vtctx->session,
+                                   kVTCompressionPropertyKey_AllowFrameReordering,
+                                   kCFAllocatorDefault,
+                                   &has_b_frames_cfbool);
+
+    if (!error && has_b_frames_cfbool) {
+        if (CFBooleanGetValue(has_b_frames_cfbool)) {
+            avctx->max_b_frames = 16;
+        }
+        CFRelease(has_b_frames_cfbool);
+    }
+
     if (vtctx->codec_id == AV_CODEC_ID_H264) {
         vtctx->get_param_set_func = CMVideoFormatDescriptionGetH264ParameterSetAtIndex;
 
-- 
2.34.1

