Why the resolution of the client produce will decrease after a period of time

Hi everyone,have you seen anything like this? is there any way to fix it? thanks
At first

Two minutes later

then ,never come back !

I use fixed resolution 720p to init client camera produce

async produce(type, deviceId = null) {
        let mediaConstraints = {}
        let audio = false
        let screen = false
        switch (type) {
            case mediaType.audio:
                mediaConstraints = {
                    audio: {
                        deviceId: deviceId
                    },
                    video: false
                }
                audio = true
                break
            case mediaType.video:
                mediaConstraints = {
                    audio: false,
                    video: {
                        width: 1280,
                        height: 720,
                        deviceId: deviceId
                        /*aspectRatio: {
                            ideal: 1.7777777778
                        }*/
                    }
                }
                break
            case mediaType.screen:
                mediaConstraints = false
                screen = true
                break;
            default:
                return
                break;
        }

Browser can decrease resolution due to CPU or bandwidth restrictions. Open dev tools available in the browser and debug it there, it should tell you precisely what is going on and why.

In fact, this optimization is certainly not good for everyone. I changed the code of webrtc to maintain the resolution instead of reducing the resolution as blow.

webrtc_video_engin.cc line2123 M89


webrtc::DegradationPreference
WebRtcVideoChannel::WebRtcVideoSendStream::GetDegradationPreference() const {
  // Do not adapt resolution for screen content as this will likely
  // result in blurry and unreadable text.
  // |this| acts like a VideoSource to make sure SinkWants are handled on the
  // correct thread.
  /*if (!enable_cpu_overuse_detection_) {
    return webrtc::DegradationPreference::DISABLED;
  }

  webrtc::DegradationPreference degradation_preference;
  if (rtp_parameters_.degradation_preference.has_value()) {
    degradation_preference = *rtp_parameters_.degradation_preference;
  } else {
    if (parameters_.options.content_hint ==
        webrtc::VideoTrackInterface::ContentHint::kFluid) {
      degradation_preference =
          webrtc::DegradationPreference::MAINTAIN_FRAMERATE;
    } else if (parameters_.options.is_screencast.value_or(false) ||
               parameters_.options.content_hint ==
                   webrtc::VideoTrackInterface::ContentHint::kDetailed ||
               parameters_.options.content_hint ==
                   webrtc::VideoTrackInterface::ContentHint::kText) {
      degradation_preference =
          webrtc::DegradationPreference::MAINTAIN_RESOLUTION;
    } else if (IsEnabled(call_->trials(), "WebRTC-Video-BalancedDegradation")) {
      // Standard wants balanced by default, but it needs to be tuned first.
      degradation_preference = webrtc::DegradationPreference::BALANCED;
    } else {
      // Keep MAINTAIN_FRAMERATE by default until BALANCED has been tuned for
      // all codecs and launched.
      degradation_preference =
          webrtc::DegradationPreference::MAINTAIN_FRAMERATE;
    }
  }

  return degradation_preference;*/
  if (!enable_cpu_overuse_detection_) {
    return webrtc::DegradationPreference::DISABLED;
  }
  return webrtc::DegradationPreference::MAINTAIN_RESOLUTION;
}

The mobile phone that failed to maintain 720p VP8 before is now running stably on 720p live broadcast. However, I tried to maintain 1080p live broadcast on this mobile phone, and the mobile phone crashed in about 10 minutes.

This phone uses the CPU :MediaTek Dimensity 700, which was almost $200 in China one year ago.Very cheap. Therefore, I suggest that you directly delete the steamer‘s degradation, just like the code above. Try to raise the viewer’s degradation threshold ,to improve robust.

1 Like

use contentHint may help
“detail”

1 Like