admin管理员组文章数量:1321241
I have this piece of code which takes input the the camera and displays it within the web browser window (works only if served from a web server, not directly by opening a file):
<html>
<body>
<video id="video" width="640" height="480" autoplay="true"></video>
<script>
var video = document.getElementById('video');
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices.getUserMedia({video: true}).then(function (stream) {
video.src = window.URL.createObjectURL(stream);
video.play();
});
}
</script>
</body>
</html>
I'd like to live-stream the video it to a URL (example: to "/publish/?password=" as in )
How do I code that?
Thanks!
I have this piece of code which takes input the the camera and displays it within the web browser window (works only if served from a web server, not directly by opening a file):
<html>
<body>
<video id="video" width="640" height="480" autoplay="true"></video>
<script>
var video = document.getElementById('video');
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices.getUserMedia({video: true}).then(function (stream) {
video.src = window.URL.createObjectURL(stream);
video.play();
});
}
</script>
</body>
</html>
I'd like to live-stream the video it to a URL (example: to "/publish/?password=" as in https://github./vbence/stream-m)
How do I code that?
Thanks!
Share Improve this question asked Feb 2, 2017 at 8:23 ikevin8meikevin8me 4,3137 gold badges46 silver badges86 bronze badges1 Answer
Reset to default 4The best practice approach, especially if you expect to have multiple clients viewing the video is to stream to a video streaming server and then have the video streaming server stream it to the individual clients.
Video streaming servers are available opensource or mercial and are quiet specialised with mechanisms to maximise device coverage and to handle different network conditions and device screen size/resolutions. rebuilding this type of functionality yourself would not be trivial.
Below is an example of the approach using Wowza a mercial streaming server (I have no affiliation to them):
More info here (from where the above picture was taken): https://www.wowza./products/capabilities/webrtc-streaming-software
An source example of streaming servers which will support similar approaches is GStreamer:
- https://gstreamer.freedesktop
Update
Some links with info on using the Janus server. This supports connections from WebRTC clients and includes a streaming plugin:
- https://github./meetecho/janus-gateway
- https://github./meetecho/janus-gateway/blob/master/plugins/janus_streaming.c
本文标签: How to publish a live video stream from HTML and JavaScriptStack Overflow
版权声明:本文标题:How to publish a live video stream from HTML and JavaScript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742097564a2420642.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论