Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get media stream object form HTML5 video element in javascript

Tags:

html

video

webrtc

all I'm in peer to peer communication using webRTC , we have media stream object from the getUserMedia which is given as input stream to peerconnection. Here I need video stream from the selected video file from the local drive which is playing using Video element of HTML5. Is it possible to create mediastream object from the video tag?

thanks, suri

like image 646
surbob Avatar asked Aug 27 '13 06:08

surbob


1 Answers

For now you can't add a media stream from a video tag, but it should be possible in the future, as it is explained on MDN

MediaStream objects have a single input and a single output. A MediaStream object generated by getUserMedia() is called local, and has as its source input one of the user's cameras or microphones. A non-local MediaStream may be representing to a media element, like or , a stream originating over the network, and obtained via the WebRTC PeerConnection API, or a stream created using the Web Audio API MediaStreamAudioSourceNode.

But you can use Media Source Extensions API to do what yo want : you have to put the local file into a stream and append in in a MediaSource object. You can learn more about MSE here : http://www.w3.org/TR/media-source/

And you can find a demo and source of the method above here

like image 65
rodincave Avatar answered Sep 28 '22 16:09

rodincave