From 3dc319587f5bb96905f5984262e036c58a756c8c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 14 Dec 2023 13:42:17 +0100 Subject: [PATCH] fftools/ffmpeg: deprecate -fps_mode/vsync drop It depends on the ability of muxers to generate timestamps, which is itself deprecated. --- doc/ffmpeg.texi | 3 --- fftools/ffmpeg.h | 3 +++ fftools/ffmpeg_filter.c | 9 +++++++-- fftools/ffmpeg_mux.c | 2 ++ fftools/ffmpeg_opt.c | 7 ++++++- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index c503963941..f157c06e12 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1742,9 +1742,6 @@ constant frame rate. @item vfr (2) Frames are passed through with their timestamp or dropped so as to prevent 2 frames from having the same timestamp. -@item drop -As passthrough but destroys all timestamps, making the muxer generate -fresh timestamps based on frame-rate. @item auto (-1) Chooses between cfr and vfr depending on muxer capabilities. This is the default method. diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index affa80856a..96f4e757e1 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -60,6 +60,7 @@ #define FFMPEG_OPT_ENC_TIME_BASE_NUM 1 #define FFMPEG_OPT_TOP 1 #define FFMPEG_OPT_FORCE_KF_SOURCE_NO_DROP 1 +#define FFMPEG_OPT_VSYNC_DROP 1 #define FFMPEG_ERROR_RATE_EXCEEDED FFERRTAG('E', 'R', 'E', 'D') @@ -69,7 +70,9 @@ enum VideoSyncMethod { VSYNC_CFR, VSYNC_VFR, VSYNC_VSCFR, +#if FFMPEG_OPT_VSYNC_DROP VSYNC_DROP, +#endif }; enum EncTimeBase { diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index bb755d7bb4..9fc877b437 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -2104,8 +2104,11 @@ static void video_sync_process(OutputFilterPriv *ofp, AVFrame *frame, if (delta0 < 0 && delta > 0 && - ost->vsync_method != VSYNC_PASSTHROUGH && - ost->vsync_method != VSYNC_DROP) { + ost->vsync_method != VSYNC_PASSTHROUGH +#if FFMPEG_OPT_VSYNC_DROP + && ost->vsync_method != VSYNC_DROP +#endif + ) { if (delta0 < -0.6) { av_log(ost, AV_LOG_VERBOSE, "Past duration %f too large\n", -delta0); } else @@ -2143,7 +2146,9 @@ static void video_sync_process(OutputFilterPriv *ofp, AVFrame *frame, ofp->next_pts = llrint(sync_ipts); frame->duration = llrint(duration); break; +#if FFMPEG_OPT_VSYNC_DROP case VSYNC_DROP: +#endif case VSYNC_PASSTHROUGH: ofp->next_pts = llrint(sync_ipts); frame->duration = llrint(duration); diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 74df6dcb64..3ce4ef131e 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -150,8 +150,10 @@ static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt) goto fail; } +#if FFMPEG_OPT_VSYNC_DROP if (ost->type == AVMEDIA_TYPE_VIDEO && ost->vsync_method == VSYNC_DROP) pkt->pts = pkt->dts = AV_NOPTS_VALUE; +#endif // rescale timestamps to the stream timebase if (ost->type == AVMEDIA_TYPE_AUDIO && !ost->enc) { diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 6177a96a4e..96d3c56fd7 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -188,7 +188,12 @@ int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_id if (!av_strcasecmp(arg, "cfr")) *vsync_var = VSYNC_CFR; else if (!av_strcasecmp(arg, "vfr")) *vsync_var = VSYNC_VFR; else if (!av_strcasecmp(arg, "passthrough")) *vsync_var = VSYNC_PASSTHROUGH; - else if (!av_strcasecmp(arg, "drop")) *vsync_var = VSYNC_DROP; +#if FFMPEG_OPT_VSYNC_DROP + else if (!av_strcasecmp(arg, "drop")) { + av_log(NULL, AV_LOG_WARNING, "-vsync/fps_mode drop is deprecated\n"); + *vsync_var = VSYNC_DROP; + } +#endif else if (!is_global && !av_strcasecmp(arg, "auto")) *vsync_var = VSYNC_AUTO; else if (!is_global) { av_log(NULL, AV_LOG_FATAL, "Invalid value %s specified for fps_mode of #%d:%d.\n", arg, file_idx, st_idx);