title: ffmpeg resize down larger video to fit desired size and add padding
body: <p>I'm trying to resize a larger video to fit an area that I have. In order to achieve this I calculate first the dimensions of the resized video so That it fits my area, and then I try to add padding to this video so that the final result will have the desired dimension, keeping the aspect ratio as well.</p>
  
  <p>So let's say that I have the original video dimensions of 1280x720 and to fit my area of 405x320 I need first to resize the video to 405x227. I do that. Everything is fine at this point. I do some math and I find out that I have to add 46 pixels of padding at the top and the bottom.</p>
  
  <p>So the padding parameter of the command for that would be <code>-vf "pad=405:320:0:46:black"</code>. But each time I run the command I get an error like <code>Input area 0:46:405:273 not within the padded area 0:0:404:226</code>. </p>
  
  <p>The only docs for padding that I found is this <a href="http://ffmpeg.org/libavfilter.html#pad" rel="noreferrer">http://ffmpeg.org/libavfilter.html#pad</a>.</p>
  
  <p>I don't know what I'm doing wrong. Anyone had this problem before? Do you have any suggestions?</p>