Created
March 20, 2016 18:28
-
-
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).
This file contains hidden or 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
'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