chanson.live icon indicating copy to clipboard operation
chanson.live copied to clipboard

feat: Don't use `ffmpeg` to stream RTP packets

Open obviyus opened this issue 2 years ago • 0 comments

Problem

ffmpeg is fantastic. It was the simplest way for me to get started with converting my downloaded *.opus files to and RTP stream that can be piped to Mediasoup.

However, when streaming music to a producer in Mediasoup, a single ffmpeg subprocess consumes ~95% CPU for a core: image

This is not a problem while we had just a single audio stream. However, I've been toying with the idea of having multiple "stations" on the radio that users can control (essentially a Radio Jockey).

Potential Solutions

(in order of preference)

  • Optimise the ffmpeg command here. Maybe I'm re-encoding the audio that's in opus to begin with?
  • Use webrtc.rs to build a CLI tool that accepts an audio file and generate RTP packets. Though I don't imagine better performance than ffmpeg is on the horizon.
  • Build my own single function RTP packet streaming tool based on the IETF spec

I would love some insights on this. I don't wish to just get a larger machine if it's at all possible to have multiple RTP streams, say 5 per core, considering it's only audio.

obviyus avatar Dec 19 '22 06:12 obviyus