0

Regarding https://github.com/Ruslan-B/FFmpeg.AutoGen.Questions/issues/36.

I am using FFmpeg.AutoGen to inject per-Frame Metadata into a video in my C# program via an H.264 SEI Message. Works great. To do so I use av_frame_new_side_data_from_buf(), which requires an AVBuffer to hold the SEI message, pointed at via an AVBufferRef. This behavior is achieved via the following block. ( Full source file referenced in the GitHub issue. )

fixed (byte* pMessageData = message)
{
    AVBufferRef* MetaDataBuffer = ffmpeg.av_buffer_alloc((ulong)message.Length);
    MetaDataBuffer->data = pMessageData;
    AVFrameSideData* sideData = ffmpeg.av_frame_new_side_data_from_buf(&frame, AVFrameSideDataType.AV_FRAME_DATA_SEI_UNREGISTERED, MetaDataBuffer);
}

This creates a memory leak, as the buffer is never freed. However, I do not understand how to actually free this buffer. I have tried av_free(), av_freep(), av_buffer_unref() in different orders, but have either gotten no effect at all, or an immediate exit of ffmpeg, without exception an exception being thrown.

To add insult to injury, because the buffer is owned by the ffmpeg dll and not the C# process, the performance profiler is blind to this memory leak, reporting an unchanging heap size. enter image description here How can I properly free this buffer?

FrostKiwi
  • 741
  • 1
  • 6
  • 16

0 Answers0