From ad536445d9dcca25aab3745906eea8c3b0b2c3ce Mon Sep 17 00:00:00 2001 From: hydrabolt Date: Sun, 8 Nov 2015 16:40:40 +0000 Subject: [PATCH] Fixed ffmpeg/avconv confusions --- lib/Voice/AudioEncoder.js | 3 ++- src/Voice/AudioEncoder.js | 3 ++- test/bot.1.js | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Voice/AudioEncoder.js b/lib/Voice/AudioEncoder.js index 9ca95a128..d3a9641e5 100644 --- a/lib/Voice/AudioEncoder.js +++ b/lib/Voice/AudioEncoder.js @@ -49,6 +49,7 @@ var AudioEncoder = (function () { var p = cpoc.spawnSync(choice); if (!p.error) { + console.log("found " + choice); this.choice = choice; return choice; } @@ -97,7 +98,7 @@ var AudioEncoder = (function () { var self = this; return new Promise(function (resolve, reject) { - var enc = cpoc.spawn("ffmpeg", ["-f", "s16le", "-ar", "48000", "-ac", "1", // this can be 2 but there's no point, discord makes it mono on playback, wasted bandwidth. + var enc = cpoc.spawn(self.getChoice(), ["-f", "s16le", "-ar", "48000", "-ac", "1", // this can be 2 but there's no point, discord makes it mono on playback, wasted bandwidth. "-af", "volume=1", "pipe:1", "-i", file]); enc.stdout.once("readable", function () { diff --git a/src/Voice/AudioEncoder.js b/src/Voice/AudioEncoder.js index 33aa5b0d4..f412b27f2 100644 --- a/src/Voice/AudioEncoder.js +++ b/src/Voice/AudioEncoder.js @@ -34,6 +34,7 @@ class AudioEncoder{ for(var choice of choices){ var p = cpoc.spawnSync(choice); if(!p.error){ + console.log("found " + choice); this.choice = choice; return choice; } @@ -84,7 +85,7 @@ class AudioEncoder{ encodeFile(file, callback=function(err, buffer){}){ var self = this; return new Promise((resolve, reject) => { - var enc = cpoc.spawn("ffmpeg" , [ + var enc = cpoc.spawn(self.getChoice() , [ "-f", "s16le", "-ar", "48000", "-ac", "1", // this can be 2 but there's no point, discord makes it mono on playback, wasted bandwidth. diff --git a/test/bot.1.js b/test/bot.1.js index afcd544ff..bd2f540e4 100644 --- a/test/bot.1.js +++ b/test/bot.1.js @@ -39,8 +39,8 @@ client.on("message", m => { if (client.internal.voiceConnection) { var connection = client.internal.voiceConnection; - - connection.playFile(rest).then(intent => { + var request = require("request"); + connection.playRawStream(request(rest)).then(intent => { client.reply(m, "playing!").then((msg) => { intent.on("end", () => {