简体   繁体   中英

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

示例图像

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM