[英]FFmpeg pad filter calculating wrong width
I'm using我在用着
ffmpeg.exe -i in.jpg -filter_complex "[0:v]pad=iw:ih+10:0:0" out.jpg
to add a padding of 10px
at the bottom of images and videos.在图像和视频的底部添加
10px
的填充。 In most cases it works as expected but with some the width is off by 1px
resulting in failure with error:在大多数情况下,它按预期工作,但有些宽度偏离
1px
,导致失败并出现错误:
[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
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.您可以看到输入区域的宽度为
623
,填充区域的宽度为622
,但事实并非如此,因为我们使用iw
来设置填充的宽度。
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.