voice
voice copied to clipboard
Somtimes ffmpeg process is not finished.
ubuntu 33024 33017 7 8월26 ? 04:34:36 /home/ubuntu/.nvm/versions/node/v16.6.2/bin/node /home/ubuntu/bot/index.js
ubuntu 36962 33024 0 8월26 ? 00:00:01 /home/ubuntu/bot/node_modules/ffmpeg-static/ffmpeg -i - -analyzeduration 0 -loglevel 0 -f s16le -ar 48000 -ac 2 pipe:1
ubuntu 37297 33024 0 8월27 ? 00:00:00 /home/ubuntu/bot/node_modules/ffmpeg-static/ffmpeg -i - -analyzeduration 0 -loglevel 0 -f s16le -ar 48000 -ac 2 pipe:1
ubuntu 44057 33024 0 8월27 ? 00:00:01 /home/ubuntu/bot/node_modules/ffmpeg-static/ffmpeg -i - -analyzeduration 0 -loglevel 0 -f s16le -ar 48000 -ac 2 pipe:1
ubuntu 56265 33024 0 8월28 ? 00:00:03 python /home/ubuntu/bot/node_modules/youtube-dl-exec/bin/youtube-dl https://www.youtube.com/watch?v=PUSkqc1amgI -o - -q -f bestaudio[
ubuntu 56268 33024 0 8월28 ? 00:00:20 /home/ubuntu/bot/node_modules/ffmpeg-static/ffmpeg -i - -analyzeduration 0 -loglevel 0 -f s16le -ar 48000 -ac 2 pipe:1
Even if 3 songs are finished, 3 ffmpeg processes are not ended. Is there any solution?
Further details:
- @discordjs/voice version: 0.6.0
- Node.js version: 16.6.2
- Operating system: ubuntu 20.04
- Priority this issue should have – please be realistic and elaborate if possible:
- Sometimes the ffmpeg process remains even when the song ends normally. In the above process log, the three ffmpeg processes above correspond to this problem.
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 ] .