0
votes

I am trying to play some audio on my linux server and stream it to multiple internet browsers. I have a loopback device I'm specifying as input to ffmpeg. ffmpeg is then streamed via rtp to a WebRTC server (Janus). It works, but the sound that comes out is horrible.

Here's the command I'm using to stream from ffmpeg to janus over rtp:

nice --20 sudo ffmpeg -re -f alsa -i hw:Loopback,1,0 -c:a libopus -ac
1 -b:a 64K -ar 8000 -vn -rtbufsize 250M -f rtp rtp://127.0.0.1:17666

The WebRTC server (Janus) requires that the audio codec be opus. If I try to do 2 channel audio or increase the sampling rate, the stream slows down or sound worse. The "nice" command is to give the process higher priority.

1
What is the Audio configuration on the Janus side ? how is the negotiation between the ffmpeg (rtp source) to the Janus gateway ? is there any SDP parameter. - mail2subhajit
The sdp is setup in a janus server configuration file: janus.conf.meetecho.com/docs/streaming.html - Robert Bain
When you are changing parameter ( channels or bitrate or sampling frequency) on the ffmpeg side are you changing parameter on the janus side too. As in rtp there is no negotiation, you need to hard code it. - mail2subhajit
Yeah, the sdp is hard coded in a janus conf. If I change one I change them both. - Robert Bain
recommend to have the default sdp/janus conf and configure you ffmpeg accordingly. can you share the janus conf /sdp for reference. - mail2subhajit

1 Answers

0
votes

Using gstreamer instead of ffmpeg works and sounds great!

Here's the cmd I'm using on CentOS 7:

sudo gst-launch-1.0 alsasrc device=hw:Loopback,1,0 ! rawaudioparse ! audioconvert ! audioresample ! opusenc ! rtpopuspay ! udpsink host=127.0.0.1 port=14365