Answers.Body: <p>The general limiting rule is <code>((Width * 8) + 1024)*(Height + 128) &lt; INT_MAX</code>. The rationale being, that all pixels of an image plane should be accessible using a signed integer index.</p>
  
  <p>On a machine with 32-bit integers, INT MAX is 2147483647.</p>
  
  <p>So, <code>((32768 * 8) + 1024)*(16384 + 128) = 4345430016</code> which is <code>&gt; 2147483647</code>.</p>
  
  <p>Now, it's possible there is a bug with the image size check, in that the factor 8 applied to the width is prematurely applied in most cases and can be skipped. You can raise a ticket at trac.ffmpeg.org if you want to explore that possibility. Else, you'll need to use another tool (maybe Imagemagick).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-03T13:44:46.937Z
Answers.LastActivityDate: 2019-09-03T13:44:46.937Z
Answers.UserDisplayName: Gyan
Body: <p>I need to use ffmpeg with very large images (32768x16384).
  When I try to read such an image I get the error:</p>
  
  <pre><code>Picture size 32768x16384 is invalid
  </code></pre>
  
  <p>It it does not matter what operation I want to do on the image (like scaling, v360 cutout etc.) it already fails at the read-in stage.
  I tried JPG and PNG as input formats.</p>
  
  <p>Full log with demonstration operation (scale 32k to 16k)</p>
  
  <pre><code>E:\XXX\Pipeline&gt;"E:\XXX\Pipeline\bin\ffmpeg.exe" -y -i E:\XXX\Pipeline\calibration_sphere32k.jpg -vf scale=16384:-2 "calibration_sphere32k_scaled.jpg"
  ffmpeg version N-94664-g0821bc4eee Copyright (c) 2000-2019 the FFmpeg developers
    built with gcc 9.1.1 (GCC) 20190807
    configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --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 --enable-libopenmpt
    libavutil      56. 33.100 / 56. 33.100
    libavcodec     58. 55.101 / 58. 55.101
    libavformat    58. 31.104 / 58. 31.104
    libavdevice    58.  9.100 / 58.  9.100
    libavfilter     7. 58.101 /  7. 58.101
    libswscale      5.  6.100 /  5.  6.100
    libswresample   3.  6.100 /  3.  6.100
    libpostproc    55.  6.100 / 55.  6.100
  [mjpeg @ 000001eefc88ab80] [IMGUTILS @ 000000acfa1fef30] Picture size 32768x16384 is invalid
  [image2 @ 000001eefc878740] decoding for stream 0 failed
  [image2 @ 000001eefc878740] Could not find codec parameters for stream 0 (Video: mjpeg (Baseline), none(bt470bg/unknown/unknown)): unspecified size
  Consider increasing the value for the 'analyzeduration' and 'probesize' options
  Input #0, image2, from 'E:\XXX\Pipeline\calibration_sphere32k.jpg':
    Duration: 00:00:00.04, start: 0.000000, bitrate: 20939328 kb/s
      Stream #0:0: Video: mjpeg (Baseline), none(bt470bg/unknown/unknown), 25 tbr, 25 tbn, 25 tbc
  Stream mapping:
    Stream #0:0 -&gt; #0:0 (mjpeg (native) -&gt; mjpeg (native))
  Press [q] to stop, [?] for help
  [mjpeg @ 000001eefc88d3c0] [IMGUTILS @ 000000acfa1ff050] Picture size 32768x16384 is invalid
  Error while decoding stream #0:0: Invalid data found when processing input
  Cannot determine format of input stream 0:0 after EOF
  Error marking filters as finished
  Conversion failed!
  </code></pre>
  
  <p><strong>EDIT</strong>
  Found out, that the maximum horizontal resolution is: 22976.
  This is a very odd number.</p>
  
Tags: <ffmpeg>
Title: How to fix: ffmpeg: Picture size 32768x16384 is invalid?
UserDisplayName: Piranha
ThreadText: # How to fix: ffmpeg: Picture size 32768x16384 is invalid?
  
  (Asked by: username_0 on 2019-09-03)
  
  I need to use ffmpeg with very large images (32768x16384).
  When I try to read such an image I get the error:
  
  ```
  Picture size 32768x16384 is invalid
  
  ```
  
  It it does not matter what operation I want to do on the image (like scaling, v360 cutout etc.) it already fails at the read-in stage.
  I tried JPG and PNG as input formats.
  
  Full log with demonstration operation (scale 32k to 16k)
  
  ```
  E:\XXX\Pipeline>"E:\XXX\Pipeline\bin\ffmpeg.exe" -y -i E:\XXX\Pipeline\calibration_sphere32k.jpg -vf scale=16384:-2 "calibration_sphere32k_scaled.jpg"
  ffmpeg version N-94664-g0821bc4eee Copyright (c) 2000-2019 the FFmpeg developers
    built with gcc 9.1.1 (GCC) 20190807
    configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --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 --enable-libopenmpt
    libavutil      56. 33.100 / 56. 33.100
    libavcodec     58. 55.101 / 58. 55.101
    libavformat    58. 31.104 / 58. 31.104
    libavdevice    58.  9.100 / 58.  9.100
    libavfilter     7. 58.101 /  7. 58.101
    libswscale      5.  6.100 /  5.  6.100
    libswresample   3.  6.100 /  3.  6.100
    libpostproc    55.  6.100 / 55.  6.100
  [mjpeg @ 000001eefc88ab80] [IMGUTILS @ 000000acfa1fef30] Picture size 32768x16384 is invalid
  [image2 @ 000001eefc878740] decoding for stream 0 failed
  [image2 @ 000001eefc878740] Could not find codec parameters for stream 0 (Video: mjpeg (Baseline), none(bt470bg/unknown/unknown)): unspecified size
  Consider increasing the value for the 'analyzeduration' and 'probesize' options
  Input #0, image2, from 'E:\XXX\Pipeline\calibration_sphere32k.jpg':
    Duration: 00:00:00.04, start: 0.000000, bitrate: 20939328 kb/s
      Stream #0:0: Video: mjpeg (Baseline), none(bt470bg/unknown/unknown), 25 tbr, 25 tbn, 25 tbc
  Stream mapping:
    Stream #0:0 -> #0:0 (mjpeg (native) -> mjpeg (native))
  Press [q] to stop, [?] for help
  [mjpeg @ 000001eefc88d3c0] [IMGUTILS @ 000000acfa1ff050] Picture size 32768x16384 is invalid
  Error while decoding stream #0:0: Invalid data found when processing input
  Cannot determine format of input stream 0:0 after EOF
  Error marking filters as finished
  Conversion failed!
  
  ```
  
  **EDIT**
  Found out, that the maximum horizontal resolution is: 22976.
  This is a very odd number.
  
  **Tags:** ffmpeg
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-09-03. Score: 3 | Accepted answer
  
  The general limiting rule is `((Width * 8) + 1024)*(Height + 128) < INT_MAX`. The rationale being, that all pixels of an image plane should be accessible using a signed integer index.
  
  On a machine with 32-bit integers, INT MAX is 2147483647.
  
  So, `((32768 * 8) + 1024)*(16384 + 128) = 4345430016` which is `> 2147483647`.
  
  Now, it's possible there is a bug with the image size check, in that the factor 8 applied to the width is prematurely applied in most cases and can be skipped. You can raise a ticket at trac.ffmpeg.org if you want to explore that possibility. Else, you'll need to use another tool (maybe Imagemagick).
  
  
  ---
  
  