FFmpeg垫滤波器计算错误的宽度 [英] FFmpeg pad filter calculating wrong width

查看:78
本文介绍了FFmpeg垫滤波器计算错误的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用

ffmpeg.exe -i in.jpg -filter_complex "[0:v]pad=iw:ih+10:0:0" out.jpg

在图像和视频的底部添加 10px 的填充.在大多数情况下,它可以按预期工作,但有些宽度会偏离 1px ,导致失败并出现错误:

to add a padding of 10px at the bottom of images and videos. In most cases it works as expected but with some the width is off by 1px resulting in failure with error:

[Parsed_pad_0 @ 000002ba70617c40] Input area 0:0:623:640 not within the padded area 0:0:622:650 or zero-sized
[Parsed_pad_0 @ 000002ba70617c40] Failed to configure input pad on Parsed_pad_0
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0

您可以看到输入区域的宽度为 623 ,填充区域的宽度为 622 ,但这不是事实,因为我们使用的是iw 设置填充的宽度.

you can see that the width of the input area is 623 and the padded area width is 622 but this should not be the case since we are using iw to set the width of the padding.

这是一个失败的示例图像.

Here is a sample image that fails.

推荐答案

事实证明,您不能以奇数边界填充子采样像素格式.工作方法是即使使用

it turns out you can not pad subsampled pixel formats at odd boundries. the workaroud is to make the boundary even by using

ffmpeg.exe -i in.jpg -filter_complex "[0:v]pad=ceil(iw/2)*2:ceil((ih+10)/2)*2:0:0" out.jpg

这篇关于FFmpeg垫滤波器计算错误的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆