Reputation: 538
I'm using a Node.JS Discord bot to stream a voice call over RTP. Currently, in my speaking
event handler, I have
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);
equivalent to running the ffmpeg command 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}
Variations of this command produce errors ranging from pipe:: Invalid input
or pipe:: Invalid argument
to Invalid data on input.
to [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.
Could anyone help me with sending a ReadableStream (opus) to an RTP mulaw stream? Thanks!
Upvotes: 1
Views: 1481
Reputation: 538
I asked on the ffmpeg IRC and realized that raw Opus bitsreams can't be decoded. I instead passed in a raw PCM stream and added -f s32le
to the input, which is listed as a format in ffmpeg -formats
.
Upvotes: 1