adv.setVideoEncoding()

call.adv.setVideoEncoding() controls the video stream transmitted in the call. It can be used to limit its maximum bandwidth and framerate, and downscale the transmitted video.

Lowering any of these values means lower video quality - but also lower CPU and Internet connection requirements to successfully transmit the video stream.

Video bandwidth is constantly monitored and controlled by the browsers, if connection has low bandwidth they decrease video bandwidth automatically to avoid dropped frames. Please notice that these values are requests - browser can decide to ignore them. They are also the maximum values - if browser detects bad connections it may lower video quality further.

Arguments

call.adv.setVideoEncoding(maxBitrate, maxFramerate, scaleDown)

  • maxBitrate - (optional) maximum video bandwidth, in kbps
  • maxFramerate - (optional) maximum frames per second
  • scaleDown - (optional) video frame size downscale factor (see below)

Missing values keep old settings.

maxBitrate is usually 2 Mbps (2000 kbps) unless limited by wrtc.videoBandwidth or wrtc.adv.requestBandwidth. You can cut video bandwidth in half, to 1 Mbps (1000 kbps) by setting maxBitrate to 1000 without any noticeable degradation in image quality. Once video bandwidth has been lowered to around 600 kbps you will start to notice image quality degradation.

scaleDown is a downsizing factor of the video frame. Factor 1 keeps original frame size. Factor 2 downscales transmitted image to half width, half height, resulting in a picture quarter in size of the original. For instance if original video frame is 640x480 pixels in size scaleDown=2 will result in video frames of 320x240 pixels in size transmitted. scaleDown is a float, you may use fractional values but it must be equal or greater than 1.0 - video frames can be downscaled only, not enlarged.

Returns

nothing

Example

Transmit a low resolution "postage stamp" image:

call.adv.setVideoEncoding(100, 5, 4);

Transmit full image again:

call.adv.setVideoEncoding(wrtc.videoBandwidth, 50, 1);

Different ways of controlling video quality

You should always try to keep video bandwidth as low as possible but still deliver an acceptable video quality to optimize user video experience vs bandwidth and CPU load. Most of the work is done automatically by the browsers - but they still optimize video quality for full screen viewing. If you know the displayed video will be smaller, or if you for some other reason want to limit video bandwidth or quality there are multiple ways wrtc_kit can help you:

It is important to understand what these different functions do and which one to use.

wrtc.adv.videoConstraints control your video source, your video camera. Setting video size and framerate here will instantly affect all your calls as you control the very source of your video with it.

wrtc.videoBandwidth control the max transmitted video bandwidth all your future calls will use. It will not affect bandwidth of current calls. wrtc.videoBandwidth is mostly intended to be set only once, in wrtc.init() as an absolute maximum bandwidth limit for all your calls.

wrtc.adv.requestBandwidth controls the same way the max received video bandwidth for all your future calls. It is a request sent to call partners: please avoid sending higher bandwidth than this to me. This value is also mostly intended to be set only once, in wrtc.init().

call.adv.setVideoEncoding() is a dynamic way of changing the video stream you transmit in a call. It is individual for each call. You still set the maximum values those calls can use - the browser can still limit the values further.

call.adv.requestVideoEncoding() is a dynamic way of changing the video stream you receive in a call, but it only works if client at other end of call uses wrtc_kit - eg it will not work for SIP calls.

If you set multiple maximum values then the lowest of them will be used. For instance wrtc.videoBandwidth=1000; call.adv.setVideoEncoding(500); will result in maximum 500 kbps video stream.

See Also

ixnx/wrtc/js/api/call/adv.setvideoencoding.txt · Last modified: by tibor
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0