2020年12月22日星期二

Possible Memory leak in FFMPEGAutogen Example

I'm using the https://github.com/Ruslan-B/FFmpeg.AutoGen library to connect to an rtsp camera stream and save the frames as png images.

Testing with the FFMPEG.Autogen's example project present in the Github repository with no changes I've noticed that the memory usuage seems to constantly grow in infinitely. I've made sure to dispose of all bitmaps, pointers etc after use but am unable to pinpoint the source of the issue.

It seems to be coming from their VideoStreamDecoder.TryDecodeNextFrame method as shown below:

public bool TryDecodeNextFrame(out AVFrame frame)          {              ffmpeg.av_frame_unref(_pFrame);              ffmpeg.av_frame_unref(_receivedFrame);              int error;              do              {                  try                  {                      do                      {                          error = ffmpeg.av_read_frame(_pFormatContext, _pPacket);                          if (error == ffmpeg.AVERROR_EOF)                          {                              frame = *_pFrame;                              return false;                          }                          else if(error < 0)                          {                          }                            error.ThrowExceptionIfError();                      } while (_pPacket->stream_index != _streamIndex);                        ffmpeg.avcodec_send_packet(_pCodecContext, _pPacket).ThrowExceptionIfError();                  }                  finally                  {                      ffmpeg.av_packet_unref(_pPacket);                  }                    error = ffmpeg.avcodec_receive_frame(_pCodecContext, _pFrame);              } while (error == ffmpeg.AVERROR(ffmpeg.EAGAIN));              error.ThrowExceptionIfError();              if (_pCodecContext->hw_device_ctx != null)              {                  ffmpeg.av_hwframe_transfer_data(_receivedFrame, _pFrame, 0).ThrowExceptionIfError();                  frame = *_receivedFrame;              }              else              {                  frame = *_pFrame;              }              return true;          }  
https://stackoverflow.com/questions/65407831/possible-memory-leak-in-ffmpegautogen-example December 22, 2020 at 07:22PM

没有评论:

发表评论