shimat / opencvsharp

OpenCV wrapper for .NET
Apache License 2.0
5.39k stars 1.15k forks source link

Videowriter Output missing on x86 Platforms #1407

Closed jw-suh closed 1 year ago

jw-suh commented 2 years ago

Summary of your issue

When using opencvsharp to create a mp4 file in a 32-bit WPF application, no output file is generated. Easily reproducible by creating a new Console Application (in my case .NET core 3.1) and adding the Platform Target x86. The error is reproducible with a console application, for completion’s sake we are encountering this issue in a WPF application.

Environment

Using .NET core 3.1 with the following Nuget Packages:

The application is built and run on a 64-bit Windows 10 machine

What did you do when you faced the problem?

Create a VideoWriter like so:

var videoWriter = new VideoWriter($@"C:\Temp\Snapshots\TestTimelapse\TestTimelapse.mp4", FourCC.Default, 20, new OpenCvSharp.Size(2304, 1296), true);

and add frames (in my case 100) to it with the Write() Method:

var allFrames = Directory
  .EnumerateFiles($@"C:\Temp\Snapshots\TestTimelapse", "*.jpg")
  .Select(file => new FileInfo(file))
  .OrderBy(file => file.CreationTime)
  .Select(file => File.ReadAllBytes(file.FullName))
  .Select(fileContent => Mat.FromImageData(fileContent, ImreadModes.AnyColor))
  .ToList();

foreach (var frame in allFrames)
  videoWriter.Write(frame);

videoWriter.Dispose();

Project to reproduce(~ 16kb): VideoWriterx86.zip

Picture to reproduce (~ 13mb): TestTimelapse.zip

Output:

The folder only contains the images and no additional file was created.

Console output:

OpenCV: FFMPEG: format mp4 / MP4 (MPEG-4 Part 14)
fourcc tag 0x7634706d/'mp4v' codec_id 000C
fourcc tag 0x31637661/'avc1' codec_id 001B
fourcc tag 0x33637661/'avc3' codec_id 001B
fourcc tag 0x31766568/'hev1' codec_id 00AD
fourcc tag 0x31637668/'hvc1' codec_id 00AD
fourcc tag 0x7634706d/'mp4v' codec_id 0002
fourcc tag 0x7634706d/'mp4v' codec_id 0001
fourcc tag 0x7634706d/'mp4v' codec_id 0007
fourcc tag 0x7634706d/'mp4v' codec_id 003D
fourcc tag 0x7634706d/'mp4v' codec_id 0058
fourcc tag 0x312d6376/'vc-1' codec_id 0046
fourcc tag 0x63617264/'drac' codec_id 0074
fourcc tag 0x7634706d/'mp4v' codec_id 00A3
fourcc tag 0x39307076/'vp09' codec_id 00A7
fourcc tag 0x31307661/'av01' codec_id 801D
fourcc tag 0x6134706d/'mp4a' codec_id 15002
fourcc tag 0x63616c61/'alac' codec_id 15010
fourcc tag 0x6134706d/'mp4a' codec_id 1502D
fourcc tag 0x6134706d/'mp4a' codec_id 15001
fourcc tag 0x6134706d/'mp4a' codec_id 15000
fourcc tag 0x332d6361/'ac-3' codec_id 15003
fourcc tag 0x332d6365/'ec-3' codec_id 15028
fourcc tag 0x6134706d/'mp4a' codec_id 15004
fourcc tag 0x61706c6d/'mlpa' codec_id 1502C
fourcc tag 0x43614c66/'fLaC' codec_id 1500C
fourcc tag 0x7375704f/'Opus' codec_id 1503C
fourcc tag 0x6134706d/'mp4a' codec_id 15005
fourcc tag 0x6134706d/'mp4a' codec_id 15018
fourcc tag 0x6134706d/'mp4a' codec_id 15803
fourcc tag 0x7334706d/'mp4s' codec_id 17000
fourcc tag 0x67337874/'tx3g' codec_id 17005
fourcc tag 0x646d7067/'gpmd' codec_id 18807
fourcc tag 0x316d686d/'mhm1' codec_id 15817

What did you intend to be?

I expected the frames to be added to a video file with the file extension .mp4

jw-suh commented 2 years ago

Can anyone confirm or deny that this issue exists outside of our development environment? We still have this issue and can reproduce it on all of our development machines.

Guyiming commented 2 years ago

I have the same problem.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.