【发布时间】:2019-01-20 20:12:51
【问题描述】:
我正在使用 Node.JS Discord 机器人通过 RTP 流式传输语音呼叫。目前,在我的speaking 事件处理程序中,我有
var cmd = child_process.spawn("ffmpeg", [
'-protocol_whitelist', 'file,crypto,sdp,rtp,udp,pipe,opus',
'-re',
'-acodec', 'opus',
'-i', '-',
'-ar', '8000',
'-acodec', 'pcm_mulaw',
'-f', 'mulaw',
'-f', 'rtp',
`rtp://${rtp_ip}:${rtp_port}`]);
reciever.createOpusStream(user).pipe(cmd.stdin);
相当于运行ffmpeg命令ffmpeg -protocol_whitelist file,crypto,sdp,rtp,udp,pipe,opus -re acodec opus -i - -ar 8000 -acodec pcm_mulaw -f mulaw -f rtp rtp://${rtp_ip}:${rtp_port}
此命令的变体产生的错误范围从 pipe:: Invalid input 或 pipe:: Invalid argument 到 Invalid data on input. 到 [mp3 @ 0x5615decebe60] Format mp3 detected only with low score of 1, misdetection possible!
[mp3 @ 0x5615decebe60] Failed to read frame size: Could not seek to 16101. 任何人都可以帮助我将 ReadableStream(作品)发送到 RTP mulaw 流吗?谢谢!
【问题讨论】:
-
传入数据的格式是什么,即封装(不是编解码器)?奥格?
-
我正在使用此处记录的 discord.js 方法:discord.js.org/#/docs/main/stable/class/…
-
好吧,不可能(至少使用 ffmpeg)。流格式无效 - 请参阅 github.com/discordjs/discord.js/issues/2462
-
这是直接来自 Discord 的原始 Opus 流,通过管道传输到 ffmpeg 的标准输入。我可以改用 createPCMstream,但这可能会产生额外的开销
标签: node.js ffmpeg discord rtp discord.js