mirror of
https://github.com/danbulant/discord.js
synced 2026-07-05 03:00:35 +00:00
Fixed ffmpeg/avconv confusions
This commit is contained in:
parent
36e40d1b35
commit
ad536445d9
3 changed files with 6 additions and 4 deletions
|
|
@ -49,6 +49,7 @@ var AudioEncoder = (function () {
|
||||||
|
|
||||||
var p = cpoc.spawnSync(choice);
|
var p = cpoc.spawnSync(choice);
|
||||||
if (!p.error) {
|
if (!p.error) {
|
||||||
|
console.log("found " + choice);
|
||||||
this.choice = choice;
|
this.choice = choice;
|
||||||
return choice;
|
return choice;
|
||||||
}
|
}
|
||||||
|
|
@ -97,7 +98,7 @@ var AudioEncoder = (function () {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
return new Promise(function (resolve, reject) {
|
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]);
|
"-af", "volume=1", "pipe:1", "-i", file]);
|
||||||
|
|
||||||
enc.stdout.once("readable", function () {
|
enc.stdout.once("readable", function () {
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ class AudioEncoder{
|
||||||
for(var choice of choices){
|
for(var choice of choices){
|
||||||
var p = cpoc.spawnSync(choice);
|
var p = cpoc.spawnSync(choice);
|
||||||
if(!p.error){
|
if(!p.error){
|
||||||
|
console.log("found " + choice);
|
||||||
this.choice = choice;
|
this.choice = choice;
|
||||||
return choice;
|
return choice;
|
||||||
}
|
}
|
||||||
|
|
@ -84,7 +85,7 @@ class AudioEncoder{
|
||||||
encodeFile(file, callback=function(err, buffer){}){
|
encodeFile(file, callback=function(err, buffer){}){
|
||||||
var self = this;
|
var self = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var enc = cpoc.spawn("ffmpeg" , [
|
var enc = cpoc.spawn(self.getChoice() , [
|
||||||
"-f", "s16le",
|
"-f", "s16le",
|
||||||
"-ar", "48000",
|
"-ar", "48000",
|
||||||
"-ac", "1", // this can be 2 but there's no point, discord makes it mono on playback, wasted bandwidth.
|
"-ac", "1", // this can be 2 but there's no point, discord makes it mono on playback, wasted bandwidth.
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,8 @@ client.on("message", m => {
|
||||||
|
|
||||||
if (client.internal.voiceConnection) {
|
if (client.internal.voiceConnection) {
|
||||||
var connection = client.internal.voiceConnection;
|
var connection = client.internal.voiceConnection;
|
||||||
|
var request = require("request");
|
||||||
connection.playFile(rest).then(intent => {
|
connection.playRawStream(request(rest)).then(intent => {
|
||||||
client.reply(m, "playing!").then((msg) => {
|
client.reply(m, "playing!").then((msg) => {
|
||||||
|
|
||||||
intent.on("end", () => {
|
intent.on("end", () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue