shmit
shmit

Reputation: 2524

ffmpeg throwing System.AccessViolationException

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

ErrorScreenshot

Upvotes: 0

Views: 617

Answers (1)

SuRGeoNix
SuRGeoNix

Reputation: 617

I'm not familiar with this library but from the stack trace it seems that you close an AVFormatContext which is possible already closed or not initialized yet. Review your code and make sure that you don't do that. Worst case you could also try to add the following above your function and discard the exception:-

[HandleProcessCorruptedStateExceptions]
[SecurityCritical]
void avcloseinputFunction() {
try { avformat_close_input ... } catch (Exception e) {}
}

Upvotes: 1

Related Questions