fftools/ffmpeg_enc: merge -force_key_frames source/source_no_drop

Always use the functionality of the latter, which makes more sense as it
avoids losing keyframes due to vsync code dropping frames.

Deprecate the 'source_no_drop' value, as it is now redundant.
pull/390/head
Anton Khirnov 1 year ago
parent 735b082231
commit d2c416fdf1
  1. 5
      doc/ffmpeg.texi
  2. 3
      fftools/ffmpeg.h
  3. 5
      fftools/ffmpeg_enc.c
  4. 6
      fftools/ffmpeg_mux_init.c
  5. 22
      tests/ref/fate/force_key_frames-source-drop

@ -1060,7 +1060,6 @@ Deprecated see -bsf
@item -force_key_frames[:@var{stream_specifier}] @var{time}[,@var{time}...] (@emph{output,per-stream}) @item -force_key_frames[:@var{stream_specifier}] @var{time}[,@var{time}...] (@emph{output,per-stream})
@item -force_key_frames[:@var{stream_specifier}] expr:@var{expr} (@emph{output,per-stream}) @item -force_key_frames[:@var{stream_specifier}] expr:@var{expr} (@emph{output,per-stream})
@item -force_key_frames[:@var{stream_specifier}] source (@emph{output,per-stream}) @item -force_key_frames[:@var{stream_specifier}] source (@emph{output,per-stream})
@item -force_key_frames[:@var{stream_specifier}] source_no_drop (@emph{output,per-stream})
@var{force_key_frames} can take arguments of the following form: @var{force_key_frames} can take arguments of the following form:
@ -1121,10 +1120,6 @@ starting from second 13:
@item source @item source
If the argument is @code{source}, ffmpeg will force a key frame if If the argument is @code{source}, ffmpeg will force a key frame if
the current frame being encoded is marked as a key frame in its source. the current frame being encoded is marked as a key frame in its source.
@item source_no_drop
If the argument is @code{source_no_drop}, ffmpeg will force a key frame if
the current frame being encoded is marked as a key frame in its source.
In cases where this particular source frame has to be dropped, In cases where this particular source frame has to be dropped,
enforce the next available frame to become a key frame instead. enforce the next available frame to become a key frame instead.

@ -58,6 +58,7 @@
#define FFMPEG_OPT_ADRIFT_THRESHOLD 1 #define FFMPEG_OPT_ADRIFT_THRESHOLD 1
#define FFMPEG_OPT_ENC_TIME_BASE_NUM 1 #define FFMPEG_OPT_ENC_TIME_BASE_NUM 1
#define FFMPEG_OPT_TOP 1 #define FFMPEG_OPT_TOP 1
#define FFMPEG_OPT_FORCE_KF_SOURCE_NO_DROP 1
enum VideoSyncMethod { enum VideoSyncMethod {
VSYNC_AUTO = -1, VSYNC_AUTO = -1,
@ -484,7 +485,9 @@ typedef enum {
enum { enum {
KF_FORCE_SOURCE = 1, KF_FORCE_SOURCE = 1,
#if FFMPEG_OPT_FORCE_KF_SOURCE_NO_DROP
KF_FORCE_SOURCE_NO_DROP = 2, KF_FORCE_SOURCE_NO_DROP = 2,
#endif
}; };
typedef struct KeyframeForceCtx { typedef struct KeyframeForceCtx {

@ -1093,10 +1093,7 @@ static enum AVPictureType forced_kf_apply(void *logctx, KeyframeForceCtx *kf,
kf->expr_const_values[FKF_N_FORCED] += 1; kf->expr_const_values[FKF_N_FORCED] += 1;
goto force_keyframe; goto force_keyframe;
} }
} else if (kf->type == KF_FORCE_SOURCE && } else if (kf->type == KF_FORCE_SOURCE && !dup_idx) {
(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; int dropped_keyframe = kf->dropped_keyframe;
kf->dropped_keyframe = 0; kf->dropped_keyframe = 0;
if ((in_picture->flags & AV_FRAME_FLAG_KEY) || dropped_keyframe) if ((in_picture->flags & AV_FRAME_FLAG_KEY) || dropped_keyframe)

@ -2513,8 +2513,12 @@ static int process_forced_keyframes(Muxer *mux, const OptionsContext *o)
// parse it only for static kf timings // parse it only for static kf timings
} else if (!strcmp(forced_keyframes, "source")) { } else if (!strcmp(forced_keyframes, "source")) {
ost->kf.type = KF_FORCE_SOURCE; ost->kf.type = KF_FORCE_SOURCE;
#if FFMPEG_OPT_FORCE_KF_SOURCE_NO_DROP
} else if (!strcmp(forced_keyframes, "source_no_drop")) { } else if (!strcmp(forced_keyframes, "source_no_drop")) {
ost->kf.type = KF_FORCE_SOURCE_NO_DROP; av_log(ost, AV_LOG_WARNING, "The 'source_no_drop' value for "
"-force_key_frames is deprecated, use just 'source'\n");
ost->kf.type = KF_FORCE_SOURCE;
#endif
} else { } else {
int ret = parse_forced_key_frames(ost, &ost->kf, mux, forced_keyframes); int ret = parse_forced_key_frames(ost, &ost->kf, mux, forced_keyframes);
if (ret < 0) if (ret < 0)

@ -9,14 +9,14 @@
0, 2, 3, 1, 24, 0x589c06e0, F=0x0, S=1, 8 0, 2, 3, 1, 24, 0x589c06e0, F=0x0, S=1, 8
0, 3, 4, 1, 24, 0x4a700621, F=0x0, S=1, 8 0, 3, 4, 1, 24, 0x4a700621, F=0x0, S=1, 8
0, 4, 5, 1, 24, 0x4f300661, F=0x0, S=1, 8 0, 4, 5, 1, 24, 0x4f300661, F=0x0, S=1, 8
0, 5, 6, 1, 24, 0x53f006a1, F=0x0, S=1, 8 0, 5, 6, 1, 57, 0x7a110e90, S=1, 8
0, 6, 7, 1, 24, 0x58b006e1, F=0x0, S=1, 8 0, 6, 7, 1, 24, 0x4f1c0660, F=0x0, S=1, 8
0, 7, 8, 1, 24, 0x4a840622, F=0x0, S=1, 8 0, 7, 8, 1, 24, 0x53dc06a0, F=0x0, S=1, 8
0, 8, 9, 1, 24, 0x4f440662, F=0x0, S=1, 8 0, 8, 9, 1, 24, 0x589c06e0, F=0x0, S=1, 8
0, 9, 10, 1, 24, 0x540406a2, F=0x0, S=1, 8 0, 9, 10, 1, 24, 0x4a700621, F=0x0, S=1, 8
0, 10, 11, 1, 24, 0x58c406e2, F=0x0, S=1, 8 0, 10, 11, 1, 24, 0x4f300661, F=0x0, S=1, 8
0, 11, 12, 1, 24, 0x4a980623, F=0x0, S=1, 8 0, 11, 12, 1, 24, 0x53f006a1, F=0x0, S=1, 8
0, 12, 13, 1, 24, 0x4f580663, F=0x0, S=1, 8 0, 12, 13, 1, 24, 0x58b006e1, F=0x0, S=1, 8
0, 13, 14, 1, 24, 0x541806a3, F=0x0, S=1, 8 0, 13, 14, 1, 24, 0x4a840622, F=0x0, S=1, 8
0, 14, 15, 1, 24, 0x58d806e3, F=0x0, S=1, 8 0, 14, 15, 1, 57, 0x88850f14, S=1, 8
0, 15, 16, 1, 24, 0x4aac0624, F=0x0, S=1, 8 0, 15, 16, 1, 57, 0x7aa20e95, S=1, 8

Loading…
Cancel
Save