1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

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.
This commit is contained in:
Anton Khirnov 2023-09-09 14:13:18 +02:00
parent 735b082231
commit d2c416fdf1
5 changed files with 20 additions and 21 deletions

View File

@ -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}] 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_no_drop (@emph{output,per-stream})
@var{force_key_frames} can take arguments of the following form:
@ -1121,10 +1120,6 @@ starting from second 13:
@item source
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.
@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,
enforce the next available frame to become a key frame instead.

View File

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

View File

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

View File

@ -2513,8 +2513,12 @@ static int process_forced_keyframes(Muxer *mux, const OptionsContext *o)
// parse it only for static kf timings
} else if (!strcmp(forced_keyframes, "source")) {
ost->kf.type = KF_FORCE_SOURCE;
#if FFMPEG_OPT_FORCE_KF_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 {
int ret = parse_forced_key_frames(ost, &ost->kf, mux, forced_keyframes);
if (ret < 0)

View File

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