radek-k / FFMediaToolkit

FFMediaToolkit is a cross-platform video decoder/encoder library for .NET that uses FFmpeg native libraries. It supports video frames extraction, reading stream metadata and creating videos from bitmaps in any format supported by FFmpeg.
MIT License
353 stars 56 forks source link

Getting System.AccessViolationException when splitting video into frames #32

Closed shubmittal closed 3 years ago

shubmittal commented 3 years ago

I am using ffmpeg to extract frames and iterate over them. The codes iterates correctly over few frames and then then randomly throws error

"System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.' Any suggestions on how to resolve it? System details and screenshot below:

System Details: OS: Windows TargetFramework: .netCore3.1 Nugets: FFMediaToolkit v3.0.0 and SixLabors.ImageSharp v1.0.0 Shared dlls copied from: https://ffmpeg.zeranoe.com/builds/ for version 4.2.2

image

SKProCH commented 3 years ago

@radek-k i still expirience this exception on 3.1.0 release:

Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at FFmpeg.AutoGen.ffmpeg+<>c.<.cctor>b__6_453(FFmpeg.AutoGen.AVDictionary**)
   at FFmpeg.AutoGen.ffmpeg.av_dict_free(FFmpeg.AutoGen.AVDictionary**)
   at FFMediaToolkit.Common.FFDictionary.OnDisposing()
   at FFMediaToolkit.Common.Wrapper`1[[FFmpeg.AutoGen.AVDictionary, FFmpeg.AutoGen, Version=4.3.0.1, Culture=neutral, PublicKeyToken=9b7632533a381715]].Disposing(Boolean)
   at FFMediaToolkit.Common.Wrapper`1[[FFmpeg.AutoGen.AVDictionary, FFmpeg.AutoGen, Version=4.3.0.1, Culture=neutral, PublicKeyToken=9b7632533a381715]].Finalize()
Tom-da-Coder commented 3 years ago

Me too have the exact same problem. After some frames it can randomly throw this error. I use the latest (yesterday) code from GitHub and the Zeranoe shared builds, 64-bit Windows. My program is in .NET Core 3.1. I am converting mpeg1 files to images.

Tom-da-Coder commented 3 years ago

image

Tom-da-Coder commented 3 years ago

In Common.FFDictionary

Tom-da-Coder commented 3 years ago

Thank you for the answer I got by mail. I don't understand why I can see it here. But in any event I removed the "!" in front of requireDsiposing (above) and now I don't get any sudden accessvioloations, it works. Thanks!!!