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 thrown at (swscale-5.dll) Access violation reading location #87

Closed
NormantasST opened this issue May 23, 2021 · 1 comment
Closed
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@NormantasST
Copy link

NormantasST commented May 23, 2021

The full error is "Exception thrown at 0x00007FFB719230C2 (swscale-5.dll) in GrayScaleFilter.exe: 0xC0000005: Access violation reading location 0x000001B5E690B000."

I'm using one function to export images into a folder. Another to build a video from them.

my code:

private static void CombineImagesUsingFFMTK(string fileLocation, int frameCount)
        {
            File.Delete(outputPath);
            System.IO.DirectoryInfo directory = new DirectoryInfo(outputImageDir);
            FFMediaToolkit.Decoding.MediaFile mediaFile = FFMediaToolkit.Decoding.MediaFile.Open(fileLocation);
            // You can set there codec, bitrate, frame rate and many other options.
            var settings = new VideoEncoderSettings(width: mediaFile.Video.Info.FrameSize.Width, height: mediaFile.Video.Info.FrameSize.Height, framerate: 30, codec: VideoCodec.H264);
            settings.EncoderPreset = EncoderPreset.Fast;
            settings.CRF = 17;
            using (var video = MediaBuilder.CreateContainer(outputPath).WithVideo(settings).Create())
            {
                for (int i = 0; i < frameCount; i++)
                {
                    Bitmap bitmap = new Bitmap($"{outputImageDir}\\{i}.jpeg");
                    System.Drawing.Rectangle rect = new System.Drawing.Rectangle(System.Drawing.Point.Empty, bitmap.Size);
                    BitmapData bitLock = bitmap.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
                    FFMediaToolkit.Graphics.ImageData bitmapImageData = FFMediaToolkit.Graphics.ImageData.FromPointer(bitLock.Scan0, ImagePixelFormat.Bgr24, bitmap.Size);
                    Console.WriteLine($"Adding: image {outputImageDir}\\{i}.jpeg to video");
                    video.Video.AddFrame(bitmapImageData);
                    bitmap.UnlockBits(bitLock);
                }
            }
        }

The error happens on line video.Video.AddFrame(bitmapImageData);

I looked into other issues, with similar problems (write protected, access violation) and modified from the example code into this. Not sure what to do.

Tried using different libraries to decode the video but this one feels like the most Intuitive. I had a version (Using Splicer) where I get the video, but I can't use the timeline to skip video and it runs on 1fps, 73frames (2,3sec video) becomes 73sec video.

@radek-k radek-k added bug Something isn't working help wanted Extra attention is needed labels Jun 12, 2021
@sunilhalvie
Copy link

Hi Normantas,
I am facing the same issue, can you please guide me to solve this if you had figured it out?

@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
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants