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
352 stars 56 forks source link

MediaFile.Video.ReadFrame() sometimes causes crash #40

Closed Reimnop closed 3 years ago

Reimnop commented 3 years ago

I'm using .NET Core 3.1. App runs fine if the crash doesn't happen. It seems to happen randomly. image Code: image

redbaty commented 3 years ago

I'm having this problem aswell, and I've managed to narrowed it down to FFDictionary dispose method, especifacally when it calls:

ffmpeg.av_dict_free(&ptr);

To reproduce it, I've been creating new MediaFile on a loop (not parallel, just a good old for) and trying to extract a frame, on the same video file.

manojkumarvstrenser commented 3 years ago

I also have the same issue. We could reproduce the issue in .NET core 3.1

var videoFile = MediaFile.Open(moviePath); ImageData data1 = videoFile.Video.ReadFrame(new TimeSpan(0, 0, 0, 0, 15)); videoFile.Dispose();

The Dispose() method is crashing some times.

kskalski commented 3 years ago

Not sure if that is really related, but I think there is a bug in FFDictinoary Dispose method, which I fixed here https://github.com/radek-k/FFMediaToolkit/pull/46