#record bot encoding problems
14 messages · Page 1 of 1 (latest)
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();
})
Thank you very much! Worked
you welcome
do you know how to do this realtime ?
I can get the audio into the ffmpeg child process but i cant get it out
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)
decode the opus packets to get pcm
how ? because the voice doc has no desc
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
thanks bro
but, audio are not good, i dont hear the audio it s just saturation
i'have resolve my probleme thanks