ImageResizer FFmpeg plugin failing to produce an image for a frame

0

Using a fairly simple installation of ImageResizer, integrated with our application. We're evaluating it, and so have not applied a license yet. Images are resizing as expected (with the red dot for no license), but we're trying to pull frames from videos using the FFmpeg plugin and having problems.

With a request like myvideo.mp4?ffmpeg.seconds=1 or myvideo.mp4?ffmpeg.percent=50, the browser shows The image ... cannot be displayed because it contains errors, and application log shows:

ImageResizer.ImageCorruptedException (0x80004005): File may be corrupted, empty, or may contain a PNG image with a single dimension greater than 65,535 pixels. ---> System.ArgumentException: Parameter is not valid.
at System.Drawing.Bitmap..ctor(Stream stream, Boolean useIcm)
at ImageResizer.ImageBuilder.DecodeStream(Stream s, ResizeSettings settings, String optionalPath)
at ImageResizer.ImageBuilder.LoadImage(Object source, ResizeSettings settings, Boolean restoreStreamPos)
at ImageResizer.ImageBuilder.LoadImage(Object source, ResizeSettings settings, Boolean restoreStreamPos)
at ImageResizer.ImageBuilder.BuildJob(ImageJob job)
at ImageResizer.ImageBuilder.BuildInternal(ImageJob job)
at ImageResizer.ImageBuilder.BuildInQueue(ImageJob job, Boolean useSemaphore, Int32 maxQueuingMilliseconds, CancellationToken cancel)
at ImageResizer.ImageBuilder.Build(ImageJob job)
at ImageResizer.InterceptModule.<>c__DisplayClass5_0.<handlerequest>b__1(Stream stream)
at ImageResizer.Plugins.DiskCache.CustomDiskCache.<>c__DisplayClass29_0.<trywritefile>b__0()
at ImageResizer.Plugins.DiskCache.LockProvider.TryExecute(String key, Int32 timeoutMs, LockCallback success)
at ImageResizer.Plugins.DiskCache.CustomDiskCache.GetCachedFile(String keyBasis, String extension, ResizeImageDelegate writeCallback, Int32 timeoutMs, Boolean asynchronous)
at ImageResizer.Plugins.DiskCache.DiskCache.Process(IResponseArgs e)
at ImageResizer.Plugins.DiskCache.DiskCache.Process(HttpContext context, IResponseArgs e)
at ImageResizer.InterceptModule.HandleRequest(HttpContext context, HttpModuleRequestAssistant ra, IVirtualFile vf)
at ImageResizer.InterceptModule.CheckRequest_PostAuthorizeRequest(Object sender, EventArgs e)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

1: Source:

ImageResizer

1: Stack Trace:

at ImageResizer.ImageBuilder.LoadImage(Object source, ResizeSettings settings, Boolean restoreStreamPos)
1: at ImageResizer.ImageBuilder.BuildJob(ImageJob job)
1: at ImageResizer.ImageBuilder.BuildInternal(ImageJob job)
1: at ImageResizer.ImageBuilder.BuildInQueue(ImageJob job, Boolean useSemaphore, Int32 maxQueuingMilliseconds, CancellationToken cancel)
1: at ImageResizer.ImageBuilder.Build(ImageJob job)
1: at ImageResizer.InterceptModule.<>c__DisplayClass5_0.<handlerequest>b__1(Stream stream)
1: at ImageResizer.Plugins.DiskCache.CustomDiskCache.<>c__DisplayClass29_0.<trywritefile>b__0()
1: at ImageResizer.Plugins.DiskCache.LockProvider.TryExecute(String key, Int32 timeoutMs, LockCallback success)
1: at ImageResizer.Plugins.DiskCache.CustomDiskCache.GetCachedFile(String keyBasis, String extension, ResizeImageDelegate writeCallback, Int32 timeoutMs, Boolean asynchronous)
1: at ImageResizer.Plugins.DiskCache.DiskCache.Process(IResponseArgs e)
1: at ImageResizer.Plugins.DiskCache.DiskCache.Process(HttpContext context, IResponseArgs e)
1: at ImageResizer.InterceptModule.HandleRequest(HttpContext context, HttpModuleRequestAssistant ra, IVirtualFile vf)
1: at ImageResizer.InterceptModule.CheckRequest_PostAuthorizeRequest(Object sender, EventArgs e)
1: at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
1: at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
1: at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

UPDATE In order to make sure that there is no issue with the underlying ffmpeg and actually pulling an image from the video in question, i used the command line to pull a frame from it manually. Full output is below, and it produced the 'test.png' image as expected.

ffmpeg.exe -i P:\path\to\media\myvideo.mp4 -vframes 1 test.png
ffmpeg version N-69258-gf994000 Copyright (c) 2000-2015 the FFmpeg developers
  built on Jan 25 2015 22:21:16 with gcc 4.9.2 (GCC)
  configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --e
v --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm
e-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable
bvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libw
ble-lzma --enable-decklink --enable-zlib
  libavutil      54. 17.100 / 54. 17.100
  libavcodec     56. 20.100 / 56. 20.100
  libavformat    56. 19.100 / 56. 19.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5.  9.100 /  5.  9.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'P:\path\to\media\myvideo.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp41mp42isom
    creation_time   : 2018-02-07 00:14:12
    location        : +nn.nnnn-nnn.nnnn/
  Duration: 00:00:13.64, start: 0.000000, bitrate: 840 kb/s
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 98 kb/s (default)
    Metadata:
      creation_time   : 2018-02-07 00:14:12
      handler_name    : Core Media Audio
    Stream #0:1(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 568x320, 735 kb/s, 29.98 fps, 29.97 tbr,
    Metadata:
      rotate          : 90
      creation_time   : 2018-02-07 00:14:12
      handler_name    : Core Media Video
    Side data:
      displaymatrix: rotation of -90.00 degrees
Output #0, image2, to 'test.png':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp41mp42isom
    location        : +nn.nnnn-nnn.nnnn/
    encoder         : Lavf56.19.100
    Stream #0:0(und): Video: png, rgb24, 568x320, q=2-31, 200 kb/s, 29.97 fps, 29.97 tbn, 29.97 tbc (default)
    Metadata:
      rotate          : 90
      creation_time   : 2018-02-07 00:14:12
      handler_name    : Core Media Video
      encoder         : Lavc56.20.100 png
Stream mapping:
  Stream #0:1 -> #0:0 (h264 (native) -> png (native))
Press [q] to stop, [?] for help
frame=    1 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.03 bitrate=N/A
video:249kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

So why can ffmpeg.exe pull the frame manually, but when i try to do it through the browser and ImageResizer, i get the error above?

asp.net-mvc-4
imageresizer
asked on Stack Overflow Jan 27, 2021 by ilasno • edited Feb 15, 2021 by ilasno

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0