Streaming local mp4 file in openvidu-js

I am currently dealing with manipulating videoSource of openvidu-js. Since the default value of publisher.videosource is set ad undefined which is the webcam, I wanted to replace it with my local mp4 file. But as far as I understand, videosource element of the publisher is referring the capturing device not the file itself. I wanted to modify it below is the code.

when camera value gets in the vid, publisher.addVideoelement changes into undefined, else videosource changes to local 1.mp4 file. I assume the client code cannot find the video source

Hi, I think you won’t be able to inject a mp4 file in this way.
Why do you want do this? Do you need do this for testing purposes or what the reason?

just for curiosity. currently I’m studying about webRTC and I thought openVidu is a fine program

You can’t assign a mp4 file as videoSource of webRTC endpoint.

The simplest way to to that is launching a chrome browser (from terminal) with the following command:

google-chrome --use-fake-ui-for-media-stream --use-fake-device-for-media-stream --allow-file-access-from-files --use-file-for-fake-video-capture=video.y4m

For running it, you will need to convert your mp4 file to y4m.

1 Like

thank you for your the advice.