title: Ffmpeg: Scale+crop video then overlay image?
body: <p>This is my first SO question. Help me help you help me: does this question need any clarification?</p>
  
  <p>Goal: A script that makes Instagram-ready videos with audio, and a logo overlay. The script takes in an audio and video source and combines them. Important: the logo should have a consistent position and size for each video. This probably means that all output videos should have the same width x height.</p>
  
  <p>Any alternate approaches are welcome!</p>
  
  <p>The ffmpeg command I'm calling from python is below. I try to scale the video to 720:-2 (so auto-height), then crop a 500x500 square from the center. The choices of 720 and 500 are arbitrary; better approaches are welcome.</p>
  
  <pre><code>ffmpeg -i video.mp4 -i logo.png -i audio.mp3 -filter_complex "[0:v]scale=720:-2,crop=500:500[bg];[bg][1:v] overlay=(W-w)/2:(H-h)/2" -pix_fmt yuv420p -map 0:v -map 2:a -shortest + output.mp4
  </code></pre>
  
  <p>This script errors on some videos.</p>
  
  <pre><code>[Parsed_crop_1 @ 0x7fcf96401f00] Invalid too big or non positive size for width '500' or height '500'
  [Parsed_crop_1 @ 0x7fcf96401f00] Failed to configure input pad on Parsed_crop_1
  </code></pre>
  
  <p>I'm new to ffmpeg so please guide me to correct usage of filter_complex. Thank you!</p>