janoglezcampos / gstreamerchromebridge Goto Github PK
View Code? Open in Web Editor NEWNodeJs app that allows streaming from gstreamer to html5 on chrome.
NodeJs app that allows streaming from gstreamer to html5 on chrome.
Hi this looks great
Have tried to get it working
On the Auto Bridge am getting a pipeline syntax error for some reason
And on the initial Bridge, I get a Listen error. Am a little confused as you are attempting to listen on 8081 and also expect streamer to listen on the same port?
how to add http headers to load the video in Chrome. I had follow your way and run success in Firefox but fail in Chrome ๏ผ
Hey!
Thank you for this nice work, I was able to display a Camera Feed in my Webapp with the tcpBridgeAutoPipeline script.
Am I correct about the functionality that each time a Client issues a GET request it spawns a new gstreamer child process?
Is there any way to transmit the same gstreamer source to multiple clients at the same time with this?
Hi there,
Thanks for posting the solutions. I ran a server with tcpBridgeAutoPipeline.js on a Raspberry Pi. Since I didn't have a camera, I changed the CLI pipeline to gst-launch-1.0 -v filesrc location = bigbuck.mp4 ! decodebin ! x264enc ! rtph264pay ! udpsink host=localhost port=8081
and changed 'Content-Type': 'video/mp4'
Then I got an error - Error: listen EADDRINUSE: address already in use :::8081
I tried changing to other port and checked whether port was in use sudo lsof -i -P -n
to make sure was not in use. But still getting the same error message. I think the issue is on the server itself not on the script you provided, but I can't figure out and am new to gstreamer cli pipeline and not sure how tcp server works with http server at the same time.
Could you please take a look and give me some insights? Appreciate your help.
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/mp4',
});
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 =
['-v', 'filesrc', 'location=bigbuck.mp4',
'!', 'decodebin',
'!', 'x264enc',
'!', 'rtph264pay',
'!', 'udpsink', 'host=localhost',
'port=' + tcpServer.address().port];
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);
});
Error message:
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
}
package.json
{
"name": "gstreamer",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "nodemon index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1",
"nodemon": "^2.0.5"
}
}
pi@raspberrypi:~ $ lsof -i tcp:8081
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 7827 pi 23u IPv6 118623 0t0 TCP *:tproxy (LISTEN)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.