libcamera-vid -t 0 --width 1920 --height 1080 --inline --listen -o tcp://0.0.0.0:8000
websockify 0.0.0.0:8001 0.0.0.0:8000
/rpicam/index.html
as following<head>
<meta name="color-scheme" content="dark">
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jmuxer@2.0.4/dist/jmuxer.min.js"></script>
<style>
body{
margin: 0;
}
</style>
</head>
<body>
<div id="container" style="width: 100%; margin: 0 auto;">
<div class="vsc-controller"></div>
<video width="100%" autoplay muted id="player"></video>
</div>
<script>
function parse(data) {
var input = new Uint8Array(data),
video = input;
return {
video: video,
};
}
window.onload = function () {
var socketURL = document.location.href.replace('http', 'ws')+'ws/';
var jmuxer = new JMuxer({
node: 'player',
mode: 'video',
flushingTime: 0,
fps: 30,
debug: false
});
var ws = new WebSocket(socketURL);
ws.binaryType = 'arraybuffer';
ws.addEventListener('message', function (event) {
var data = parse(event.data);
jmuxer.feed(data);
});
}
</script>
</body>
/rpicam/
to static file directory, and /rpicam/ws/
to 0.0.0.0:8001
. Typical configuration of the later is as following.location /rpicam/ws/ {
proxy_redirect off;
proxy_pass http://0.0.0.0:8001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
For now I am happy with the result, but a dedicated backend would be optimal/necessary to solve these issues.