Skip to content

Instantly share code, notes, and snippets.

@stpettersens
Created March 20, 2016 18:28
Show Gist options
  • Save stpettersens/9c0c37d3e53b67de977b to your computer and use it in GitHub Desktop.
Save stpettersens/9c0c37d3e53b67de977b to your computer and use it in GitHub Desktop.
Server which listens for PCM stream and outputs a Ogg Vorbis file (doesn't work yet).
'use strict';
const ogg = require('ogg');
const vorbis = require('vorbis');
const BinaryServer = require('binaryjs').BinaryServer;
let server = BinaryServer({port: 8080});
let oe = new ogg.Encoder();
let ve = new vorbis.Encoder();
let out = null;
server.on('connection', function(client) {
client.on('stream', function(stream, meta) {
stream.pipe(ve);
stream.on('end', function() {
ve.pipe(oe.stream());
oe.pipe(process.stdout);
});
});
client.on('close', function() {
if(out != null) {
ve.pipe(oe.stream());
oe.pipe(process.stdout);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment