Samur Araújo
Samur Araújo

Reputation: 29

How to stream a video file with WebRTC?

I would like to stream a video file selected through the input file to a peer using WebRTC.

Details: I would like to use the addstream method instead of the data channel for this purpose.

In my code I generated a blob from the file, like this:

localVideo.src =  window.URL.createObjectURL(file);

It plays correctly locally.

But I also would like to stream this video to a peer.

Then I try to generate a MediaStream from the blob to use it as parameter of the method addstream.

None of these methods works on chrome Version 37.0.2062.120 (64-bit)

localVideo.captureStream

localVideo.createMediaElementSource

localVideo.captureStreamUntilEnded

localVideo.stream

localVideo.srcObject

localStream.mozCaptureStreamUntilEnded

Anyone know how to do it?

Upvotes: 3

Views: 3452

Answers (1)

Benjamin Trent
Benjamin Trent

Reputation: 7566

You have two options:

  1. Use a data connection and push each frame and then play each frame on the other side.
  2. If you are in firefox, you could try mozCaptureStreamUntilEnded

There is no implementation in Chrome that is built for streaming a video file as a MediaStream as of yet.

Muaz Kahn WebRTC Experiments has a small script that should simplify this for you. It takes into account both options.

Upvotes: 1

Related Questions