question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[ffmpeg] v8.6.0/8.6.1 - MagickImageCollection partially retrieves frames of certain mp4 videos

See original GitHub issue

Description

On Magick.NET version 8.6.0 and 8.6.1, loading an mp4 in a MagickImageCollection only returns a partial amount of frames and fails to properly reproduce all frames from the source video(s) on certain mp4 files.

Steps to Reproduce

Ensure ffmpeg 4.4.1 exists in the PATH env variable and rename the attached mp4 to ryu.mp4 if not already named:

  1. Create a new dotnet console app targeting .NET 6 using dotnet new console
  2. Add Magick.NET-Q16-x64 v8.6.1 NuGet package
  3. Paste the following code into Program.cs
  4. Build using dotnet build -c Release -r win-x64
  5. Copy the ryu.mp4 to bin\Release\net6.0\win-x64
  6. Run the executable from the bin\Release\net6.0\win-x64 directory

           using (var imgCol = new MagickImageCollection("ryu.mp4"))
           {
            Console.WriteLine("Total frames: " + imgCol.Count);
            await imgCol.WriteAsync("ryu1.mp4");
            await imgCol.WriteAsync("ryu1.gif");
           }

           using (var imgCol = new MagickImageCollection("ryu1.mp4"))
           {
            Console.WriteLine("Total frames: " + imgCol.Count);
           }

           using (var imgCol = new MagickImageCollection("ryu1.gif"))
           {
            Console.WriteLine("Total frames: " + imgCol.Count);
           }

https://user-images.githubusercontent.com/4016293/149682455-8ad5a0bc-6de5-4e68-aa66-fe273d4a1a45.mp4

The output on 8.6.1 should be:

Total frames: 5 
Total frames: 5
Total frames: 5

On 8.5.0, the output should be:

Total frames: 119
Total frames: 119
Total frames: 119

BONUS targeting arm64

Use the same steps to build as above, but with the following modifications:

  1. Use Magick.NET-Q16-arm64
  2. Build using dotnet build -c Release -r win-arm64
  3. Copy the ryu.mp4 to bin\Release\net6.0\win-arm64
  4. Run the executable from the bin\Release\net6.0\win-arm64 directory

8.6.1 on arm64 (Magick.NET-Q16-arm64) returns:

Total frames: 1
Total frames: 1
Total frames: 1

0.2022.113.2048 returns:

Total frames: 119
Total frames: 119
Total frames: 119

System Configuration

  • Magick.NET version: 8.6.1
  • Environment (Operating system, version and so on): Windows 11 Arm64 22533, .NET 6.0 (x64 compiled app).
  • Additional information:
    • Using FFMPEG 4.4.1 from https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-4.4.1-full_build.7z.
    • FFMPEG 4.4.1 Arm64 built from vcpkg (attached, but can be built with the command below):
    •  .\vcpkg.exe install ffmpeg[ffmpeg,fdk-aac,fontconfig,freetype,fribidi,iconv,ilbc,lzma,mp3lame,modplug,opencl,openjpeg,openssl,opus,sdl2,snappy,soxr,speex,theora,vorbis,vpx,webp]:arm64-windows-static
      

ffmpeg-4-4-1-arm64.zip

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dlemstracommented, Jan 18, 2022

I hope I understand your question correctly but instead of having a picture for each frame you name have a picture that is valid for an “AnimationDelay”. That means that if a frame doesn’t change each frame it will be valid for “AnimationDelay”.

1reaction
dlemstracommented, Jan 18, 2022

Because we now use webp instead of pam as the format when reading the frames of the fle. The number of frames is changed because the animation delay is now set. You can see that when you print the following:

foreach(var img in imgCol)
{
    Console.WriteLine(img.AnimationDelay);
}

In earlier versions this value was 0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found