RTMP stream quality

Hello,
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:

Frontend:

        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')
            });

SDP:

  return `v=0
  o=- 0 0 IN IP4 127.0.0.1
  s=FFmpeg
  c=IN IP4 127.0.0.1
  t=0 0
  m=video ${video.remoteRtpPort} RTP/AVP ${videoCodecInfo.payloadType} 
  a=rtpmap:${videoCodecInfo.payloadType} ${videoCodecInfo.codecName}/${videoCodecInfo.clockRate}
  b=AS:2000000
  a=sendonly
  m=audio ${audio.remoteRtpPort} RTP/AVP ${audioCodecInfo.payloadType} 
  a=rtpmap:${audioCodecInfo.payloadType} ${audioCodecInfo.codecName}/${audioCodecInfo.clockRate}/${audioCodecInfo.channels}
  a=sendonly
  `;

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

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