Answers.Body: <p>it turns out you can not pad subsampled pixel formats at odd boundries.
  the workaroud is to make the boundary even by using</p>
  <pre><code>ffmpeg.exe -i in.jpg -filter_complex &quot;[0:v]pad=ceil(iw/2)*2:ceil((ih+10)/2)*2:0:0&quot; out.jpg
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-06T16:16:37.543Z
Answers.LastActivityDate: 2020-07-06T16:16:37.543Z
Answers.UserDisplayName: Abdullah Saleem
Body: <p>I'm using</p>
  <pre><code>ffmpeg.exe -i in.jpg -filter_complex &quot;[0:v]pad=iw:ih+10:0:0&quot; out.jpg
  </code></pre>
  <p>to add a padding of <code>10px</code> at the bottom of images and videos.
  In most cases it works as expected but with some the width is off by <code>1px</code> resulting in failure with error:</p>
  <pre><code>[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
  </code></pre>
  <p>you can see that the width of the input area is <code>623</code> and the padded area width is <code>622</code> but this should not be the case since we are using <code>iw</code> to set the width of the padding.</p>
  <p>Here is a sample image that fails.</p>
  <p><a href="https://i.sstatic.net/RXMAe.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/RXMAe.jpg" alt="sample image" /></a></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-06T16:03:22.877Z
Comments.Text: @PaulB.Mahol any workaround that you could suggest?
Comments.UserDisplayName: Abdullah Saleem
Tags: <ffmpeg>
Title: FFmpeg pad filter calculating wrong width
UserDisplayName: Abdullah Saleem
ThreadText: # FFmpeg pad filter calculating wrong width
  
  (Asked by: username_0 on 2020-07-06)
  
  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](https://i.sstatic.net/RXMAe.jpg)](https://i.sstatic.net/RXMAe.jpg)
  
  **Tags:** ffmpeg
  
  > **Comments:**
  > **username_0**: @PaulB.Mahol any workaround that you could suggest?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2020-07-06. Score: 0 | Accepted answer
  
  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
  
  ```
  
  
  ---
  
  