errory voice

This commit is contained in:
Amish Shah
2016-08-24 21:38:48 +01:00
parent 48444a5444
commit 8683f45816
20 changed files with 476 additions and 13 deletions

View File

@@ -0,0 +1,13 @@
class ConverterEngine {
constructor(player) {
this.player = player;
}
createConvertStream() {
return;
}
}
module.exports = ConverterEngine;

View File

@@ -0,0 +1 @@
exports.fetch = () => require('./FfmpegConverterEngine');

View File

@@ -0,0 +1,33 @@
const ConverterEngine = require('./ConverterEngine');
const ChildProcess = require('child_process');
function chooseCommand() {
for (const cmd of ['ffmpeg', 'avconv', './ffmpeg', './avconv']) {
if (!ChildProcess.spawnSync(cmd, ['-h']).error) {
return cmd;
}
}
}
class FfmpegConverterEngine extends ConverterEngine {
constructor(player) {
super(player);
this.command = chooseCommand();
}
createConvertStream() {
super.createConvertStream();
const encoder = ChildProcess.spawn(this.command, [
'-analyzeduration', '0',
'-loglevel', '0',
'-i', '-',
'-f', 's16le',
'-ar', '48000',
'-ss', '0',
'pipe:1',
], { stdio: ['pipe', 'pipe', 'ignore'] });
return encoder;
}
}
module.exports = FfmpegConverterEngine;