discordjs / voice

Implementation of the Discord Voice API for discord.js and other JS/TS libraries
Apache License 2.0
328 stars 112 forks source link

AudioResource.volume.volumeDecibels returns NaN #173

Closed WOZARDLOZARD closed 2 years ago

WOZARDLOZARD commented 2 years ago

Please describe the problem you are having in as much detail as possible: When trying to access the volume, in decibels, from an audio resource, the result is NaN, even though it's supposed to be a number.

Screenshot:

screenshot

Include a reproducible code sample here, if possible:

const { createAudioResource, StreamType } = require('@discordjs/voice');

const args = ['-reconnect', '1', '-reconnect_streamed', '1', '-reconnect_on_network_error', '1', '-reconnect_on_http_error', '4xx,5xx', '-reconnect_delay_max', '30', '-analyzeduration', '0', '-loglevel', '0', '-acodec', 'libopus', '-f', 'opus', '-ar', '48000', '-ac', '2'];

const stream = ytdl("youtube_url", { filter: "audioonly", highWaterMark: 1 << 25, requestOptions: { headers: { cookie: process.env.YTCOOKIE } } }).pipe(new FFmpeg({
    args,
})).pipe(new PassThrough({
    highWaterMark: 1,
}));

const resource = createAudioResource(stream, { inputType: StreamType.OggOpus, inlineVolume: true });

console.log(resource.volume.volumeDecibels); // NaN

Further details:

Relevant client options:

Opus Libraries

Encryption Libraries

FFmpeg

twlite commented 2 years ago

This is a bug in prism-media and was fixed by https://github.com/amishshah/prism-media/pull/82

I guess that version is not yet released

WOZARDLOZARD commented 2 years ago

Looks like following the fixes in the prism-media PR indeed fixed the issue, thank you!