本文介绍了解决方案从DeckLink卡到浏览器的流( - ; TCP MJPEG - &GT;&GT的Gstreamer?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我需要从DeckLink卡到浏览器实时流。我还必须能够与一个非常贫困的网络链路(128kbits / s的...)这样做,所以我需要能够在一个非常低的FPS流(1 FPS是罚款)和非常低的图像质量。I need to live stream from a decklink card to a browser. I also must be able to do it with a very poor network link (128kbits/s...), so I need to be able to stream at a very low fps (1 fps is fine) and a very low image quality.目前我使用的GStreamer获得从卡的视频,反式code它MJPEG,以及TCP流吧。这部分是完美的工作,但现在我要管这个TCP流与HTTP流。At the moment I'm using GStreamer to get the video from the card, to transcode it to MJPEG, and to stream it with TCP. This part is perfectly working, but now I need to tube this tcp stream to an HTTP stream.我可以VLC做到这一点,它在正常的帧率效果很好(15帧 - > 0.5秒的延迟)。但是,如果我喂VLC用1 FPS流,它引入了大约11秒,这是不是罚款,我的目的的等待时间。I can do this with VLC and it works well at a "normal" framerate (15 fps -> 0.5 sec of latency). But if I feed VLC with a 1 fps stream, it introduces a latency of around 11 sec, which is not fine for my purpose.所以,现在我正在寻找替代VLC的。我看到3种方式这样做的:So, now I'm looking for a replacement of VLC. I see 3 ways of doing it : 使用GStreamer的的souphttpclientsink流与HTTP流媒体服务器use the GStreamer's souphttpclientsink to stream to an HTTP streaming server创建自己的HTTP服务器,至极监听TCP流,并将它重新流至客户端。我试着在Python和Node.js的,它是近的工作,但我会preFER有像previous一个更强大的解决方案有一个create my own HTTP server, wich listens to the TCP stream and re-streams it to the clients. I tried in Python and Node.js and it is nearly working, but I would prefer to have a more robust solution like the previous one更​​棘手:创建自己的HTTP服务器,监听TCP流和数据使用WebSockets发送到客户端,然后去code再流客户端...even more tricky : create my own HTTP server, listen to the TCP stream and send the data to the client with websockets, and then decode then stream client side...然后,我的问题是: 你知道哪些HTTP流媒体服务器(如果可能免费)与souphttpclientsink(或tcpclientsink)使用吗?do you know which HTTP streaming servers (if possible free) are usable with souphttpclientsink (or tcpclientsink) ?你有什么其他的想法后流的GStreamer流浏览器?do you have any other idea to stream a GStreamer stream to a browser ?感谢您阅读!推荐答案我得到的解决方案的WebSockets工作,由于节点Dicer酶模块(并感谢MSCDEX投放this帖子)。I got the websockets solution working, thanks to the node Dicer module (and thanks to mscdex on this post ).因此​​,这里是我做过什么:So here is what I did : 1°)流进行我的DeckLink卡通过TCP视频蒙山的GStreamer:1°) Stream my Decklink card's video over TCP whith GStreamer :gst-launch -v decklinksrc mode=10 connection=0 ! deinterlace ! videorate ! videoscale ! video/x-raw-yuv, framerate=1/5, width=256, height=144 ! jpegenc quality=20 ! multipartmux boundary="--videoboundary" ! tcpserversink host=<TCP src stream IP address> port=<TCP src stream port> 2°)听此流与节点,并通过发送socket.io每张图片:2°) Listen to this stream with Node and send each image via socket.io :// ------------------------------------------------// Constants :// ------------------------------------------------var srcHost = "<TCP src stream IP address>";var srcPort = <TCP src stream port>var srcBoundary = "--videoboundary";var destHost = "<dest IP address>";var destPort = <dest port>;// ------------------------------------------------// ------------------------------------------------// ------------------------------------------------// ------------------------------------------------// Includes :// ------------------------------------------------var Http = require('http');var Net = require('net');var Dicer = require('dicer');var SocketIO = require('socket.io');// ------------------------------------------------// ------------------------------------------------// ------------------------------------------------// ------------------------------------------------// TCP socket :// ------------------------------------------------var socket = Net.Socket();socket.connect(srcPort, srcHost, function() { // Init socket IO : var io = SocketIO.listen(Http.createServer().listen(destPort, destHost), { log: false }); // Init Dicer : var dicer = new Dicer({ boundary: srcBoundary }); dicer.on('part', function(part) { var frameEncoded = ''; part.setEncoding('base64'); part.on('header', function(header) { }); part.on('data', function(data) { frameEncoded += data; }); part.on('end', function() { io.sockets.emit('image', frameEncoded); }); }); // Handle streams closing : dicer.on('finish', function() { console.log('Dicer stream finished'); }); socket.on('close', function() { console.log('TCP socket closed'); }); // Pipe : socket.pipe(dicer);});// ------------------------------------------------// ------------------------------------------------// ------------------------------------------------ 3°)听客户端上的WebSocket:3°) Listen to the websocket on the client :<html> <head> <script src="jquery-1.9.1.js"></script> <script src="socket.io-client/socket.io.min.js"></script> <script> var socket = io.connect('http://<dest IP address>:<dest port>'); socket.on('image', function (data) { $("#video").attr("src", "data:image/jpeg;base64," + data.toString("base64") ); }); </script> </head> <body> <img id="video" style="display:block; width:400px; height:auto;" src="" /> </body></html>如果我获得工作的其他解决方案(但我可以用这个去)我会更新这个帖子。I will update this post if I get other solutions working (but I may go with this one). 这篇关于解决方案从DeckLink卡到浏览器的流( - ; TCP MJPEG - &GT;&GT的Gstreamer?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-23 02:19
查看更多