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
Access violation and heap corruption when disposing MediaFile object #61
Open any video file var mediaFile = MediaFile.Open(videoPath); then I got all the frames using TryReadNextFrame(out ImageData).
Then I wanted to dispose the mediaFile after that a heap corruption or access violation happens.
I have traced the problem to InputContainer class, OnDisposing() method line marked with ->>>>
protected override void OnDisposing()
{
Video?.Dispose();
var ptr = Pointer;
ffmpeg.avformat_close_input(&ptr);
// Note: the internal buffer could have changed, and be != avio_ctx_buffer
if (Pointer->pb != null)
{
ffmpeg.av_free(Pointer->pb->buffer);
->>>> ffmpeg.avio_context_free(&Pointer->pb);
}
}
Open any video file
var mediaFile = MediaFile.Open(videoPath);
then I got all the frames usingTryReadNextFrame(out ImageData)
. Then I wanted to dispose the mediaFile after that a heap corruption or access violation happens. I have traced the problem to InputContainer class, OnDisposing() method line marked with ->>>>