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:
- set the video element’s src to the video file
- wait for the video element’s onloadeddata event
- upon the event use the video element’s captureStream API
- 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='192.168.166.178', port=3000): Max retries exceeded with url: /rooms/vsrqncgn (Caused by SSLError(SSLCertVerificationError("hostname '192.168.166.178' doesn't match 'fs'"))) while doing GET request to URL: https://192.168.166.178:3000/rooms/vsrqncgn
to avoid errors about self-signed certificates.
Then, when I run this script:
max@msi:~/Desktop$ SERVER_URL=https://192.168.166.178:3000 ROOM_ID=vsrqncgn MEDIA_FILE=./hello.mp4 ./ffmpeg.sh >>> verifying that room 'vsrqncgn' exists... >>> creating Broadcaster... >>> creating mediasoup PlainTransport for producing audio... ....skipped....
it fails on
>>> creating mediasoup PlainTransport for producing audio... 'res' variable is filled with this: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Error</title> </head> <body> <pre>Cannot POST /rooms/vsrqncgn/broadcasters/DhPxwLp5OtnRf55J4E9tl7Q95MRhR1tX/transports</pre> </body> </html>
It doesn’t mention self-signed certificates as a problem. Did anyone else see this problem?