node.js - 如何将 Opus 流从 Discord 流式传输到 RTP
问题描述
我正在使用 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 (opus) 发送到 RTP mulaw 流吗?谢谢!
解决方案
我在 ffmpeg IRC 上询问并意识到原始 Opus 比特流无法解码。我改为传入原始 PCM 流并添加-f s32le
到输入中,该输入在ffmpeg -formats
.
推荐阅读
- c# - 是否有一种编程模式可以为 C# 中的泛型类提供可覆盖的默认值?
- angular - Angular:如何从嵌套的 ngFor 循环中获取输入值?
- integration - 为外部 SOAP Web 服务创建一个 maximo 端点
- java - HIbernate ignore fetching data from OnetoMany field
- python - Get Dictionary Keys From NumPy Array and Values From Increment
- javascript - 如何在使用 JSON 的 Highcharts 同步图表中设置 yAxis 最小值/最大值
- reactjs - How to achieve hot-reloading for a chrome browser extension created using create-react-app?
- r - 大虚线geom_line,但点更靠近
- c# - Github 操作构建 UWP 项目
- google-data-studio - 如何在 Data Studio 中创建多线图例