diff mbox series

[FFmpeg-devel,v2,1/2] lavc/videotoolboxenc: Dump the encoder

Message ID 20230905160221.2347008-1-mypopydev@gmail.com
State New
Headers show
Series [FFmpeg-devel,v2,1/2] lavc/videotoolboxenc: Dump the encoder | expand

Commit Message

Jun Zhao Sept. 5, 2023, 4:02 p.m. UTC
Dump the encoder, it's will help debug some case

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavcodec/videotoolboxenc.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 8e493c4f7a..3512d35b73 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -1110,6 +1110,32 @@  static int vtenc_create_encoder(AVCodecContext   *avctx,
         return AVERROR_EXTERNAL;
     }
 
+    // Dump the init encoder
+    {
+        CFStringRef encoderID = NULL;
+        status = VTSessionCopyProperty(vtctx->session,
+                                       kVTCompressionPropertyKey_EncoderID,
+                                       kCFAllocatorDefault,
+                                       &encoderID);
+        if (status == noErr) {
+            CFIndex length   = CFStringGetLength(encoderID);
+            CFIndex max_size = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8);
+            char *name       = av_malloc(max_size);
+            if (!name)
+                return AVERROR(ENOMEM);
+
+            CFStringGetCString(encoderID,
+                               name,
+                               max_size,
+                               kCFStringEncodingUTF8);
+            av_log(avctx, AV_LOG_DEBUG, "Init the encoder: %s\n", name);
+
+            av_freep(&name);
+        }
+        if (encoderID != NULL)
+            CFRelease(encoderID);
+    }
+
     if (avctx->flags & AV_CODEC_FLAG_QSCALE && !vtenc_qscale_enabled()) {
         av_log(avctx, AV_LOG_ERROR, "Error: -q:v qscale not available for encoder. Use -b:v bitrate instead.\n");
         return AVERROR_EXTERNAL;