[FFmpeg-devel] [PATCH 09/18] fftools/ffmpeg_filter: sanitize framerate retrieved from the filtergraph
Anton Khirnov
anton at khirnov.net
Sat Aug 26 18:11:35 EEST 2023
Lavfi uses 1/0 to signal unknown/VFR, which should not be passed to
encoders.
---
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);
--
2.40.1
More information about the ffmpeg-devel
mailing list