Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception "Invalid minimum required packet size" in Version 14.1 and up #1761

Closed
TheNetStriker opened this issue Nov 28, 2024 · 5 comments
Closed
Milestone

Comments

@TheNetStriker
Copy link

TheNetStriker commented Nov 28, 2024

Magick.NET version

14.2 Magick.NET-Q16-HDRI-AnyCPU

Environment (Operating system, version and so on)

Windows 10

Description

After I've updated from version 14.0 to 14.2 I get the following error after a long period when trying to create a thumbnail from a GoPro video:

ImageMagick.MagickDelegateErrorException : VideoDelegateFailed `[libwebp_anim @ 000001e45c4900c0] Invalid minimum required packet size 2627894982 (max allowed is 2147483583)
video encoding failed: Invalid argument
' @ error/video.c/ReadVIDEOImage/273

  Stack Trace: 
UnitTest1.SaveVideoThumbnailTest() line 411
--- End of stack trace from previous location ---
----- Inner Stack Trace -----
NativeInstance.CheckException(IntPtr exception, IntPtr result) line 54
NativeMagickImage.ReadStream(IMagickSettings`1 settings, ReadWriteStreamDelegate reader, SeekStreamDelegate seeker, TellStreamDelegate teller, Void* data) line 6139
NativeMagickImage.ReadStream(IMagickSettings`1 settings, ReadWriteStreamDelegate reader, SeekStreamDelegate seeker, TellStreamDelegate teller) line 7536
MagickImage.Read(Stream stream, IMagickReadSettings`1 readSettings, Boolean ping) line 7455
MagickImage.Read(Stream stream, IMagickReadSettings`1 readSettings) line 4658
MagickImage.ctor(Stream stream, IMagickReadSettings`1 readSettings) line 192
StaticFunctions.SaveImageThumbnail(idCatalogItem catalogItem, IDImagerDB db, IDImagerThumbsDB dbThumbs, List`1 types, ServiceSettings serviceSettings) line 105

The error also occurs in version 14.1. Only if I downgrade to 14.0 again it works.

Any idea what could cause this problem?

Steps to Reproduce

Here is a code example:

if (Enum.TryParse<MagickFormat>("MP4", true, out MagickFormat magickFormat))
{
    magickReadSettings = new MagickReadSettings { Format = magickFormat };
    MagickImage image = new MagickImage(imageStream, magickReadSettings)
    {
        Format = MagickFormat.Jpeg,
    };
}

The error occurs on the new MagickImage line after a long period. (I measured 33.3 minutes with my unit test)

@dlemstra
Copy link
Owner

There is no version 4.2, did you mean 14.2? Are you sure that only this library got upgraded and not a library on your system? The ffmpeg executable is used to read your video and I suspect that something changed there?

@TheNetStriker TheNetStriker changed the title Exception "Invalid minimum required packet size" in Version 4.1 and up Exception "Invalid minimum required packet size" in Version 14.1 and up Nov 29, 2024
@TheNetStriker
Copy link
Author

TheNetStriker commented Nov 29, 2024

There is no version 4.2, did you mean 14.2? Are you sure that only this library got upgraded and not a library on your system? The ffmpeg executable is used to read your video and I suspect that something changed there?

Sorry I mistyped the version number. Yes I meant the 14.2 version. I've just updated the title and text with the correct version number.

I did only change the library version to reproduce this.

I did some more test's and I guess I found out what is causing this issue. I tracked the ffmpeg command line arguments of both library versions using ProcessMonitor and found out that from version 14.1 the -vframes 1 command line argument of the ffmpeg process is missing. Instead there are just two spaces:

rawvideo -y -vcodec webp

In version 14.0 the -vframes 1 argument is just between those two arguments. This causes the ffmpeg command to run for a long time and then it causes the error.

Any idea why this command line argument was removed?

@dlemstra
Copy link
Owner

Thanks for all your research! I suspect that was removed to make it possible to read all the images in your mp4 file. But that should happen automatically when you use a MagickImage. I will need to figure out why this is no longer happening but I suspect I removed this by accident. Setting FrameCount = 1 in the MagickReadSettings should fix your issue for now.

@TheNetStriker
Copy link
Author

Thanks for all your research! I suspect that was removed to make it possible to read all the images in your mp4 file. But that should happen automatically when you use a MagickImage. I will need to figure out why this is no longer happening but I suspect I removed this by accident. Setting FrameCount = 1 in the MagickReadSettings should fix your issue for now.

Thanks for the hint. Setting FrameCount = 1 solves the problem for now.

@dlemstra
Copy link
Owner

I checked my commit history and it looks like I broke this by accident. This will be resolved in the next release and then FrameCount will default to 1 again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants