Try round_up output w/h for the clips with odd resolution to avoid failure if no padding is required(e.g. iw/ih+0+0).
$ffmpeg -i input.mp4 -vf "scale=1241x1234,pad=iw+0+0:ih+3+3:0:3" -f null - Before: Round down to 1240x1234 and failed since s->w < inlink->w (e.g. 1240 < 1241) [Parsed_pad_1 @ 0x7f849090f840] Padded dimensions cannot be smaller than input dimensions. [Parsed_pad_1 @ 0x7f849090f840] Failed to configure input pad on Parsed_pad_1 Error reinitializing filters! Failed to inject frame into filter network: Invalid argument Error while processing the decoded data for stream #0:0 Conversion failed! After: Try to Round up for odd resolution (1241x1234 -> 1242x1240) Stream #0:0(und): Video: wrapped_avframe, yuv420p(tv, progressive), 1242x1240 Signed-off-by: Linjie Fu <linjie.justin...@gmail.com> --- libavfilter/vf_pad.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c index e52f7284d4..c9a0a75630 100644 --- a/libavfilter/vf_pad.c +++ b/libavfilter/vf_pad.c @@ -107,6 +107,7 @@ static int config_input(AVFilterLink *inlink) AVFilterContext *ctx = inlink->dst; PadContext *s = ctx->priv; AVRational adjusted_aspect = s->aspect; + int round_w, round_h; int ret; double var_values[VARS_NB], res; char *expr; @@ -178,9 +179,13 @@ static int config_input(AVFilterLink *inlink) if (s->y < 0 || s->y + inlink->h > s->h) s->y = var_values[VAR_Y] = (s->h - inlink->h) / 2; - s->w = ff_draw_round_to_sub(&s->draw, 0, -1, s->w); - s->h = ff_draw_round_to_sub(&s->draw, 1, -1, s->h); - /* sanity check params */ + round_w = ff_draw_round_to_sub(&s->draw, 0, -1, s->w); + round_h = ff_draw_round_to_sub(&s->draw, 1, -1, s->h); + + s->w = round_w < inlink->w ? ff_draw_round_to_sub(&s->draw, 0, 1, s->w) : round_w; + s->h = round_h < inlink->h ? ff_draw_round_to_sub(&s->draw, 0, 1, s->h) : round_h; + + /* sanity check params */ if (s->w < inlink->w || s->h < inlink->h) { av_log(ctx, AV_LOG_ERROR, "Padded dimensions cannot be smaller than input dimensions.\n"); return AVERROR(EINVAL); -- 2.31.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".