c# – SIPSorcery WebRTC receive and save video stream to file

I created a project using SIPSorcery that receives stream (VP8 or H264 format) from WebRTC, and saves it to video file (and photo if needed). The problem is, I cannot think how to convert that received video frame:

peerConnection.OnVideoFrameReceived += SaveFrameToFullRecordingStream;

private void SaveFrameToFullRecordingStream(IPEndPoint arg1, uint arg2, byte[] frame, VideoFormat format)
    // Decode frame?

As per SIPSorcery documentation:
OnVideoFrameReceived event

What I struggle with is my lack of knowledge how to decode it to a valid byte array that can be appended to a stream and then saved to a .webm or .mp4 file.

I tried also doing this from video sink decoded frame event:

_videoSink.OnVideoSinkDecodedSample += VideoSink_OnVideoSinkDecodedSample;

It was also unsuccessful.
I do not know how to reconstruct frames and create full files from frames received by WebRTC.

Read more here: Source link