[FFmpeg-devel] [PATCH 06/12] fftools/ffmpeg_enc: unbreak -force_key_frames source_no_drop
Anton Khirnov
anton at khirnov.net
Tue Oct 3 18:35:20 EEST 2023
Unlike the 'source' mode, which preserves source keyframe-marking as-is,
the 'source_no_drop' mode attempts to keep track of keyframes dropped by
framerate conversion and mark the next output frame as key in such
cases. However,
* c75be061487 broke this functionality entirely, and made it equivalent
to 'source'
* even before it would only work when the frame immediately following
the dropped keyframe is preserved and not dropped as well
Also, drop a redundant check for 'frame' in setting dropped_keyframe, as
it is redundant with the check on the above line.
---
fftools/ffmpeg_enc.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index b928bf208c..42f64a4a49 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -1066,7 +1066,7 @@ finish:
}
ost->last_dropped = *nb_frames == *nb_frames_prev && frame;
- ost->kf.dropped_keyframe = ost->last_dropped && frame && (frame->flags & AV_FRAME_FLAG_KEY);
+ ost->kf.dropped_keyframe |= ost->last_dropped && (frame->flags & AV_FRAME_FLAG_KEY);
}
static enum AVPictureType forced_kf_apply(void *logctx, KeyframeForceCtx *kf,
@@ -1109,8 +1109,9 @@ static enum AVPictureType forced_kf_apply(void *logctx, KeyframeForceCtx *kf,
(in_picture->flags & AV_FRAME_FLAG_KEY) && !dup_idx) {
goto force_keyframe;
} else if (kf->type == KF_FORCE_SOURCE_NO_DROP && !dup_idx) {
+ int dropped_keyframe = kf->dropped_keyframe;
kf->dropped_keyframe = 0;
- if ((in_picture->flags & AV_FRAME_FLAG_KEY) || kf->dropped_keyframe)
+ if ((in_picture->flags & AV_FRAME_FLAG_KEY) || dropped_keyframe)
goto force_keyframe;
}
--
2.40.1
More information about the ffmpeg-devel
mailing list