Best way to publish a video with audio?

Hi there, I responded to another thread regarding this topic but it’s quite old so I thought a new one might be in order.

Essentially I’m wondering what are the best options for publishing a pre-recorded video to a session. So if I have a URL for example, https://example.com/myvid.mp4, what is the best way to display that video in a synchronized manner to all my session subscribers?

Option 1:
The older thread suggested using OpenVidu’s signal() method to essentially just play the downloaded video at the correct time. Essentially, the “admin” signals the pre-recorded video to start, all subscribers receive that signal, and the video starts playing at the same time for everyone. This method works great and the quality is fantastic obviously as it bypasses the OpenVidu server almost entirely but the major drawback as far as I can see is that you can’t take advantage of OpenVidu’s recording module.

Or you could, but the session recording would be missing the segment with the pre-recorded video. Any solutions to this particular problem would be amazing.

Option 2:
Another option I recently spent a lot of hours on was trying to use HTMLMediaElement.captureStream() to get the video and audio tracks from a video element (with the src set to my video URL) and then passing those tracks to my publisher.

Unfortunately, it seems like captureStream() is still a very buggy API on both Chrome and Firefox. I could get the video to appear for subscribers (although Chrome has some issues that require workarounds) but it seems like audio just doesn’t work for some reason (even though it was working on previous versions of both Chrome and Firefox apparently).

Option 3:
Another option I saw was doing a screen share (using mediaDevices.getDisplayMedia() which offers audio sharing capabilities depending on the browser/operating system) and then playing the video in the tab/window that is shared. However in my tests of this, the video/audio quality was pretty poor.

Option 4:
In the previous thread, I also the suggestion of using the KurentoPlayer API directly somehow to do this but I’m not even sure where to begin with that to be honest. Any suggestions on this would also be appreciated.

Thanks!

Option 5:

Launching a browser like Google Chrome and setting the video file as video/audio input. You can launch it manually from your local terminal with the specific flags or you can automatically launch it with selenium-webdriver.

The flags you will need:

--use-fake-ui-for-media-stream,
--use-fake-device-for-media-stream,
--allow-file-access-from-files,
--use-file-for-fake-audio-capture=your-audio-file-path.wav,
--use-file-for-fake-video-capture=your-video-file-path.y4m

We are using this approach for load-testing. If you’re interested you can check this class openvidu-loadtest/real-browser.service.ts at master · OpenVidu/openvidu-loadtest · GitHub

I also answered in the old thread: Integration of pre-recorded video with RTC - #7 by pabloFuente

One more option:

Option 6: Simulate an “virtual participant” with a node application and KMS. We have using that approach for load testing: openvidu-loadtest/emulate-browser.service.ts at deb1e06952add0528d710325dea665a59bcc09ff · OpenVidu/openvidu-loadtest · GitHub

Thank you for all the responses! I’m not sure I fully understand options 5 and 6 just yet but I will look into the provided links.

For now, me and my team settled on offering our users two choices for sharing videos.

The first choice will use option 1. We will make it clear to our users that the session recording will not include the pre-recorded video segment they share. Perhaps down the road we will add some functionality that manually merges/splice in the pre-recorded video the user shared during the session with OpenVidu’s video recording of the session.

The second choice will use option 3, mediaDevices.getDisplayMedia() with its built-in audio sharing capabilities. For this choice, we’ll just explain to users that picture/sound quality will be lower but the benefit is that it will show up in recordings properly.

Thanks!