How to stream from local file?

I need help for stream from local file. I read the documentation of the mediasoup client but haven’t found the corresponding api. Is there a way to switch files from mediastream or any way to stream local files?

You can use external tool like FFmpeg or GStreamer, create plain transport in mediasoup and stream with plain RTP. Documentation actually mentions this a few times.

But my customer want use all in browser. FFMpeg or GStreamer is command line

Then stream from browser using WebRTC. I do not understand what the question is then. Also in this case it has nothing to do with mediasoup specifically.

1 Like

You can use the captureStream API

  1. upload video file to the HTML page
  2. attach the video file to a video element src
  3. use captureStream to create MediaStream
  4. create a producer using the above mediastream tracks

Wow, It looks like it will work. Thanks i will try this solution now

Hi bro, i try your solution but when producerTransport.on(‘produce’,…) i recevied a message “Error: Uncaught (in promise): Your stream has no audio tracks.”. Can you help me?

This is Mediastreamtrack get from audio tag

I added mediastreamtrack to a mediastream and add it to srcObject of other audio tag. And this audio tag has played the added track. It’s may be a bug off mediasoup??

How can be adding a second MediaStreamTrack to a MediaStream and just get audio of that track be a bug in mediasoup? Please, let’s not just assume that “everything is a bug in mediasoup”. You are using a MediaStream and a MediaStreamTrackobjects. Those are not “mediasoup API” but browser API.

BTW that’s the behaviour of a MediaStream when you add more than one audio MediaStreamTrack.

1 Like

Sorry because i use mediastreamtrack for another audio tag and it play correctly. I add only one track to Mediastream. Can you help me?

Can you help me by creating a captureStream () + mediasoup example? I try it but not work. In spite of your solution is basically.

Could do but it may take some time due to being busy.

1 Like

I know this is a waste of your time. If you make a example for captureStream() i really truly grateful you. Sr if my english so bad

@ethand91 Can you help me, I tried many ways but all failed

Sorry, Quang, don’t expect anyone here to do consultancy services for free. That’s not the purpose of this forum.

I’ll do it when I have free time, but I can’t give any estimations as to when it’ll be done.
If you can’t wait you will have to do it yourself.

1 Like

i tried to stream from an mp4 h264 file but when i try to consume it a blank video is displayed can’t figure out what is the problem.
these are my router capabilities
kind: “video”,
name: “H264”,
mimeType: “video/H264”,
clockRate: 90000,
parameters: {
“packetization-mode”: 1,
“profile-level-id”: “42e01f”
mp4 video codec info
its working fine on firefox

Please don’t hijack irrelevant threads with new questions over a year later