[FFmpeg-devel] [PATCH 08/13] lavc/videotoolboxenc: Add realtime encoding property

Rick Kern kernrj at gmail.com
Sun Apr 10 05:50:13 CEST 2016


Hint to the encoder that encoding should be done in real-time, even at the
expense of quality.

Signed-off-by: Rick Kern <kernrj at gmail.com>
---
 libavcodec/videotoolboxenc.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index a3f7e5e..5430479 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -77,6 +77,7 @@ typedef struct VTEncContext {
     int64_t level;
 
     int64_t entropy;
+    int64_t realtime;
 
     bool flushing;
     bool has_b_frames;
@@ -753,6 +754,16 @@ static av_cold int vtenc_init(AVCodecContext *avctx)
         }
     }
 
+    if (vtctx->realtime) {
+        status = VTSessionSetProperty(vtctx->session,
+                                      kVTCompressionPropertyKey_RealTime,
+                                      kCFBooleanTrue);
+
+        if (status) {
+            av_log(avctx, AV_LOG_ERROR, "Error setting realtime property: %d\n", status);
+        }
+    }
+
     status = VTCompressionSessionPrepareToEncodeFrames(vtctx->session);
     if (status) {
         av_log(avctx, AV_LOG_ERROR, "Error: cannot prepare encoder: %d\n", status);
@@ -1521,6 +1532,9 @@ static const AVOption options[] = {
     { "cavlc", "CAVLC entropy coding", 0, AV_OPT_TYPE_CONST, { .i64 = VT_CAVLC }, INT_MIN, INT_MAX, VE, "entropy" },
     { "cabac", "CABAC entropy coding", 0, AV_OPT_TYPE_CONST, { .i64 = VT_CABAC }, INT_MIN, INT_MAX, VE, "entropy" },
 
+    { "realtime", "Hint that encoding should happen in real-time if not faster (e.g. capturing from camera).",
+        OFFSET(realtime), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, VE },
+
     { NULL },
 };
 
-- 
2.7.4



More information about the ffmpeg-devel mailing list