我正在尝试使用websockets(确切地说是socket.io)和节点服务器将实时视频从我的rpi(任何linux机器)传输到我的笔记本电脑。以前有人这样做过,可以分享他们的设置吗?注意:我尝试了一堆剧照和流式传输,但它似乎是一个非常密集的任务,并且还会产生明显的延迟
答案 0 :(得分:0)
您可以使用ffmpeg
将视频流解码为hls
格式。
该解决方案在现实世界和显示视频之间有一点延迟(约3-10秒)。详见here(俄语)。
// index.html
<!DOCTYPE html>
<html>
<head>
<meta HTTP-EQUIV="Expires" CONTENT="0">
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
<meta http-equiv="Cache-Control" content="private">
<script src="https://cdn.jsdelivr.net/hls.js/latest/hls.min.js"></script>
</head>
<body>
<video id="video"></video>
<script>
if(!Hls.isSupported())
return console.error('HSL is not supported');
var video = document.getElementById('video');
var hls = new Hls();
hls.loadSource('index1.m3u8');
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function() {
video.play();
});
</script>
</body>
</html>
// ffmpeg example (I use rstp stream)
ffmpeg -rtsp_transport tcp -loglevel error -hwaccel auto -i rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k1.mov -ar 44100 -acodec aac -ac 1 -strict -2 -crf 18 -c:v copy -preset ultrafast -flags -global_header -fflags flush_packets -tune zerolatency -hls_time 1 -hls_list_size 3 -hls_wrap 4 -hls_flags delete_segments -start_number 0 index1.m3u8
// http server (you can use any other)
var http = require('http');
var fs = require('fs');
var static = require('node-static');
var file = new static.Server('.', {cache: false });
http.createServer(function(req, res) {
file.serve(req, res);
}).listen(1111);
console.log('Server running on 127.0.0.1:1111...');