[FFmpeg-cvslog] fftools/ffmpeg_filter: sanitize framerate retrieved from the filtergraph

Anton Khirnov git at videolan.org
Wed Aug 30 13:00:20 EEST 2023


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Fri Jul 21 16:17:35 2023 +0200| [82dd4dbe3f465bc11ea8a3b05733b43ca8d44c5c] | committer: Anton Khirnov

fftools/ffmpeg_filter: sanitize framerate retrieved from the filtergraph

Lavfi uses 1/0 to signal unknown/VFR, which should not be passed to
encoders.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=82dd4dbe3f465bc11ea8a3b05733b43ca8d44c5c
---

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

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 925b5116cc..177a6f7e5c 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1805,8 +1805,11 @@ int reap_filters(FilterGraph *fg, int flush)
             if (!fgp->is_meta)
                 fd->bits_per_raw_sample = 0;
 
-            if (ost->type == AVMEDIA_TYPE_VIDEO)
-                fd->frame_rate_filter = av_buffersink_get_frame_rate(filter);
+            if (ost->type == AVMEDIA_TYPE_VIDEO) {
+                AVRational fr = av_buffersink_get_frame_rate(filter);
+                if (fr.num > 0 && fr.den > 0)
+                    fd->frame_rate_filter = fr;
+            }
 
             ret = enc_frame(ost, filtered_frame);
             av_frame_unref(filtered_frame);



More information about the ffmpeg-cvslog mailing list