Attempted better ffmpeg handling

This commit is contained in:
abalabahaha
2016-03-10 21:40:19 -08:00
parent b5c200901b
commit ef679e87c4
2 changed files with 50 additions and 6 deletions

View File

@@ -73,10 +73,18 @@ export default class AudioEncoder {
]);
stream.pipe(enc.stdin);
var ffmpegErrors = "";
enc.stdout.pipe(this.volume);
enc.stderr.on("data", (data) => {
reject(new Error("FFMPEG: " + new Buffer(data).toString().trim()));
ffmpegErrors += "\n" + new Buffer(data).toString().trim();
});
enc.once("exit", (code, signal) => {
if (code) {
reject(new Error("FFMPEG: " + ffmpegErrors));
}
})
this.volume.once("readable", () => {
resolve({
@@ -111,10 +119,17 @@ export default class AudioEncoder {
'pipe:1'
]);
var ffmpegErrors = "";
enc.stdout.pipe(this.volume);
enc.stderr.on("data", (data) => {
reject(new Error("FFMPEG: " + new Buffer(data).toString().trim()));
ffmpegErrors += "\n" + new Buffer(data).toString().trim();
});
enc.once("exit", (code, signal) => {
if (code) {
reject(new Error("FFMPEG: " + ffmpegErrors));
}
})
this.volume.once("readable", () => {
resolve({
@@ -148,10 +163,17 @@ export default class AudioEncoder {
]);
var enc = cpoc.spawn(this.getCommand(), options);
var ffmpegErrors = "";
enc.stdout.pipe(this.volume);
enc.stderr.on("data", (data) => {
reject(new Error("FFMPEG: " + new Buffer(data).toString().trim()));
ffmpegErrors += "\n" + new Buffer(data).toString().trim();
});
enc.once("exit", (code, signal) => {
if (code) {
reject(new Error("FFMPEG: " + ffmpegErrors));
}
})
this.volume.once("readable", () => {
resolve({