Last active
April 9, 2018 23:52
-
-
Save tewarid/c5c7eb1f42b41056ddc45d785257f3e0 to your computer and use it in GitHub Desktop.
stream live webm over http
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pipeline crashes after a while with GStreamer 1.10.2 on Windows 10 and macOS
Playback freezes with GStreamer 1.14.0 on Windows 10.0.17133.1.