-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Corrupt pcm stream & opus stream never finishes. #4780
Comments
PCM just contains the audio samples, but ffmpeg needs to know metadata information such as bitrate, sample rate, and channels to convert it to mp3/wav. Here is a working function that I use: import ffmpeg from "fluent-ffmpeg"
const convertPCM = async (input, dest) => {
await new Promise((resolve, reject) => {
ffmpeg(input).inputOptions(["-f", "s16le", "-ar", "48k", "-ac", "2"]).save(dest)
.on("end", () => resolve())
.on("error", () => reject())
})
} This sets the format to signed 16-bit PCM, sample rate to 48kHz, and channels to 2 (stereo). |
|
My guess is that there is an error (that you aren't catching) so the stream never resolves. I never use opus, so I don't know the ffmpeg command for that. But there is this library prism media that has an opus decoder. |
The opus stream not finishing is unrelated to As the stream never fires a |
Hi there, We're working on a new implementation of Discord's Voice API that has better playback quality and is more reliable than what we currently support in Discord.js v12 - check it out at https://github.com/discordjs/voice! The new library solves many of the issues that users are facing, and as part of this, we're dropping built-in support for voice in our next major release. We have a PR (#5402) that adds native support for our new voice library - once this PR is merged, this issue will be closed. You can still use our new voice library before that PR lands - just take a look at our music bot example to see how to get started upgrading your voice code. By using the boilerplate music player in the example, you can make it even easier to upgrade your code. Note that the PR above only reduces some of the boilerplate code you'd otherwise have to write - you do not have to wait for the PR to be merged to start using the new voice library. If you have any questions about this, feel free to:
|
Please describe the problem you are having in as much detail as possible:
After either piping to a file or to ffmpeg using
ffmpeg-fluent
, both throw an error where the input data is corrupt/incorrect.After converting the file to mp3 with the
ffmpeg
command-line tool, I get a 59KB file that is just static noise.Using
{ mode: 'opus' }
instead of{ mode: 'pcm' }
results in the stream never finishing. While the pcm stream is ~200KB once finished, the opus stream is ~8KB, which leads me to believe something isn't working there.Include a reproducible code sample here, if possible:
Further details:
Let me know if I did anything wrong - I'm not sure what else to try at this point :)
Medium? Audio recording is completely broken. Not sure if it's a large part of day-to-day use for users that use discord.js but for those who do it's a fairly high priority.
Relevant client options:
b0ab37d
The text was updated successfully, but these errors were encountered: