Updated May 04, 2017 : The captureStream API captureStream now supported in both Chrome and Firefox.
var stream_from_WebM_or_Mp4_File = videoTag.captureStream(); var stream_from_Canvas2D = canvasTag.captureStream(25);
Parameter "25" is requested at a frame rate.
Now you can share the resulting stream using the RTCPeerConnection API or record using the MediaRecorder API.
Please check a similar answer: fooobar.com/questions/962236 / ...
There are two possibilities:
1) captureStreamUntilEnded / Demo
It is supported only in Firefox as " mozCaptureStreamUntilEnded ".
2) MediaSource API Demo
MediaSource APIs are supported in both Chrome and Firefox; however, this is not a real-time media stream.
What you can do is read pieces of files; Share them with other users using any transfer gateway, such as WebSockets, socket.io, or WebRTC data channels then use the MediaSource API to play these fragments as soon as possible, rather than waiting for the entire file to be shared.
Remember that WebRTC implementations in both chromium and gecko currently support a single, but "live" source of multimedia; this means that you cannot use the captured stream from pre-recorded media as a live source for multimedia . Also, you cannot use the fake WebAudio stream as a LIVE multimedia source.
The following code will NOT work in Firefox:
preRecordedMediaStream = preRecordedMedia.mozCaptureStreamUntilEnded(); peer.addStream(preRecordedMediaStream);
You can check out the demo here .
Updated at 13:06 - Sunday, July 27, 2014 (UTC)
You can record a pre-recorded mp3 / ogg file using the FileReader / WebAudio API and share it as a LIVE audio source with WebRTC peer-to-peer connections, as I did in this demo / source code .