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

@@ -90,9 +90,17 @@ var AudioEncoder = (function () {
var enc = _child_process2["default"].spawn(_this.getCommand(), ['-hide_banner', '-i', '-', '-f', 's16le', '-ar', '48000', '-ss', options.seek || 0, '-ac', 2, 'pipe:1']);
stream.pipe(enc.stdin);
var ffmpegErrors = "";
enc.stdout.pipe(_this.volume);
enc.stderr.on("data", function (data) {
reject(new Error("FFMPEG: " + new Buffer(data).toString().trim()));
ffmpegErrors += "\n" + new Buffer(data).toString().trim();
});
enc.once("exit", function (code, signal) {
if (code) {
reject(new Error("FFMPEG: " + ffmpegErrors));
}
});
_this.volume.once("readable", function () {
@@ -122,9 +130,16 @@ var AudioEncoder = (function () {
var enc = _child_process2["default"].spawn(_this2.getCommand(), ['-hide_banner', '-i', file, '-f', 's16le', '-ar', '48000', '-ss', options.seek || 0, '-ac', 2, 'pipe:1']);
var ffmpegErrors = "";
enc.stdout.pipe(_this2.volume);
enc.stderr.on("data", function (data) {
reject(new Error("FFMPEG: " + new Buffer(data).toString().trim()));
ffmpegErrors += "\n" + new Buffer(data).toString().trim();
});
enc.once("exit", function (code, signal) {
if (code) {
reject(new Error("FFMPEG: " + ffmpegErrors));
}
});
_this2.volume.once("readable", function () {
@@ -155,9 +170,16 @@ var AudioEncoder = (function () {
var options = ffmpegOptions.concat(['-hide_banner', '-f', 's16le', '-ar', '48000', '-ac', 2, 'pipe:1']);
var enc = _child_process2["default"].spawn(_this3.getCommand(), options);
var ffmpegErrors = "";
enc.stdout.pipe(_this3.volume);
enc.stderr.on("data", function (data) {
reject(new Error("FFMPEG: " + new Buffer(data).toString().trim()));
ffmpegErrors += "\n" + new Buffer(data).toString().trim();
});
enc.once("exit", function (code, signal) {
if (code) {
reject(new Error("FFMPEG: " + ffmpegErrors));
}
});
_this3.volume.once("readable", function () {

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({