mumble-record/record.js

27 lines
913 B
JavaScript
Raw Normal View History

2020-03-19 14:14:26 +00:00
const mumble = require('mumble'),
fs = require('fs'),
lame = require('lame'),
options = {
key: fs.readFileSync(__dirname + '/key.pem'),
cert: fs.readFileSync(__dirname + '/cert.pem')
}
console.log('Connecting')
mumble.connect(process.argv[2] || 'mastodon.madrid', options, (error, connection) => {
if (error) { console.error(error) }
console.log('Connected')
connection.authenticate(process.argv[3] || 'record')
connection.on('initialized', () => {
2020-03-19 23:21:41 +00:00
chan = connection.channelByName(process.argv[4] || 'Root')
2020-03-19 14:14:26 +00:00
chan.join()
})
const encoder = new lame.Encoder({
channels: 1,
sampleRate: 48000,
bitDepth: 16,
bitRate: 128,
outSampleRate: 44100,
mode: lame.STEREO
})
connection.outputStream().pipe(encoder).pipe(fs.createWriteStream(__dirname + '/records/mumble-' + Date.now() + '.mp3'))
})