ottpeter
ottpeter

Reputation: 85

Input area 0:0:1280:675 not within the padded area 0:0:1280:674 or zero-sized

I'm setting a padding to a list of videos. When resolution was 854x480, it worked, when I switched to 1280x720 it does not work. Most likely this is because of odd numbers, as stated in this question: FFmpeg pad filter calculating wrong width

This was my original code (bash script creating the filter complex parts):

# Resolution
RES_X=1280
RES_Y=720
...
FILTER_COMPLEX_LIST="${FILTER_COMPLEX_LIST}[$i:v]scale=$RES_X:$RES_Y:force_original_aspect_ratio=1,pad=width=$RES_X:height=$RES_Y:x='if(lt(in_w,$RES_X),($RES_X-in_w)/2,0)':0,setsar=1[v$i];"

I changed the calculation of pad width and pad height, but the error is the same.

FILTER_COMPLEX_LIST="${FILTER_COMPLEX_LIST}[$i:v]scale=$RES_X:$RES_Y:force_original_aspect_ratio=1,pad=width=ceil($RES_X/2)*2:height=ceil($RES_Y/2)*2:x='if(lt(in_w,$RES_X),($RES_X-in_w)/2,0)':0,setsar=1$

This is the error:

[Parsed_pad_19 @ 0x558b4fe3bb40] Input area 0:0:1280:675 not within the padded area 0:0:1280:674 or zero-sized [Parsed_pad_19 @ 0x558b4fe3bb40] Failed to configure input pad on Parsed_pad_19 Error configuring complex filters. Invalid argument

I don't understand why padded area is not padded area 0:0:1280:720 in the first place. Where should I add the ceil() or floor() function to make this work?

Upvotes: 0

Views: 602

Answers (2)

Daniel Ajisafe
Daniel Ajisafe

Reputation: 31

In my case, I had an image that had a different size compared to others. The issue was solved when I removed it.

Upvotes: 1

ottpeter
ottpeter

Reputation: 85

Analyzing the logs I realized these lines:

... [Parsed_pad_1 @ 0x564355d71aa0] Setting 'width' to value '1280' [Parsed_pad_1 @ 0x564355d71aa0] Setting 'height' to value '720' [Parsed_pad_1 @ 0x564355d71aa0] Setting 'x' to value 'if(lt(in_w,1280),(1280-in_w)/2,0)' [Parsed_pad_1 @ 0x564355d71aa0] Setting 'height' to value '0' [Parsed_setsar_2 @ 0x564355b92140] Setting 'sar' to value '1' [Parsed_scale_3 @ 0x564355d7dde0] Setting 'w' to value '1280' [Parsed_scale_3 @ 0x564355d7dde0] Setting 'h' to value '720' [Parsed_scale_3 @ 0x564355d7dde0] Setting 'force_original_aspect_ratio' to value '1' [Parsed_scale_3 @ 0x564355d7dde0] w:1280 h:720 flags:'bilinear' interl:0 [Parsed_pad_4 @ 0x564355b845a0] Setting 'width' to value '1280' [Parsed_pad_4 @ 0x564355b845a0] Setting 'height' to value '720' [Parsed_pad_4 @ 0x564355b845a0] Setting 'x' to value 'if(lt(in_w,1280),(1280-in_w)/2,0)' [Parsed_pad_4 @ 0x564355b845a0] Setting 'height' to value '0' ...

... which suggests, that in the code

FILTER_COMPLEX_LIST="${FILTER_COMPLEX_LIST}[$i:v]scale=$RES_X:$RES_Y:force_original_aspect_ratio=1,pad=width=$RES_X:height=$RES_Y:x='if(lt(in_w,$RES_X),($RES_X-in_w)/2,0)':0,setsar=1[v$i];"

:0 does not set value for y, but for height. (After setting value for x, near the end of the line).

This is strange, because most of the time this code didn't fail. After I changed this line to

FILTER_COMPLEX_LIST="${FILTER_COMPLEX_LIST}[$i:v]scale=$RES_X:$RES_Y:force_original_aspect_ratio=1,pad=width=$RES_X:height=$RES_Y:x='if(lt(in_w,$RES_X),($RES_X-in_w)/2,0)':y=0,setsar=1[v$i];"

it works.

y= should also contain an lt() function to adjust content to middle, but now it does not fail. The problem was that only some of the parameters were explicitly set, the last parameter was not, so ffmpeg followed the order of the parameters, so it set the wrong parameter to 0.

Thank you Gyan for telling about the -report option.

Upvotes: 1

Related Questions