#record bot encoding problems

14 messages · Page 1 of 1 (latest)

digital storm
karmic thistle
#
const receiver = connection.receiver.subscribe(message.member.id, {end: {behavior: EndBehaviorType.AfterSilence, duration: 100}}); 
        const decoder = new prism.opus.Decoder({ frameSize: 960, channels: 2, rate: 48000 });
        const stream = receiver.pipe(decoder).pipe(fs.createWriteStream("./recorded.pcm"))

        writer.on("finish", () => {

            exec("ffmpeg -f s16le -ar 44.1k -ac 2 -i recorded.pcm output.mp3")

            connection.disconnect();

        })
karmic thistle
half sparrow
#

I can get the audio into the ffmpeg child process but i cant get it out

karmic thistle
#

hey, i want to make a discord bot to record audio of an user but if i encode file in mp3 or wav, the file was corrupt and if i encode file in pcm i can't convert him in mp3 ([email protected]) (@discord.js/voice main)

limpid marsh
karmic thistle
woeful kelp
#

just using prism-media, which @discordjs/voice depends on
you can import opus from prism-media, and create a new opus.Decoder() which acts as a duplex stream that should receive an opus packet stream and outputs pcm
which is to say you can pipe the AudioReceiveStream that <VoiceReceiver>.subscribe() returns to said decoder, and the decoder will be a readable pcm stream

karmic thistle
karmic thistle
#

i'have resolve my probleme thanks