Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Anton Khirnov <anton@khirnov.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 08/27] fftools/ffmpeg_enc: merge -force_key_frames source/source_no_drop
Date: Tue, 19 Sep 2023 21:10:35 +0200
Message-ID: <20230919191044.18873-9-anton@khirnov.net> (raw)
In-Reply-To: <20230919191044.18873-1-anton@khirnov.net>

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.
---
 doc/ffmpeg.texi                             |  5 -----
 fftools/ffmpeg.h                            |  3 +++
 fftools/ffmpeg_enc.c                        |  5 +----
 fftools/ffmpeg_mux_init.c                   |  6 +++++-
 tests/ref/fate/force_key_frames-source-drop | 22 ++++++++++-----------
 5 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index d2864ff37e..ea473e14e8 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -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.
 
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 2e8f1db9b6..eaa663e718 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -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 {
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index 1db67d1497..0ad3a7b6b1 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -1105,10 +1105,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)
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 9d6f442068..f35680e355 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -2509,8 +2509,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)
diff --git a/tests/ref/fate/force_key_frames-source-drop b/tests/ref/fate/force_key_frames-source-drop
index 99aa2ae826..220c0f0f88 100644
--- a/tests/ref/fate/force_key_frames-source-drop
+++ b/tests/ref/fate/force_key_frames-source-drop
@@ -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
-- 
2.40.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2023-09-19 19:22 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-19 19:10 [FFmpeg-devel] [RFC/PATCH] ffmpeg CLI multithreading Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 01/27] fftools/ffmpeg: move derivation of frame duration from filter framerate Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 02/27] fftools/ffmpeg_enc: move handling video frame duration to video_sync_process() Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 03/27] fftools/ffmpeg_enc: move remaining vsync-related code " Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 04/27] fftools/ffmpeg_enc: simplify adjust_frame_pts_to_encoder_tb() signature Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 05/27] ffools/ffmpeg_filter: stop trying to handle an unreachable state Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 06/27] tests/fate/ffmpeg: add tests for -force_key_frames source Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 07/27] fftools/ffmpeg_enc: unbreak -force_key_frames source_no_drop Anton Khirnov
2023-09-19 19:10 ` Anton Khirnov [this message]
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 09/27] fftools/ffmpeg: stop accessing OutputStream.last_dropped in print_report() Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 10/27] fftools/ffmpeg_enc: move framerate conversion state into a separate struct Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 11/27] fftools/ffmpeg_enc: move fps conversion code to ffmpeg_filter Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 12/27] fftools/ffmpeg_filter: fail on filtering errors Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 13/27] fftools/ffmpeg_enc: constify the frame passed to enc_open() Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 14/27] fftools/ffmpeg_filter: move filtering to a separate thread Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 15/27] fftools/ffmpeg_mux: add muxing thread private data Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 16/27] fftools/ffmpeg_demux: switch from AVThreadMessageQueue to ThreadQueue Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 17/27] XXX: disable fix_sub_duration_heartbeat Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 18/27] XXX fftools/ffmpeg_enc: temporarily disable side data copying Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 19/27] XXX ffmpeg temporarily disable -stream_loop Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 20/27] WIP: fftools/ffmpeg_enc: move encoding to a separate thread Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 21/27] WIP fftools/ffmpeg: add thread-aware transcode scheduling infrastructure Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 22/27] WIP fftools/ffmpeg_demux: convert to the scheduler Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 23/27] WIP fftools/ffmpeg_dec: " Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 24/27] WIP fftools/ffmpeg_filter: " Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 25/27] WIP fftools/ffmpeg_enc: " Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 26/27] WIP fftools/ffmpeg_mux: " Anton Khirnov
2023-09-19 19:10 ` [FFmpeg-devel] [PATCH 27/27] WIP: ffmpeg: switch to scheduler Anton Khirnov
2023-09-20 14:49 ` [FFmpeg-devel] [RFC/PATCH] ffmpeg CLI multithreading Michael Niedermayer
2023-09-25 10:17   ` Anton Khirnov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230919191044.18873-9-anton@khirnov.net \
    --to=anton@khirnov.net \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git