i-TechSoftware / RtspClientSharpCore

C# RTSP Client for .NET Core 3.0/.NET 5.0
MIT License
40 stars 15 forks source link

Unable to capture multiple RTSP camera #11

Open arunkmarhudrom opened 1 year ago

arunkmarhudrom commented 1 year ago

Throw error - System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'

i-TechSoftware commented 1 year ago

sorry, I no longer support this repository.

phil-kk commented 1 week ago

@arunkmarhudrom try replace TestRtspClient.FrameDecoder

public class FrameDecoder : IFrameDecoder { private readonly static ThreadLocal H264 = new (() => FFmpegVideoDecoder.CreateDecoder(FFmpegVideoCodecId.H264)); private readonly static ThreadLocal MJPEG = new (() => FFmpegVideoDecoder.CreateDecoder(FFmpegVideoCodecId.MJPEG));

    public FFmpegVideoDecoder GetDecoderForFrame(RawVideoFrame videoFrame)
    {
        if (videoFrame is RawJpegFrame)
            return MJPEG.Value;
        if (videoFrame is RawH264Frame)
            return H264.Value;
        return null;
}

public IDecodedVideoFrame TryDecode(RawVideoFrame rawVideoFrame)
{
  var decoder = GetDecoderForFrame(rawVideoFrame);
  return decoder.TryDecode(rawVideoFrame);
}

} }