Open cjh980402 opened 2 years ago
Please post code that can reproduce this situation
// create AudioResource
async function songDownload(url) {
const ytdlProcess = ytdl(
url,
{
o: '-',
q: '',
f: 'bestaudio[ext=webm+acodec=opus+asr=48000]/bestaudio',
r: '100K'
},
{ stdio: ['ignore', 'pipe', 'ignore'] }
);
const stream = ytdlProcess.stdout;
if (!stream) {
throw new Error('no stdout');
}
const onError = () => {
if (!ytdlProcess.killed) {
ytdlProcess.kill();
}
stream.resume();
};
ytdlProcess.on('error', onError);
try {
const probe = await demuxProbe(stream);
return createAudioResource(probe.stream, { inputType: probe.type, inlineVolume: true });
} catch (err) {
onError();
throw err;
}
};
// play the song
try {
player.play(await songDownload(songs[0].url));
player.state.resource.volume.setVolume(volume / 100);
} catch {
sendMessage('failed to play song');
songs.shift();
return;
}
Just a recommendation, you can switch to play-dl. Play-dl doesn't require ffmpeg in normal streams.
Thanks for your recommendation. However, I think that ffmpeg used by discordjs/voice module (https://github.com/discordjs/voice/blob/main/src/audio/TransformerGraph.ts)
Thanks for your recommendation. However, I think that ffmpeg used by discordjs/voice module (https://github.com/discordjs/voice/blob/main/src/audio/TransformerGraph.ts)
Can you test again with using this script running in a different ubuntu session after the 1st song has been completed ??
#!/bin/bash
# Check if ffmpeg is running
# -x flag only match processes whose name (or command line if -f is
# specified) exactly match the pattern.
if pgrep -x "ffmpeg" > /dev/null
then
echo "Running"
else
echo "Stopped"
fi
I will check if there is a bug that corresponds to this issue. Thanks!
Even if all song is finished, result of that script is Running
That only means ffmpeg instance is not deleted.
@amishshah
Maybe this is the reason of #164 [ Memory Leak ] .
Even if 3 songs are finished, 3 ffmpeg processes are not ended. Is there any solution?
Further details: