Skip to content

Instantly share code, notes, and snippets.

@tewarid
Last active April 9, 2018 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tewarid/c5c7eb1f42b41056ddc45d785257f3e0 to your computer and use it in GitHub Desktop.
Save tewarid/c5c7eb1f42b41056ddc45d785257f3e0 to your computer and use it in GitHub Desktop.
stream live webm over http
var cmd = 'gst-launch-1.0';
var args = ['autovideosrc',
'!', 'video/x-raw,framerate=30/1,width=320,height=240',
'!', 'videoconvert',
'!', 'queue', 'leaky=1',
'!', 'vp8enc',
'!', 'queue', 'leaky=1',
'!', 'm.', 'autoaudiosrc',
'!', 'queue', 'leaky=1',
'!', 'audioconvert',
'!', 'vorbisenc',
'!', 'queue', 'leaky=1',
'!', 'm.', 'webmmux', 'name=m', 'streamable=true',
'!', 'queue', 'leaky=1',
'!', 'tcpserversink', 'host=127.0.0.1', 'port=8001', 'sync-method=2', 'time-min=-1'];
var child = require('child_process');
var gstreamer = child.spawn(cmd, args, {stdio: 'inherit'});
gstreamer.on('exit', function (code) {
if (code != null) {
console.log('GStreamer error, exit code ' + code);
}
process.exit();
});
var express = require('express')
var app = express();
var http = require('http')
var httpServer = http.createServer(app);
app.get('/', function (req, res) {
var date = new Date();
res.writeHead(200, {
'Date': date.toUTCString(),
'Connection': 'close',
'Cache-Control': 'private',
'Content-Type': 'video/webm',
'Server': 'CustomStreamer/0.0.1',
});
var net = require('net');
var socket = net.connect(8001, function () {
socket.on('close', function (had_error) {
res.end();
});
socket.on('data', function (data) {
res.write(data);
});
});
socket.on('error', function (error) {
console.log(error);
});
});
httpServer.listen(9001);
@tewarid
Copy link
Author

tewarid commented Apr 8, 2018

Pipeline crashes after a while with GStreamer 1.10.2 on Windows 10 and macOS

(gst-launch-1.0:8888): GLib-GObject-WARNING **: gsignal.c:2635: instance '0000000003345D60' has no handler with id '17007'

Playback freezes with GStreamer 1.14.0 on Windows 10.0.17133.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment