0

The FFMPEG command I am using for scaling then cropping is working perfectly in 5 of 6 cases I am processing, but for a reason I don't understand in one case it is not working at all.

dimensions of input jpg file = 774x1032

  • dimensions of output jpg file = 1000x1000 --> OK
  • dimensions of output jpg file = 400x200 --> OK
  • dimensions of output jpg file = 750x200 --> OK
  • dimensions of output jpg file = 350x200 --> OK
  • dimensions of output jpg file = 400x350 --> OK

dimsions of output jpg file = 200x200 --> ERROR

ffmpeg -y -i input.jpg -vf "transpose=clock:passthrough=landscape,scale=(iw*sar)max(200/(iwsar)\,200/ih):ihmax(200/(iwsar)\,200/ih),crop=200:200" -q:v 1 output.jpg;

this is running in a batch process, taking as input hundred of files, and always happen the same when scaling&cropping to 200x200...

the ffmpeg output is

ffmpeg version 4.1.3 Copyright (c) 2000-2019 the FFmpeg developers

built with gcc 8.3.1 (GCC) 20190414

configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth

libavutil 56. 22.100 / 56. 22.100 libavcodec 58. 35.100 / 58. 35.100 libavformat 58. 20.100 / 58. 20.100 libavdevice 58. 5.100 / 58. 5.100 libavfilter 7. 40.101 / 7. 40.101 libswscale 5. 3.100 / 5. 3.100 libswresample 3. 3.100 / 3. 3.100 libpostproc 55. 3.100 / 55. 3.100

Input #0, image2, from '/_DEV/input.jpg': Duration: 00:00:00.04, start: 0.000000, bitrate: 144801 kb/s Stream #0:0: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 774x1032 [SAR 1:1 DAR 3:4], 25 tbr, 25 tbn, 25 tbc

Stream mapping:

Stream #0:0 -> #0:0 (mjpeg (native) -> mjpeg (native))

Press [q] to stop, [?] for help [swscaler @ 050e4100] deprecated pixel format used, make sure you did set range correctly

[Parsed_crop_2 @ 050d9140] Invalid too big or non positive size for width '200' or height '200'

[Parsed_crop_2 @ 050d9140] Failed to configure input pad on Parsed_crop_2

Error reinitializing filters!

Failed to inject frame into filter network: Invalid argument

Error while processing the decoded data for stream #0:0

Conversion failed!

Any idea on how to fix this?

1
  • Recheck your command and paste it again. Some symbols are missing.
    – Gyan
    Commented Jul 12, 2019 at 5:09

1 Answer 1

1

The problem is that when scaling your input 774x1032, it becomes smaller than 200x200, so you cannot crop it to 200x200. That's what the error is telling you.

You could "fix" this by specifying an additional min(…) function in the crop width and height, to make sure it crops only to the minimum of min(ih,200) and min(iw,200).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .