我正在尝试使用我的 discord bot 播放音乐,并且我想使用 ffmpeg 来指定音乐的开头,效果很好,但我只能使用 ffmpeg 下载音乐然后播放。我希望 ffmpeg 对其进行处理,然后将其流式传输以播放音乐。这是我用来下载然后播放音乐的代码:message.member.voiceChannel.join().then((con, err) => { ytPlay.search_video(op, (id) => { let stream = ytdl("https://www.youtube.com/watch?v=" + id, { filter: "audioonly" }); let audio = fs.createWriteStream('opStream.divx'); proc = new ffmpeg({ source: stream }) proc.withAudioCodec('libmp3lame') .toFormat('mp3') .seekInput(35) .output(audio) .run(); proc.on('end', function() { let input = fs.createReadStream('opStream.divx'); console.log('finished'); guild.queue.push(id); guild.isPlaying = true; guild.dispatcher = con.playStream(input); }); });})是否有可能做我想做的事,如果是,如何做?
添加回答
举报
0/150
提交
取消