[FFmpeg-devel] [PATCH] ffmpeg: Make CFR frame drop threshold user adjustable

Michael Niedermayer michaelni at gmx.at
Sat Jan 17 05:39:18 CET 2015


Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 ffmpeg.c     |    4 +++-
 ffmpeg.h     |    1 +
 ffmpeg_opt.c |    3 +++
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 2501e2c..42ab379 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -963,7 +963,9 @@ static void do_video_out(AVFormatContext *s,
         }
     case VSYNC_CFR:
         // FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c
-        if (delta < -1.1)
+        if (frame_drop_threshold && delta < frame_drop_threshold && ost->frame_number) {
+            nb_frames = 0;
+        } else if (delta < -1.1)
             nb_frames = 0;
         else if (delta > 1.1) {
             nb_frames = lrintf(delta);
diff --git a/ffmpeg.h b/ffmpeg.h
index 0ad1e37..2969ff5 100644
--- a/ffmpeg.h
+++ b/ffmpeg.h
@@ -479,6 +479,7 @@ extern float dts_error_threshold;
 extern int audio_volume;
 extern int audio_sync_method;
 extern int video_sync_method;
+extern float frame_drop_threshold;
 extern int do_benchmark;
 extern int do_benchmark_all;
 extern int do_deinterlace;
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index a0c977b..e3f84dd 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -86,6 +86,7 @@ float dts_error_threshold   = 3600*30;
 int audio_volume      = 256;
 int audio_sync_method = 0;
 int video_sync_method = VSYNC_AUTO;
+float frame_drop_threshold = 0;
 int do_deinterlace    = 0;
 int do_benchmark      = 0;
 int do_benchmark_all  = 0;
@@ -2870,6 +2871,8 @@ const OptionDef options[] = {
         " \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)", "type" },
     { "vsync",          HAS_ARG | OPT_EXPERT,                        { opt_vsync },
         "video sync method", "" },
+    { "frame_drop_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT,      { &frame_drop_threshold },
+        "frame drop threshold", "" },
     { "async",          HAS_ARG | OPT_INT | OPT_EXPERT,              { &audio_sync_method },
         "audio sync method", "" },
     { "adrift_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT,          { &audio_drift_threshold },
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list