Hello,
We wish to implementing our own server side recording for P2P calls. We can't use twilio's recording capabilities due to some regulatory compliances.
We tried using the js sdk directly in node but since node does not have native support for WebRTC (AFAIK) we did not suceed. As soon as we tried to connect, we got an undefined error for some WebRTC global that twilio-video-js expected. We tried connect(token, {audio:false, video:false} without sucess.
One solution we think would work is use headless Chrome, join as a participant and record received remote streams. But this does not seem like a very efficient solution.
Our understanding of the inner workings of WebRTC is very limited. What other options are available to us?
Hi @AkshayBarad ,
Thank you for writing to us with your question. You can record audio and video Tracks on the client using the Track's mediaStreamTrack property in conjunction MediaRecorder. You can then send the recorded data in chunks to your recording server using fetch.
Please let us know if this works for you.
Thanks,
Manjesh Malavalli
JSDK Team
@AkshayBarad's colleague here.
Thank you @manjeshbhargav for the response.
In our application, we support users connecting from web and mobile (iOS + Android). There is no guarantee that there will be a web user connected for a given session we wish to record. Therefore we can't rely on the method you suggested.
We did manage to use the mediaStreamTrack property of participant tracks in conjunction MediaRecorder api on the web to achieve recording Twilio participant streams. That is why the only accessible solution we could see was to spawn headless chrome instances and connect them to rooms we need to record.
Based on your understanding of the mechanics of twilio and webrtc, can you suggest alternative means of achieving this?
We are happy to invest time into learning the innards of WebRTC and using other server side languages that have WebRTC libraries. The question then is how do we go down to the WebRTC abstraction level while using the twilio service. Any insights you could share would be most appreciated.
Meanwhile, we'll do our own research into this and post our findings here.
Regards
Jinal
@jinalskothari ,
Thanks for giving more context about your use case. I will bring in @ceaglest and @idelgado , our engineers from the iOS and Android SDK team.
Chris, Inaqui, can you provide some insight into how recording of media on the client side on mobile devices can be achieved? Is it straightforward or are there complexities involved?
Thanks,
Manjesh Malavalli
JSDK Team
We don't support this use case on Android. We may in the future but it is not a specific item on our roadmap. It is pretty complex to do so. It would require capturing audio and video from multiple tracks while managing to ensure that the data is recorded in such a way that syncing is still preserved.
Recording is supported via our iOS SDK, but this is not a terribly easy task. You can record each track separately, using TVIAudioSink and TVIVideoRenderer for audio and video respectively. Samples for remote Tracks are raised at presentation time, so synchronization is going to be best effort. You will be receiving decoded samples, which you probably want to compress again before saving to disk and then going over the network.
TVIAudioSinkExample: https://github.com/twilio/video-quickstart-swift/tree/master/AudioSinkExample
WIP - TVIVideoRenderer recorder: https://github.com/twilio/video-quickstart-swift/pull/286
We don't expose some of the file recording / muxed (.webm) recording support which is present in WebRTC.
Thank you, @manjeshbhargav, @idelgado, @ceaglest.
So far, headless chrome on server based solution seems to be the most reliable. We will experiment with that and share with the community when we have some success.
Kindly close this issue.
Thank you.
@AkshayBarad and @jinalskothari,
Please take a look at https://github.com/twilio/twilio-video.js-recording-bot — this may get you a head start on the headless Chrome route. This isn't a supported solution, and you will not get as good performance as in Group Rooms, but if you want to try it out you can.
Best,
Mark
@markandrus, this is brilliant! It gives us a huge headstart towards our end goal. Thanks to Twilio team for writing it and many thanks to you for pointing it out.
Promise to send enhancement PRs ;)
You're welcome, and good luck :-)
I implemented my own solution which can record Twilio rooms in .webm format and stream the recording straight to S3 storage.
Most helpful comment
I implemented my own solution which can record Twilio rooms in
.webmformat and stream the recording straight to S3 storage.https://github.com/ted-piotrowski/puppeteer-camera