ImageResizer FFmpeg 插件无法为帧生成图像
ImageResizer FFmpeg plugin failing to produce an image for a frame
使用与我们的应用程序集成的相当简单的 ImageResizer 安装。我们正在对其进行评估,因此尚未申请许可证。图像按预期调整大小(红点表示无许可),但我们正在尝试使用 FFmpeg 插件从视频中提取帧并遇到问题。
对于 myvideo.mp4?ffmpeg.seconds=1
或 myvideo.mp4?ffmpeg.percent=50
这样的请求,浏览器显示 The image ... cannot be displayed because it contains errors
,应用程序日志显示:
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)
更新
为了确保底层 ffmpeg 没有问题并实际从有问题的视频中提取图像,我使用命令行从中手动提取帧。完整输出如下,它按预期生成了 'test.png' 图像。
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
那么为什么ffmpeg.exe可以手动拉框,但是当我尝试通过浏览器和ImageResizer拉框时,出现上面的错误?
天啊,我不觉得害羞吗..我喜欢谦逊是件好事。 :-|
原来 the Ffmpeg documentation page 底部的注释非常重要:“确保使用 <pipeline vppusage="Always"/>
,否则 ffmpeg 将无法参与请求。”.
看起来应该在安装部分。
使用与我们的应用程序集成的相当简单的 ImageResizer 安装。我们正在对其进行评估,因此尚未申请许可证。图像按预期调整大小(红点表示无许可),但我们正在尝试使用 FFmpeg 插件从视频中提取帧并遇到问题。
对于 myvideo.mp4?ffmpeg.seconds=1
或 myvideo.mp4?ffmpeg.percent=50
这样的请求,浏览器显示 The image ... cannot be displayed because it contains errors
,应用程序日志显示:
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)
更新 为了确保底层 ffmpeg 没有问题并实际从有问题的视频中提取图像,我使用命令行从中手动提取帧。完整输出如下,它按预期生成了 'test.png' 图像。
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
那么为什么ffmpeg.exe可以手动拉框,但是当我尝试通过浏览器和ImageResizer拉框时,出现上面的错误?
天啊,我不觉得害羞吗..我喜欢谦逊是件好事。 :-|
原来 the Ffmpeg documentation page 底部的注释非常重要:“确保使用 <pipeline vppusage="Always"/>
,否则 ffmpeg 将无法参与请求。”.
看起来应该在安装部分。