RTMP stream quality

We’re trying to create an webrtc app based on mediasoup + ffmpeg.

What we have is:

Frontend with mediasoup working over UDP <-> node mediasoup server that converts video using h264 to Facebook and relays to our nginx server for archiving purposes.

We’re having some trouble with bitrate. According to chrome://webrtc-internals we peak at about 3M bitrate, thus quality ain’t that perfect when recording in 720p (not a connection issue - about 100m upload / 200m download).

What we see on our facebook stream is that when someone makes sudden move there are “squares” on background:

Our ffmpeg command looks like that:

            -noautorotate -analyzeduration  2147483647 -probesize 2147483647 -loglevel     debug -protocol_whitelist pipe,tcp,udp,rtp -fflags +discardcorrupt  -f dp  -c:v  vp8 -i pipe:0 -map 0:v:0 -c:v h264 -b:v 6000k -maxrate 8000k -minrate 4000k -bufsize 16000k -r 30 -g 60 -preset ultrafast -map  0:a:0  -strict -2 -b:a 256k -c:a aac -f  tee [f=flv:onfail=ignore]' + this._url + '|[f=flv:onfail=ignore]rtmp://videortmps.xxxx:1935/live/

And our mediasoup settings seems to include max bitrate:


        this.videoProducer = await this.peer.sendTransport.produce({
                track: videoTrack, 
                encodings: [
                        maxBitrate: 1000000
                codec: this.device.rtpCapabilities.codecs.find((codec: any) => codec.mimeType.toLowerCase() === 'video/vp8')


  return `v=0
  o=- 0 0 IN IP4
  c=IN IP4
  t=0 0
  m=video ${video.remoteRtpPort} RTP/AVP ${videoCodecInfo.payloadType} 
  a=rtpmap:${videoCodecInfo.payloadType} ${videoCodecInfo.codecName}/${videoCodecInfo.clockRate}
  m=audio ${audio.remoteRtpPort} RTP/AVP ${audioCodecInfo.payloadType} 
  a=rtpmap:${audioCodecInfo.payloadType} ${audioCodecInfo.codecName}/${audioCodecInfo.clockRate}/${audioCodecInfo.channels}

Anyone have faced similar issue and might be able to help?

try to use “x-google-min-bitrate” parameter to control the bitrate