Hi There,
I am currently recording media using ffmpeg and forwarding the RTP to ports, while this works, it is sometimes error prone (ports taken, launching of ffmpeg process, etc). Having migrated a whole system from Janus to MediaSoup, I am wondering if there is a way to dump the media packets flowing through mediasoup to a file, and then use a tool like ffmpeg to post process it and create a media file (be it .opus,.mp4,.webm).
Has anybody done this? I would be willing to sponsor this…
Mediasoup can definitely be used along side FFMPEG/GSTREAMER. I would suggest looking into some of the demos to see how it’s done.
I remember looking into this a while ago, and I think it should be possible. But I think it will require a lot of custom tooling.
Mediasoup has a DirectTransport API that will send RTP and RTPC packets directly to your node process where you can write them to disk. mediasoup :: API You’ll have to decide if this right for your architecture. The alternative would be to use a PlainTransport to some external process that is receiving UDP packets and writing them to disk.
For the post-processing, you’ll need to find some some way to extract the payloads and timestamps from the rtp/rtcp files and feed them into some muxer. Keep in mind, the packets may be out of order and/or missing.
The ffmpeg rtp demuxer is pretty tightly coupled with the networking stack, so I don’t think you can use it for the post-processing. You could probably write a custom ffmpeg demuxer to do this though. The internal ffmpeg C api is very extensible.
You mentioned problems such as “ports taken, launching of ffmpeg process”. These all seem like very fixable problems. And probably a lot easier than going down this road.
Sorry, I wish I had more concrete advice. I think this is a cool idea though. Please update us if you get it work.
Also worth considering is a client based on libmediasoupclient.
Thank you @copiltembel and @jbaudanza