title: Why does this ffmpeg filter result in an "Invalid Size" error?
body: <p>Why do I see this error message:</p>
  <blockquote>
  <p>[Parsed_scale_0 @ 0x559a264c28a0] Invalid size 'if(gt(iw'</p>
  <p>[AVFilterGraph @ 0x559a268a19e0] Error initializing filter 'scale'</p>
  <p>with args 'if(gt(iw' Error initializing complex filters.</p>
  <p>Invalid argument</p>
  </blockquote>
  <p>when trying to crop a video using ffmpeg and the following complex filter:</p>
  <pre><code>ffmpeg -f mp4 -ss 01:24 \ 
    -i https://storage.googleapis.com/bucket/video.mp4 \
    -y \
    -filter_complex scale='if(gt(iw,ih),-1,616):if(gt(iw,ih),1440,-1)', crop=1440:616 \
    -an \
    -vcodec libx264 \
    -r 60 -pix_fmt yuv420p \
    -movflags faststart \
    -f mp4 \
    -t 1 \
    /tmp/asset.1554913197962.mp4
  </code></pre>
  <p>In case it's relevant, here's the output of ffprobe:</p>
  <pre><code>Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'https://storage.googleapis.com/bucket/video.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf57.56.101
    Duration: 00:02:53.76, start: 0.000000, bitrate: 2910 kb/s
      Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 2777 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default)
      Metadata:
        handler_name    : VideoHandler
      Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
      &quot;streams&quot;: [
          {
              &quot;index&quot;: 0,
              &quot;codec_name&quot;: &quot;h264&quot;,
              &quot;codec_long_name&quot;: &quot;H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10&quot;,
              &quot;profile&quot;: &quot;High&quot;,
              &quot;codec_type&quot;: &quot;video&quot;,
              &quot;codec_time_base&quot;: &quot;1001/60000&quot;,
              &quot;codec_tag_string&quot;: &quot;avc1&quot;,
              &quot;codec_tag&quot;: &quot;0x31637661&quot;,
              &quot;width&quot;: 1920,
              &quot;height&quot;: 1080,
              &quot;coded_width&quot;: 1920,
              &quot;coded_height&quot;: 1080,
              &quot;has_b_frames&quot;: 1,
              &quot;sample_aspect_ratio&quot;: &quot;1:1&quot;,
              &quot;display_aspect_ratio&quot;: &quot;16:9&quot;,
              &quot;pix_fmt&quot;: &quot;yuv420p&quot;,
              &quot;level&quot;: 40,
              &quot;color_range&quot;: &quot;tv&quot;,
              &quot;color_space&quot;: &quot;bt709&quot;,
              &quot;color_transfer&quot;: &quot;bt709&quot;,
              &quot;color_primaries&quot;: &quot;bt709&quot;,
              &quot;chroma_location&quot;: &quot;left&quot;,
              &quot;refs&quot;: 1,
              &quot;is_avc&quot;: &quot;true&quot;,
              &quot;nal_length_size&quot;: &quot;4&quot;,
              &quot;r_frame_rate&quot;: &quot;30000/1001&quot;,
              &quot;avg_frame_rate&quot;: &quot;30000/1001&quot;,
              &quot;time_base&quot;: &quot;1/90000&quot;,
              &quot;start_pts&quot;: 0,
              &quot;start_time&quot;: &quot;0.000000&quot;,
              &quot;duration_ts&quot;: 15633630,
              &quot;duration&quot;: &quot;173.707000&quot;,
              &quot;bit_rate&quot;: &quot;2777254&quot;,
              &quot;bits_per_raw_sample&quot;: &quot;8&quot;,
              &quot;nb_frames&quot;: &quot;5206&quot;,
              &quot;disposition&quot;: {
                  &quot;default&quot;: 1,
                  &quot;dub&quot;: 0,
                  &quot;original&quot;: 0,
                  &quot;comment&quot;: 0,
                  &quot;lyrics&quot;: 0,
                  &quot;karaoke&quot;: 0,
                  &quot;forced&quot;: 0,
                  &quot;hearing_impaired&quot;: 0,
                  &quot;visual_impaired&quot;: 0,
                  &quot;clean_effects&quot;: 0,
                  &quot;attached_pic&quot;: 0,
                  &quot;timed_thumbnails&quot;: 0
              },
              &quot;tags&quot;: {
                  &quot;language&quot;: &quot;und&quot;,
                  &quot;handler_name&quot;: &quot;VideoHandler&quot;
              }
          },
          {
              &quot;index&quot;: 1,
              &quot;codec_name&quot;: &quot;aac&quot;,
              &quot;codec_long_name&quot;: &quot;AAC (Advanced Audio Coding)&quot;,
              &quot;profile&quot;: &quot;LC&quot;,
              &quot;codec_type&quot;: &quot;audio&quot;,
              &quot;codec_time_base&quot;: &quot;1/44100&quot;,
              &quot;codec_tag_string&quot;: &quot;mp4a&quot;,
              &quot;codec_tag&quot;: &quot;0x6134706d&quot;,
              &quot;sample_fmt&quot;: &quot;fltp&quot;,
              &quot;sample_rate&quot;: &quot;44100&quot;,
              &quot;channels&quot;: 2,
              &quot;channel_layout&quot;: &quot;stereo&quot;,
              &quot;bits_per_sample&quot;: 0,
              &quot;r_frame_rate&quot;: &quot;0/0&quot;,
              &quot;avg_frame_rate&quot;: &quot;0/0&quot;,
              &quot;time_base&quot;: &quot;1/44100&quot;,
              &quot;start_pts&quot;: 0,
              &quot;start_time&quot;: &quot;0.000000&quot;,
              &quot;duration_ts&quot;: 7662596,
              &quot;duration&quot;: &quot;173.755011&quot;,
              &quot;bit_rate&quot;: &quot;125588&quot;,
              &quot;max_bit_rate&quot;: &quot;125588&quot;,
              &quot;nb_frames&quot;: &quot;7483&quot;,
              &quot;disposition&quot;: {
                  &quot;default&quot;: 1,
                  &quot;dub&quot;: 0,
                  &quot;original&quot;: 0,
                  &quot;comment&quot;: 0,
                  &quot;lyrics&quot;: 0,
                  &quot;karaoke&quot;: 0,
                  &quot;forced&quot;: 0,
                  &quot;hearing_impaired&quot;: 0,
                  &quot;visual_impaired&quot;: 0,
                  &quot;clean_effects&quot;: 0,
                  &quot;attached_pic&quot;: 0,
                  &quot;timed_thumbnails&quot;: 0
              },
              &quot;tags&quot;: {
                  &quot;language&quot;: &quot;eng&quot;,
                  &quot;handler_name&quot;: &quot;SoundHandler&quot;
              }
          }
      ],
      &quot;format&quot;: {
          &quot;filename&quot;: &quot;https://storage.googleapis.com/bucket/video.mp4&quot;,
          &quot;nb_streams&quot;: 2,
          &quot;nb_programs&quot;: 0,
          &quot;format_name&quot;: &quot;mov,mp4,m4a,3gp,3g2,mj2&quot;,
          &quot;format_long_name&quot;: &quot;QuickTime / MOV&quot;,
          &quot;start_time&quot;: &quot;0.000000&quot;,
          &quot;duration&quot;: &quot;173.755000&quot;,
          &quot;size&quot;: &quot;63209767&quot;,
          &quot;bit_rate&quot;: &quot;2910294&quot;,
          &quot;probe_score&quot;: 100,
          &quot;tags&quot;: {
              &quot;major_brand&quot;: &quot;isom&quot;,
              &quot;minor_version&quot;: &quot;512&quot;,
              &quot;compatible_brands&quot;: &quot;isomiso2avc1mp41&quot;,
              &quot;encoder&quot;: &quot;Lavf57.56.101&quot;
          }
      }
  }
  </code></pre>