From 19a56663ba841cbfea063fff67b1660155e1a5a4 Mon Sep 17 00:00:00 2001 From: Brian Le Date: Fri, 25 Oct 2024 12:39:26 -0700 Subject: [PATCH 1/3] Revert "Move seek arg to post-encode (#14)" This reverts commit 3747e9fe087a33389c3dda8c3310fc9fbab2e269. --- lib/voice/streams/FFmpegOggTransformer.js | 2 +- lib/voice/streams/OggOpusPassthroughTransformer.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/voice/streams/FFmpegOggTransformer.js b/lib/voice/streams/FFmpegOggTransformer.js index 6db40b68f..e42a8130a 100644 --- a/lib/voice/streams/FFmpegOggTransformer.js +++ b/lib/voice/streams/FFmpegOggTransformer.js @@ -10,7 +10,6 @@ module.exports = function(options = {}) { options.frameDuration = 60; } let inputArgs = [ - "-i", options.input || "-", "-analyzeduration", "0", "-loglevel", "24" ].concat(options.inputArgs || []); @@ -22,6 +21,7 @@ module.exports = function(options = {}) { ); } inputArgs = inputArgs.concat( + "-i", options.input || "-", "-vn" ); const outputArgs = [ diff --git a/lib/voice/streams/OggOpusPassthroughTransformer.js b/lib/voice/streams/OggOpusPassthroughTransformer.js index 0df2f6286..6a50eb897 100644 --- a/lib/voice/streams/OggOpusPassthroughTransformer.js +++ b/lib/voice/streams/OggOpusPassthroughTransformer.js @@ -10,7 +10,6 @@ module.exports = function(options = {}) { options.frameDuration = 60; } let inputArgs = [ - "-i", options.input || "-", "-loglevel", "24" ].concat(options.inputArgs || []); if(options.format === "pcm") { @@ -21,6 +20,7 @@ module.exports = function(options = {}) { ); } inputArgs = inputArgs.concat( + "-i", options.input || "-", "-vn" ); const outputArgs = [ From fe12e2679f99325f82218052653e5b6ba0ca82ae Mon Sep 17 00:00:00 2001 From: Brian Le Date: Fri, 25 Oct 2024 14:31:05 -0700 Subject: [PATCH 2/3] Support string source for OggOpusPassthroughTransformer --- lib/voice/Piper.js | 59 ++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/lib/voice/Piper.js b/lib/voice/Piper.js index 81ccc87d0..19527a09a 100644 --- a/lib/voice/Piper.js +++ b/lib/voice/Piper.js @@ -166,30 +166,43 @@ class Piper extends EventEmitter { } else { if(this.libopus) { if(options.opusPassthrough) { - this.streams.push(source = source.pipe(new OggOpusPassthroughTransformer({ - command: this.converterCommand, - encoderArgs: options.encoderArgs, - inputArgs: options.inputArgs, - format: options.format, - frameDuration: options.frameDuration - })).once("error", (e) => this.stop(e))); - } else if(typeof source === "string") { - this.streams.push(source = new FFmpegOggTransformer({ - command: this.converterCommand, - input: source, - encoderArgs: options.encoderArgs, - inputArgs: options.inputArgs, - format: options.format, - frameDuration: options.frameDuration - }).once("error", (e) => this.stop(e))); + if (typeof source === "string") { + this.streams.push(source = new OggOpusPassthroughTransformer({ + command: this.converterCommand, + input: source, + encoderArgs: options.encoderArgs, + inputArgs: options.inputArgs, + format: options.format, + frameDuration: options.frameDuration + }).once("error", (e) => this.stop(e))); + } else { + this.streams.push(source = source.pipe(new OggOpusPassthroughTransformer({ + command: this.converterCommand, + encoderArgs: options.encoderArgs, + inputArgs: options.inputArgs, + format: options.format, + frameDuration: options.frameDuration + })).once("error", (e) => this.stop(e))); + } } else { - this.streams.push(source = source.pipe(new FFmpegOggTransformer({ - command: this.converterCommand, - encoderArgs: options.encoderArgs, - inputArgs: options.inputArgs, - format: options.format, - frameDuration: options.frameDuration - })).once("error", (e) => this.stop(e))); + if(typeof source === "string") { + this.streams.push(source = new FFmpegOggTransformer({ + command: this.converterCommand, + input: source, + encoderArgs: options.encoderArgs, + inputArgs: options.inputArgs, + format: options.format, + frameDuration: options.frameDuration + }).once("error", (e) => this.stop(e))); + } else { + this.streams.push(source = source.pipe(new FFmpegOggTransformer({ + command: this.converterCommand, + encoderArgs: options.encoderArgs, + inputArgs: options.inputArgs, + format: options.format, + frameDuration: options.frameDuration + })).once("error", (e) => this.stop(e))); + } } this.streams.push(source.pipe(new OggOpusTransformer()).once("error", (e) => this.stop(e))); } else { From d1c992cb96faec69e9741b25b12f7bcbf7232092 Mon Sep 17 00:00:00 2001 From: Brian Le Date: Fri, 25 Oct 2024 14:39:26 -0700 Subject: [PATCH 3/3] lint --- lib/voice/Piper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/voice/Piper.js b/lib/voice/Piper.js index 19527a09a..2fb84f3d1 100644 --- a/lib/voice/Piper.js +++ b/lib/voice/Piper.js @@ -166,7 +166,7 @@ class Piper extends EventEmitter { } else { if(this.libopus) { if(options.opusPassthrough) { - if (typeof source === "string") { + if(typeof source === "string") { this.streams.push(source = new OggOpusPassthroughTransformer({ command: this.converterCommand, input: source,