Mediasoup Recording switching video streams dynamically

Hi Everyone,

I able to record the streams of each participant in the video call. But while recording when the user stops the video, the latest user stream got attached throughout the recording.

Is there is any way to replace a static image when video stream is not available and as soon as the video stream is available it should replace the static image.

Example:
When there is no video stream → it should use static image
when there is video stream → it should use respective video stream.

My ffmpeg command for recording

ffmpeg -nostdin -protocol_whitelist file,rtp,udp -fflags +genpts -i input-vp8.sdp -map 0:a:0 -c:a copy -map 0:v:0 -c:v copy -f webm -flags +global_header -y output.webm

input-vp8.sdp file

file v=0
o=- 0 0 IN IP4 127.0.0.1
s=-
c=IN IP4 127.0.0.1
t=0 0
m=audio 5004 RTP/AVPF 111
a=rtcp:5005
a=rtpmap:111 opus/48000/2
a=fmtp:111 minptime=10;useinbandfec=1
m=video 5006 RTP/AVPF 96
a=rtcp:5007
a=rtpmap:96 VP8/90000

I could not find any documentation or links to do this. Kindly guide me on this. Thanks for help in advance.

For achieving the behavior you described, you’ll need to implement a custom strategy to dynamically switch between a static image and a video stream based on availability.

One approach you could consider is post-processing and stitching your media together using ffmpeg after the recording is complete. During post-processing, you can detect periods where the video stream is not available and replace those segments with a static image. When the video stream becomes available again, you can seamlessly switch back to the respective video stream.

This custom strategy would involve analyzing the recorded media, identifying the segments where the video stream is missing, and replacing those segments with the static image before stitching everything together.

Additionally, MediaSFU provides support for advanced Mediasoup recording and recomposition. It’s worth noting the complexity of achieving a stable, seekable and artefact-free video. Also, consider the dynamic nature of meeting rooms and the need to adjust for changes in positions and participants over time. MediaSFU offers conference recording support in case you would need one. You can learn more about our recording capabilities at mediasfu.com.