Is there a way to disable video resolution change in WebRTC?

5,372 views
Skip to first unread message

Emin DENİZ

unread,
Apr 4, 2016, 10:08:25 AM4/4/16
to discuss-webrtc
Hi all,

I am dealing with WebRTC on android. My problem is during the call WebRTC decrease my video resolution. I know that WebRTC modify video resolution depending on CPU usage and network availability. But I want to keep that resolution. I track resolution changes using StatisticReports.
For example my call starts with 640X480 and during the call I can see values below ;

googFrameWidthInput = 640 (Input resolutions which fed by camera)
googFrameHeightInput = 480
googFrameRateInput = 3 (Input FPS which fed by camera)

googFrameHeightSent = 640 (Sent resolutions to remote)
googFrameWidthSent = 480
googFrameWidthSent = 3 (Sent FPS to remote)
googBandwidthLimitedResolution = false (In case of low band with this boolean will be true)
googCpuLimitedResolution = false  (In case of high cpu usage this boolean will be true)


A few seconds later

googFrameWidthInput = 640
googFrameHeightInput = 480
googFrameRateInput = 6

googFrameHeightSent = 480 
googFrameWidthSent = 360
googFrameWidthSent = 6
googBandwidthLimitedResolution = false
googCpuLimitedResolution = true  


A few seconds later


googFrameWidthInput = 640
googFrameHeightInput = 480
googFrameRateInput = 9

googFrameHeightSent = 320 
googFrameWidthSent = 240
googFrameWidthSent = 7
googBandwidthLimitedResolution = false
googCpuLimitedResolution = true  

As you see after a while my video resolution decreasing twice. Can I stop this happening ?

Thank you.

Peter Boström

unread,
Apr 4, 2016, 10:10:54 AM4/4/16
to discuss-webrtc
Currently not without patching the code as far as I'm aware, there's a previous thread here that mentions degradation preferences which would allow you to specify whether you prefer frame dropping over downscaling: https://groups.google.com/d/msg/discuss-webrtc/92LognAPZiA/uCK446lnBgAJ

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/5aae294d-2325-46bc-bbae-657d1d265bfd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Emin DENİZ

unread,
Apr 5, 2016, 6:30:11 AM4/5/16
to discuss-webrtc
Hi Peter,

Thank you for quick response, it was helpfull. I look for those answers. In there Alexandre mention about RTCDegradationPreference. I look in to native code but I could't find any RTCDegradationPreference or RTCRtpEncodingParameters settings. Is there something like that in native code ?
And Cristopher mentions about googCpuOveruseDetection parameter. I found it and try to set it false but it didn't work resolution keep decreasing. I am not sure if I set it correctly. Is there a mechanism I can check is it set correctly or not ?

Thank you.

4 Nisan 2016 Pazartesi 17:10:54 UTC+3 tarihinde Peter Boström yazdı:

Peter Boström

unread,
Apr 5, 2016, 6:54:07 AM4/5/16
to discuss-webrtc
You're not finding it in native code because it's not implemented yet. I'm not sure if there's currently any logging that you can check to make sure that it's correctly set. You can printf inside WebRtcVideoEngine2, video_config_.enable_cpu_overuse_detection should be the flag you want. RTCConfiguration contains set_cpu_adaptation(), maybe that's what you need to set from the native side. (I'm mostly grepping the code at this point, so YMMV).

Even if CPU adaptation is disabled however we can still downscale frames in the encoder step when quality goes "bad" (high quantization), so it's not foolproof (that's googBandwidthLimitedResolution).

Emin DENİZ

unread,
Apr 5, 2016, 7:12:08 AM4/5/16
to discuss-webrtc
Hi Peter,
I find the parameters you say in native code. When I get the Statistics I see that ;
googCpuLimitedResolution = true
googBandwidthLimitedResolution = false

For looking that I think my resolution decrease because of cpu. Is there any parameter to disable Band With Limited Resolution ?

Thank you.

5 Nisan 2016 Salı 13:54:07 UTC+3 tarihinde Peter Boström yazdı:

Peter Boström

unread,
Apr 5, 2016, 9:13:14 AM4/5/16
to discuss-webrtc
Nothing to disable the latter, unless you're running screencast (which comes with other settings and is probably not desirable for non-screencast). It would be set through the future RTCDegradationPreferences.

radioman . lt

unread,
Apr 5, 2016, 12:43:20 PM4/5/16
to discuss-webrtc
check VP8EncoderImpl::InitEncode, and look for quality_scaler_ and quality_scaler_enabled_

Peter Boström

unread,
Apr 5, 2016, 2:13:38 PM4/5/16
to discuss-webrtc
You should grep for quality_scaler_ and QualityScaler elsewhere or you won't cover HW-encoder implementations.

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.

Emin DENİZ

unread,
Apr 6, 2016, 3:15:13 AM4/6/16
to discuss-webrtc
Hi all,
I think I solve the CPU limit issue. I was adding my code following line;

mediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair("googCpuOveruseDetection", "false"));

But it was not do anything. But when I change mantory to optinal it works. Resolution did not decrease depending on CPU.

mediaConstraints.optional.add(new MediaConstraints.KeyValuePair("googCpuOveruseDetection", "false"));


But there is also band with problem. It can decrease resolution. How could I disable it also ?


5 Nisan 2016 Salı 21:13:38 UTC+3 tarihinde Peter Boström yazdı:

Peter Boström

unread,
Apr 6, 2016, 5:22:55 AM4/6/16
to discuss-webrtc
You'd have to hack the code to make sure something called "QualityScaler" (variables are named quality_scaler_) never kicks in. There's no API support for removing it (until RTCDegredationPreferences get resolved).

Emin DENİZ

unread,
Apr 6, 2016, 5:24:07 AM4/6/16
to discuss-webrtc
Thank you su much for your help peter. I will try to hack it.

6 Nisan 2016 Çarşamba 12:22:55 UTC+3 tarihinde Peter Boström yazdı:

Benjamin Hamrick

unread,
Mar 3, 2017, 3:46:05 PM3/3/17
to discuss-webrtc
Is this implemented now?

Ana Pol

unread,
May 19, 2017, 6:32:18 AM5/19/17
to discuss-webrtc
Hi, 

I tried the solution above (setting the googCpuOveruseDetection to false) and I did not get the expected result. It may seem that it works, but after waiting a while the flag gets back to true and the resolution decreases (and keeps changing). Is this implemented?

Thank you for your help.

di...@cht.net.br

unread,
Apr 11, 2018, 5:13:45 AM4/11/18
to discuss-webrtc
Has RTCDegredationPreferences been resolved or implemented? Is there some other way to choose between degrading framerate or resolution? Or disabling the degradation altogether?
Message has been deleted
Message has been deleted

Shashank Gupta

unread,
Apr 22, 2019, 1:21:05 AM4/22/19
to discuss-webrtc
Hi Emin Deniz,

I am facing the exact same issue in android during webRTC integration. and from last, one week and didn't find any solution. Did you fix this issue? Could you please help me to solve this problem.
Thanks. 

李晓帆

unread,
Apr 22, 2019, 5:48:48 AM4/22/19
to discuss...@googlegroups.com
Hi,
I don't know whether this will helpful or not.
when you SetSource, the 2nd params should apply kMaintainResolution
based r67 at src/call/video_send_stream.h
  // Based on the spec in
  // https://w3c.github.io/webrtc-pc/#idl-def-rtcdegradationpreference.
  // These options are enforced on a best-effort basis. For instance, all of
  // these options may suffer some frame drops in order to avoid queuing.
  // TODO(sprang): Look into possibility of more strictly enforcing the
  // maintain-framerate option.
  enum class DegradationPreference {
    // Don't take any actions based on over-utilization signals.
    kDegradationDisabled,
    // On over-use, request lower frame rate, possibly causing frame drops.
    kMaintainResolution,
    // On over-use, request lower resolution, possibly causing down-scaling.
    kMaintainFramerate,
    // Try to strike a "pleasing" balance between frame rate or resolution.
    kBalanced,
  };
  virtual void SetSource(
      rtc::VideoSourceInterface<webrtc::VideoFrame>* source,
      const DegradationPreference& degradation_preference) = 0;

Shashank Gupta <shankgu...@gmail.com> 于2019年4月22日周一 下午1:21写道:
--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.

zhao liang

unread,
May 13, 2020, 6:47:51 AM5/13/20
to discuss-webrtc
I noticed cpu monitor is not supported after android N, so cpu overuse does not work after android N?
What is the progress of quality_scaler_?
Is there any plan to open is as API?


在 2016年4月4日星期一 UTC+8下午10:08:25,Emin DENİZ写道:

Vic

unread,
May 13, 2020, 1:09:29 PM5/13/20
to discuss-webrtc
Has anyone solved this problem?

понедельник, 4 апреля 2016 г., 17:08:25 UTC+3 пользователь Emin DENİZ написал:

Alex Cohn

unread,
Mar 2, 2022, 1:14:26 PM3/2/22
to discuss-webrtc
On Wednesday, May 13, 2020 at 8:09:29 PM UTC+3 Vic wrote:
Has anyone solved this problem?

In my experiments, Apple did. When I choose 1280×720 for front camera on iPhone X and higher, with iOS 15.3, I get stable stream of expected resolution.

BR,
Alex
Reply all
Reply to author
Forward
0 new messages