title: ffmpeg scale, how to crop correctly
body: <p>I'm using this command to encode videos </p>
  
  <pre><code>$transcode = FFMPEG_BINARY.' -loglevel panic -y -i "'.$files['original'].'" -vf scale='.VIDEO_SIZE_X.':'.VIDEO_SIZE_Y.' -vcodec libx264 -profile main -preset slow -r 25 -b '.VIDEO_BITRATE.' -maxrate '.VIDEO_BITRATE.' -bufsize 1000k -threads '.VIDEO_THREADS.' -acodec aac -ar 44100 -f mp4 -strict -2 '.$files['mp4'];
  
  where: VIDEO_SIZE_X = 640 and VIDEO_SIZE_Y = 480, VIDEO_BITRATE = 900k
  </code></pre>
  
  <p>it all seems to work fine, but the problem I'm having is that the video is not resized to the desired size which is 640x480</p>
  
  <p><img src="https://i.stack.imgur.com/RFNfe.png" alt="output from vlc"></p>
  
  <p>^ This is the output from vlc</p>
  
  <p>It looks like there's some reference to the desired size, but the video is not scaled/cropped,
  what's the correct way of scaling videos in order to have the desired size? I don't mind having black stripes above and below or bands at the sides. </p>
  
  <p>so, here's a bit of debugging as requested:</p>
  
  <pre><code>/usr/bin/ffmpeg -loglevel panic -y -i "in.wmv" -vf scale=640:480 -vcodec libx264 -profile main -preset slow -r 25 -b 900k -maxrate 900k -bufsize 1000k -threads 8 -acodec aac -ar 44100 -f mp4 -strict -2 out.mp4
  </code></pre>
  
  <p>original video:</p>
  
  <pre><code>[wmv3 @ 0x13245c0] Extra data: 8 bits left, value: 20
  Input #0, asf, from 'in.wmv':
    Metadata:
      WMFSDKVersion   : 12.0.9600.16384
      WMFSDKNeeded    : 0.0.0.0000
      IsVBR           : 1
      VBR Peak        : 313
      Buffer Average  : 397
    Duration: 00:06:09.13, start: 0.000000, bitrate: 2111 kb/s
      Stream #0:0: Audio: wmav2 (a[1][0][0] / 0x0161), 48000 Hz, 2 channels, s16, 96 kb/s
      Stream #0:1: Video: wmv3 (Main) (WMV3 / 0x33564D57), yuv420p, 860x484, 2000 kb/s, SAR 1:1 DAR 215:121, 29.97 tbr, 1k tbn, 1k tbc
  [wmv3 @ 0x13245c0] Extra data: 8 bits left, value: 20
  </code></pre>
  
  <p>while the result is:</p>
  
  <pre><code>Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf54.29.104
    Duration: 00:06:08.76, start: 0.000000, bitrate: 975 kb/s
      Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 645:484 DAR 215:121], 842 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
      Metadata:
        handler_name    : VideoHandler
      Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, s16, 125 kb/s
      Metadata:
        handler_name    : SoundHandler
  </code></pre>
  
  <p>cheers</p>