diff options
author | Gyan Doshi <ffmpeg@gyani.pro> | 2021-02-01 18:19:18 +0530 |
---|---|---|
committer | Gyan Doshi <ffmpeg@gyani.pro> | 2021-02-05 22:54:18 +0530 |
commit | d99cc1782563672bcdb46fb5ec51135847db8c99 (patch) | |
tree | ef4abee116e19db63157615b85f1b7b508a0a3ea /fftools/ffmpeg.c | |
parent | 6b8ef5119cab9e772c6afd23e474bbd543c47039 (diff) | |
download | ffmpeg-d99cc1782563672bcdb46fb5ec51135847db8c99.tar.gz |
ffmpeg: add -fpsmax to clamp output framerate
Useful when encoding in batch or with aberrant inputs.
Diffstat (limited to 'fftools/ffmpeg.c')
-rw-r--r-- | fftools/ffmpeg.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index d7c833be63..add5a3e505 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3376,7 +3376,7 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame) ost->frame_rate = ist->framerate; if (ist && !ost->frame_rate.num) ost->frame_rate = ist->st->r_frame_rate; - if (ist && !ost->frame_rate.num) { + if (ist && !ost->frame_rate.num && !ost->max_frame_rate.num) { ost->frame_rate = (AVRational){25, 1}; av_log(NULL, AV_LOG_WARNING, "No information " @@ -3386,6 +3386,11 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame) ost->file_index, ost->index); } + if (ost->max_frame_rate.num && + (av_q2d(ost->frame_rate) > av_q2d(ost->max_frame_rate) || + !ost->frame_rate.den)) + ost->frame_rate = ost->max_frame_rate; + if (ost->enc->supported_framerates && !ost->force_fps) { int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates); ost->frame_rate = ost->enc->supported_framerates[idx]; |