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

Video.AddFrame(FrameToImageData(ImageData)) causes program to exit #125

Closed
wjadevries opened this issue Nov 7, 2022 · 0 comments
Closed

Comments

@wjadevries
Copy link

I have a C# Windows .net6 application where I want to capture video to a file.
I initialize a file like this:

var file = MediaBuilder.CreateContainer(outputFilePath).WithVideo(settings).Create();

In the Capture_NewFrame eventhandler (Aforge.Video.DirectShow) I save the incoming frames like this:

                System.Drawing.Bitmap bitmap = eventArgs.Frame;
                var rect = new System.Drawing.Rectangle(System.Drawing.Point.Empty, bitmap.Size);
                var bitLock = bitmap.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                var bitmapData = ImageData.FromPointer(bitLock.Scan0, ImagePixelFormat.Bgr24, bitmap.Size);
                file.Video.AddFrame(bitmapData);
                bitmap.UnlockBits(bitLock);

I have two cams: a Fantech Luminous C30 USB cam and an Integrated webcam in my Dell laptop.
The Fantech works fine; no issues.
But when I use the integrated webcam, the application quits unexpectedly when it reaches the call file.Video.AddFrame(bitmapData);
The code is in a try/catch block, but that isn't triggered. The application just quits.

The bitmapData for the integrated cam is Bgr24, 1280 x 720, Stride 3840, IsPooled = false, 2764800 bytes,
For the working Fantech cam the bitmapData is Bgr24, 1920 x 1080, Stride 5760, IsPooled = false, 6220800 bytes.

During the same Capture_NewFrame eventhandler I also show the incoming bitmap on an Image, which works fine for both cams.

In the event viewer I see this:

Faulting application name: TestCarMaster.exe, version: 0.7.0.0, time stamp: 0x6331eb0e
Faulting module name: swscale-6.dll, version: 6.8.112.0, time stamp: 0x6368faa4
Exception code: 0xc0000005
Fault offset: 0x000000000004b3d6
Faulting process ID: 0x1d87c
Faulting application start time: 0x01d8f2bad24f37e1
Faulting application path: C:\Repos\Wessel\Projects\TestCar\TestCarMaster\bin\Debug\net6.0-windows\TestCarMaster.exe
Faulting module path: C:\Repos\Wessel\Projects\TestCar\TestCarMaster\bin\Debug\net6.0-windows\ffmpeg\swscale-6.dll
Report ID: d8c8ee0c-38e1-47ab-ac72-9e4d23d950fd
Faulting package full name:
Faulting package-relative application ID:

@radek-k radek-k closed this as completed in 7861330 Aug 6, 2023
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

1 participant