There was error in forcing key frames. If IDR was set to -1 (default) forced key frame will be never propagated to encoder.

I also suggest to backport this patch to current stable version, because -forced_keyframe behavior in NVENC is actualy broken.


--
Miroslav Slugeň







>From 60a1efef9d4146f9ad38a779ebf05407c64e385d Mon Sep 17 00:00:00 2001
From: Miroslav Slugen <thunde...@email.cz>
Date: Sun, 12 Feb 2017 18:10:15 +0100
Subject: [PATCH 1/1] nvenc: fix wrong forced keyframe behavior

---
 libavcodec/nvenc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 7005465..20af109 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1687,9 +1687,10 @@ int ff_nvenc_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             pic_params.pictureStruct = NV_ENC_PIC_STRUCT_FRAME;
         }
 
-        if (ctx->forced_idr >= 0 && frame->pict_type == AV_PICTURE_TYPE_I) {
-            pic_params.encodePicFlags =
-                ctx->forced_idr ? NV_ENC_PIC_FLAG_FORCEIDR : NV_ENC_PIC_FLAG_FORCEINTRA;
+        if (frame->pict_type == AV_PICTURE_TYPE_I) {
+            pic_params.encodePicFlags = ctx->forced_idr > 0
+                                        ? NV_ENC_PIC_FLAG_FORCEIDR
+                                        : NV_ENC_PIC_FLAG_FORCEINTRA;
         } else {
             pic_params.encodePicFlags = 0;
         }
-- 
2.1.4

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to