FFmpeg pad filter calculating wrong width

一世执手 提交于 2021-02-11 14:29:49

问题


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. 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

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.


回答1:


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


来源:https://stackoverflow.com/questions/62758615/ffmpeg-pad-filter-calculating-wrong-width

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!