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

all I'm messaging using webRTC, we have a media stream object from getUserMedia, which is provided as an input stream for peerconnection. Here I need a video stream from a selected video file from a local disk, which is played using an HTML5 video element. Is it possible to create a media object from a video tag?

thanks, Suri

+4
source share
1 answer

At the moment, you cannot add the media stream from the video tag , but this should be possible in the future, as explained on MDN

MediaStream objects have one input and one output. The MediaStream object generated by getUserMedia () is called local and has one of the user cameras or microphones as the initial input signal. A non-local MediaStream can represent a multimedia element, for example, a stream created over the network and received through the PeerConnection WebRTC API or a stream created using the Web Audio API MediaStreamAudioSourceNode.

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

And you can find the demo and method source above here

+2
source

Source: https://habr.com/ru/post/1499075/


All Articles