6 Video Rendering Options
mmcclaskey edited this page 2021-11-11 14:58:12 -05:00

Summary

KasmVNC works well with defaults, however, there are a lot of controls that have been added over time that provide a fine grain level of control of how KasmVNC renders the screen under different conditions. There are two ways to set rendering options, client side or server side.

Client-side Settings

KasmVNC allows users to change a number of settings that affect rendering quality. Preset modes simplify settings by providing an easy single drop down that will adjust all settings for preset modes of static, low, medium, high, and extreme. Users can set the preset mode to custom and adjust the settings individually.

Preset mode changes are applied immediately without having to reconnect, however, if the user selects custom, they must refresh or disconnect and reconnect for the changes to be applied. The following table lists all options and the values set with each mode.

Name Low Medium High Extreme
Dynamic Quality Min 3 4 7 8
Dynamic Quality Max 7 9 9 9
Treat Lossless 7 7 8 8
Frame Rate 22 24 30 30
Video JPEG Quality. 5 7 8 8
Video WEBP Quality. 4 7 8 8
Video Area 65 65 65 100*
Video Time 5 5 5 100*
Video Out Time 3 3 3 3*
Scaling Mode Nearest Nearest Nearest Nearest*
Video Mode Width 960 960 1920 1920*
Video Mode Height. 540 540 1080 1080*

*Video mode is effectively disabled in Extreme mode

Resolution

Modes Medium, High, and Extreme match the resolution of the client and automatically resize if the size of the client changes. The Low mode sets a maximum width of 1280 and dynamically sets the height to keep the aspect ratio. The image is then blown up client side to take up the full screen. The static mode mirrors all settings from medium except that the resolution is fixed at 1280x720, the image is scaled client side to take as much of the screen as possible, but keeping the aspect ratio.

Anti-Aliasing

Anti-aliasing is a client side only setting, meaning it can only be set on the client and it does not affect the server. Anti-aliasing affects how the browser will scale images. High resolution screens, such as Apple Retina displays, will result in the browser automatically scaling the entire window without the user knowing. Most high DPI screens result in the browser scaling between 2 and 4 times resulting in KasmVNC resolution that is 1/2 to 1/4th the physical resolution. Scaling can result in blurring due to anti-aliasing that occurs. When Anti-Aliasing is set to Auto Dynamic, KasmVNC will disable anti-aliasing if the scaling ratio is a real number. If scaling is a fractional number, anti aliasing is required. In some cases, KasmVNC can do the wrong thing, in which case the user can set anti-aliasing to on or off.

For mobile devices with small physical screens but high DPI, the anti-aliasing feature will automatically scale out and increase the resolution so that the remote session is more usable on such mobile devices. This behavior will only occur when Anti-Aliasing is set to Auto Dynamic.

Server-Side Settings

Rendering settings can be supplied as arguments to vncserver when starting the service. The arguments covered in this page should be at the end of the vncserver command, as shown in this example.

vncserver $DISPLAY -depth 24 -geometry 1200x900 -FrameRate=30 -websocketPort 8443 -cert $HOME/.vnc/self.pem -sslOnly -interface 0.0.0.0 [OPTIONS]

Replace [OPTIONS] in the above example with the various desired settings described below.

NOTE: The client can override these settings unless you pass the argument "--IgnoreClientSettingsKasm=1"

Dynamic image quality

-DynamicQualityMin [0-9] (default 7) The minimum quality setting for JPEG/WEBP encoding. Rendering will automatically degrade JPEG quality when there is a lot of motion in a particular block. This setting controls the minimum quality to use when there is a high degree of change. The accepted values are 0-9 where 0 is low and 9 is high.

-DynamicQualityMax [0-9] (default 8) The maximum quality setting for JPEG/WEBP encoding. Rendering will automatically degrade JPEG quality when there is a lot of motion in a particular block. This setting controls the maximum quality to use when there is no or little motion. The accepted values are 0-9 where 0 is low and 9 is high.

-TreatLossLess [0-10] (default 10) Treat lossy JPEG/WEBP image blocks at this quality level or higher as lossless. By default, KasmVNC will send periodic lossy full frame updates. This allows overriding this behavior by not setting lossy updates no a block by block basis depending on the quality of the last update.

-PreferBandwidth Prefer bandwidth over quality. Sets various options for lower bandwidth use. This is off by default. This is a shortcut to adjust a number of options with a single flag. The settings used by this option are chosen by the KasmVNC team to set the best values for good bandwidth saving options without compromising the quality too much. Other settings can still be overridden.

-RecThreads [0-?] (default 0) Use this many threads to compress rects in parallel. Default is 0, which automatically sets threads to match the core count.

Video Mode

KasmVNC detects full screen video by looking for high rates of change on at least a certain percentage of the screen. Once switched to video mode, KasmVNC will drop back down to normal mode after the change threshold drops below that threshold for a certain period of time. These times and thresholds are all tunable with smart thresholds. Once in Video Mode, KasmVNC scales the resolution down server side, then scales the updates back up on the client side. For example, if the native resolution of the client is 4k, KasmVNC will send 4k until it goes into Video Mode. Once in Video Mode KasmVNC will scale the updates down to the resolution set by MaxVideoResolution, if that is lower than the client's native resolution. Scaling was chosen as the primary way to decrease bandwidth and increase frame rate. The KasmVNC development team tried numerous combinations of settings and methods and found that scaling the images down but keeping the JPEG/WEBP quality high provided the best quality while decreasing bandwidth utilization.

-JpegVideoQuality [0-9] (default -1) The JPEG quality to use when in video mode. The accepted values are 0-9 where 0 is low and 9 is high. A value of -1, default, keeps the quality level used in normal mode.

-WebpVideoQuality [0-9] (default -1) The WEBP quality to use when in video mode. The accepted values are 0-9 where 0 is low and 9 is high. A value of -1, default, keeps the quality level used in normal mode.

-MaxVideoResolution [resolution] (default "1920x1080") When in Video Mode, downscale the screen to this maximum size. Keeps aspect ratio with client's actual resolution.

-VideoTime [seconds] (default 5) Number of seconds that a high rate of change most occur before switching to video mode. Setting to 0 forces Video Mode at all times.

-VideoOutTime [seconds] (default 3) When in Video Mode, high rates of change must subside for this many seconds before dropping out of video mode.

-VideoArea [percent] (default 45) The percent of the screen that must be seeing high rates of change to meet the threshold of Video Mode. This percentage of the screen must see rapid changes for the amount of time specified by VideoTime.

-PrintVideoArea Print the detected video area % value. This is useful when trying to tune your settings for your particular use case.

-VideoScaling [0-2] (default 2) The scaling method to use in video mode. 0 = nearest, 1 = bilinear, 2 = progressive bilinear

WEBP vs JPEG

WEBP is a modern image standard with higher compression and fidelity than JPEG. The client will report if the browser supports WEBP and the server will mix JPEG and WEBP based on compute availability. Because WEBP takes longer to encode, the server may not be able to use WEBP for all screen updates. The quality of WEBP can be better than JPEG and therefore they have separate settings.