Stream video instead of webcam

Hello everyone, I’m playing with mediasoup-demo and I’m wondering if I can replace webcam stream with a file on disk. Let’s say I have a video file and I want to show it in a video window, is this possible?

May I know why you have chosen mediasoup libraries topic category instead of mediasoup demo then? (I’m changing it now).

Yes, it’s possible.

It was autosuggested, there were no other categories in sight and I wasn’t aware of them. Thanks for fixing the category.

I looked through the demo source code and examples here and the change I should make to source code to stream a file from disk is not obvious to me, can you give me a hint or example?

This can be done via the below steps:

  1. set the video element’s src to the video file
  2. wait for the video element’s onloadeddata event
  3. upon the event use the video element’s captureStream API
  4. pass the stream to a mediasoup producer

I’ve done something similar a while back so the steps may need to be tweaked a bit, but it should help you get started.

Thank you very much for the response, I will try it. My final goal is actually streaming video(not from a file but a socket). This is how I tried to solve this problem, so far.
I found this script and decided to use to stream video into mediasoup-demo’s window:

When I run it as is, I get:

>>> verifying that room 'vsrqncgn' exists...

http: error: SSLError: HTTPSConnectionPool(host='', port=3000): Max retries exceeded with url: /rooms/vsrqncgn (Caused by SSLError(SSLCertVerificationError("hostname '' doesn't match 'fs'"))) while doing GET request to URL:

I replaced
HTTPIE_COMMAND=“http --check-status”
HTTPIE_COMMAND=“http --verify=no”
to avoid errors about self-signed certificates.

Then, when I run this script:

max@msi:~/Desktop$ SERVER_URL= ROOM_ID=vsrqncgn MEDIA_FILE=./hello.mp4 ./

>>> verifying that room 'vsrqncgn' exists...
>>> creating Broadcaster...
>>> creating mediasoup PlainTransport for producing audio...

it fails on

>>> creating mediasoup PlainTransport for producing audio...

'res' variable is filled with this:
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<pre>Cannot POST /rooms/vsrqncgn/broadcasters/DhPxwLp5OtnRf55J4E9tl7Q95MRhR1tX/transports</pre>

It doesn’t mention self-signed certificates as a problem. Did anyone else see this problem?