Solutions to stream from a decklink card to browsers (Gstreamer -> TCP MJPEG -> ?)

后端 未结 1 1438
遇见更好的自我
遇见更好的自我 2021-02-04 20:05

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

1条回答
  •  渐次进展
    2021-02-04 20:37

    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°) 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= port=
    

    2°) Listen to this stream with Node and send each image via socket.io :

    // ------------------------------------------------
    // Constants :
    // ------------------------------------------------
    
    var srcHost = "";
    var srcPort = 
    var srcBoundary = "--videoboundary";
    
    var destHost = "";
    var destPort = ;
    
    // ------------------------------------------------
    // ------------------------------------------------
    // ------------------------------------------------
    
    
    
    // ------------------------------------------------
    // 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°) Listen to the websocket on the client :

    
        
    
            
            
    
            
        
    
        
    
        
    
        
    
    

    I will update this post if I get other solutions working (but I may go with this one).

    0 讨论(0)
提交回复
热议问题