0

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.

sample image

2
  • 1
    This is known "problem" related to using subsampled pixel formats.
    – user12174
    Commented Jul 6, 2020 at 15:46
  • @PaulB.Mahol any workaround that you could suggest? Commented Jul 6, 2020 at 16:03

1 Answer 1

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.