Giter Site home page Giter Site logo

Comments (3)

janoglezcampos avatar janoglezcampos commented on August 31, 2024

Hello, I am quite bussy today, so tomorrow I will check a little bit more, but after a quick review of your code, the first thing I see is that you are using and udpsink on the pipeline. Also, you shouldnt need to decode the file, i think chrome accepts mp4.

Try:
var args =
['filesrc', 'location=bigbuck.mp4',
'!', 'queue',
'!', 'm.', 'oggmux', 'name=m',
'!', 'queue',
'!', 'tcpclientsink', 'host=localhost',
'port=' + tcpServer.address().port];

If mp4 is not accepted:
var args =
['filesrc', 'location=bigbuck.mp4',
'!', 'decodebin',
'!', 'video/x-raw,framerate=30/1,width=320,height=240',
'!', 'videoconvert',
'!', 'queue',
'!', 'theoraenc',
'!', 'queue',
'!', 'm.', 'oggmux', 'name=m',
'!', 'queue',
'!', 'tcpclientsink', 'host=localhost',
'port=' + tcpServer.address().port];

The idea behind this "project" is:
Open an http server on port 8080, a tcp server on port 8081, when its open, start a pipeline that sends the frames to nodejs on that port, then resend the tcp server writes the frame with the headers to the http server on port 8080.

Gstreamer (just the frames) -> tcp server (8081) (frames + headers)-> http server (8080)

As I said, let me a day and I will come with more info.

from gstreamerchromebridge.

whypam avatar whypam commented on August 31, 2024

Hello, thanks for your advice and replying me in your tight schedule. I tried both args and got different error messages. Thanks again.

For the first one (shorter one):

pi@raspberrypi:~/gstreamer-server $ npm start

> [email protected] start /home/pi/gstreamer-server
> nodemon index.js

[nodemon] 2.0.5
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node index.js`
consol log tcpServer port: 8081

** (gst-launch-1.0:2302): CRITICAL **: 11:12:08.654: gst_ogg_stream_setup_map_from_caps: assertion 'caps != NULL' failed

Error: listen EADDRINUSE: address already in use :::8081
    at Server.setupListenHandle [as _listen2] (net.js:1331:16)
    at listenInCluster (net.js:1379:12)
    at Server.listen (net.js:1465:7)
    at /home/pi/gstreamer-server/index.js:30:15
    at Layer.handle [as handle_request] (/home/pi/gstreamer-server/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/pi/gstreamer-server/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/home/pi/gstreamer-server/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/home/pi/gstreamer-server/node_modules/express/lib/router/layer.js:95:5)
    at /home/pi/gstreamer-server/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/home/pi/gstreamer-server/node_modules/express/lib/router/index.js:335:12) {
  code: 'EADDRINUSE',
  errno: -98,
  syscall: 'listen',
  address: '::',
  port: 8081
}

For the second one (longer one):

pi@raspberrypi:~/gstreamer-server $ npm start

> [email protected] start /home/pi/gstreamer-server
> nodemon index.js

[nodemon] 2.0.5
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node index.js`
consol log tcpServer port: 8081
ERROR: from element /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstQTDemux:qtdemux0: Internal data stream error.
Additional debug info:
qtdemux.c(6073): gst_qtdemux_loop (): /GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstQTDemux:qtdemux0:
streaming stopped, reason not-negotiated (-4)
ERROR: pipeline doesn't want to preroll.

Error: listen EADDRINUSE: address already in use :::8081
    at Server.setupListenHandle [as _listen2] (net.js:1331:16)
    at listenInCluster (net.js:1379:12)
    at Server.listen (net.js:1465:7)
    at /home/pi/gstreamer-server/index.js:30:15
    at Layer.handle [as handle_request] (/home/pi/gstreamer-server/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/pi/gstreamer-server/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/home/pi/gstreamer-server/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/home/pi/gstreamer-server/node_modules/express/lib/router/layer.js:95:5)
    at /home/pi/gstreamer-server/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/home/pi/gstreamer-server/node_modules/express/lib/router/index.js:335:12) {
  code: 'EADDRINUSE',
  errno: -98,
  syscall: 'listen',
  address: '::',
  port: 8081
}

from gstreamerchromebridge.

whypam avatar whypam commented on August 31, 2024

Hello, hope you’re well. I figured the Error: listen EADDRINUSE: address already in use was due to the browser was somehow refreshed twice.

Now, I set up a Raspberry Pi camera and ran these CLI pipelines:
On RPi (server)
$ gst-launch-1.0 -v v4l2src device=/dev/video0 num-buffers=-1 ! video/x-raw,width=640,height=480, framerate=30/1 ! videoconvert ! jpegenc ! tcpserversink  host=192.168.xxx.xx port=5000

On Mac (client)
$ gst-launch-1.0 tcpclientsrc host=192.168.xxx.xx port=5000 ! jpegdec ! videoconvert ! autovideosink

These pipelines work well and start OpenGL renderer to display the camera stream.

I want to display the camera streaming on a browser. So I adapted your tcpBridgeAutoPipeline.js and replaced autovideosink to tcpclientsink and changed 'Content-Type': 'video/webm'. I got no error message but got a black blank video display, no camera streaming content.

Could you please take a look and advise anything I’m missing from the pipeline? Thanks again for your help.

On RPi, index.js

var express = require('express');
var http = require('http');
var net = require('net');
var child = require('child_process');

var expressApp = express();
var httpServer = http.createServer(expressApp);

expressApp.get('/', function (req, res) {
    var date = new Date();

    res.writeHead(200, {
        'Date': date.toUTCString(),
        'Connection': 'close',
        'Cache-Control': 'private',
        'Content-Type': 'video/webm',
    });

    var tcpServer = net.createServer(function (socket) {
        socket.on('data', function (data) {
            res.write(data);
        });
        socket.on('close', function (had_error) {
            res.end();
        });
    });

    tcpServer.maxConnections = 1;

    tcpServer.listen(8081, function () {
        var cmd = 'gst-launch-1.0';
        var args =
            ['tcpclientsrc', 'host=192.168.xxx.xx', 'port=5000'
                '!', 'jpegdec',
                '!', 'videoconvert',
                '!', 'tcpclientsink', 'host=192.168.xxx.xx',
                'port=8081'];

        var gstMuxer = child.spawn(cmd, args);

        gstMuxer.stderr.on('data', onSpawnError);
        gstMuxer.on('exit', onSpawnExit);

        res.connection.on('close', function () {
            gstMuxer.kill();
        });

    });
});

httpServer.listen(8080);

function onSpawnError(data) {
    console.log(data.toString());
}

function onSpawnExit(code) {
    if (code != null) {
        console.log('GStreamer error, exit code ' + code);
    }
}

process.on('uncaughtException', function (err) {
    console.log(err);
});

On Mac, index.html

<video width=”650” controls muted=”muted” autoplay>
	<source src=http://192.168.xxx.xx:8080 /> 
</video>

To start streaming, I did these steps:

  1. Ran this pipeline on RPi:
    $ gst-launch-1.0 -v v4l2src device=/dev/video0 num-buffers=-1 ! video/x-raw,width=640,height=480, framerate=30/1 ! videoconvert ! jpegenc ! tcpserversink  host=192.168.xxx.xx port=5000

  2. Started index.js on RPi

  3. Started index.html on Mac (client)

Could you please take a look? Appreciate your help.

from gstreamerchromebridge.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.