[FFmpeg-devel] [PATCH] modified frame timing, so that we can make sure that a frame is never forward in time with respect to the original one, when converting from VFR to CFR

Jerome Berclaz jerome at percipient.ai
Thu Mar 18 05:02:38 EET 2021


---
 fftools/ffmpeg.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 46bb014de8..8085442156 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1238,8 +1238,9 @@ static void do_video_out(OutputFile *of,
                 nb_frames = 0;
             } else if (delta < -1.1)
                 nb_frames = 0;
-            else if (delta > 1.1) {
-                nb_frames = lrintf(delta);
+            // let the CFR frame go backward by at most one frame duration with respect to the original VFR
+            else if (delta >= 2) {
+                nb_frames = floor(delta);
                 if (delta0 > 1.1)
                     nb0_frames = llrintf(delta0 - 0.6);
             }
-- 
2.27.0



More information about the ffmpeg-devel mailing list