Skip to content
metalefty edited this page Dec 22, 2024 · 6 revisions

xrdp introduces support for H.264 encoding

Since v0.10.2, xrdp has supported H.264 encoding in graphics remoting, a feature already available in Windows-to-Windows remote desktop connections. H.264, also known as AVC (Advanced Video Coding), is a widely used video compression standard for high-definition video.

xrdp with H.264 encoding reduces the amount of data transmitted over the network and provides a much smoother, more responsive experience compared to previous versions when using graphics-intensive applications.

Supported Encoders

Currently, only software encoders are supported. xrdp supports x264 and OpenH264 as H.264 encoders.

According to developers' quick testing results, x264 provides a smoother experience than OpenH264 in the context of usage within xrdp. Therefore, we recommend using x264 if both encoders are available.

Supported Clients

The clients listed here are those that the developers used for testing. Other clients not mentioned in this list may also support H.264. Please refer to each client's documents for details.

Prerequisites

Please check if xrdp has been compiled with H.264 enabled.

H.264 is available if you can see the string either --enable-x264 or --enable-openh264 in the result of xrdp --version.

$ xrdp --version
xrdp 0.10.2
  A Remote Desktop Protocol Server.
  Copyright (C) 2004-2024 Jay Sorg, Neutrino Labs, and all contributors.
  See https://github.com/neutrinolabs/xrdp for more information.

  Configure options:
      --enable-imlib2
      --enable-jpeg
      --enable-painter
      --enable-pam-config=freebsd
      --enable-pixman
      --enable-rfxcodec
      --enable-strict-locations
      --enable-x264
      --enable-openh264

For package maintainers

We recommend adding both --enable-x264 and --enable-openh264 to configure options if both encoders are available in the package repository. Then users can choose which encoder they prefer, either x264 or OpenH264.

Advanced Settings

H.264 encoding is a part of GFX extensions, so advanced settings can be configured in gfx.toml. See also the man page of gfx.toml. As the filename indicates, this configuration file is in TOML format, version v1.0.0.

gfx.toml consists of the following sections:

  • codec
  • x264
  • OpenH264

codec

codec section defines priority of codecs and preferred H.264 encoder.

[codec]
order = [ "H.264", "RFX" ]
h264_encoder = "x264"

order defines the priority of codecs. It is an array that contains H.264, RFX, or both. xrdp negotiates available codecs with clients, the first codec that the client supports will be used.

h264_encoder specifies a preferred H.264 encoder, either x264 or OpenH264. This parameter takes effect only when more than one encoder is enabled at compile time. If only one encoder is enabled at compile time, that encoder will be used, regardless of the value of this parameter. If the parameter is blank or invalid, it will default to x264.

x264

x264 section defines encoding parameters that will be passed to x264. Only the parameters listed in the following example can be configured. See x264 --fullhelp for a detailed explanation of the parameters.

[x264.default]
# NOTE: x264 specifies bitrate in unit of kbps.
preset = "ultrafast"
tune = "zerolatency"
profile = "main"     # profile is forced to baseline if preset == ultrafast
vbv_max_bitrate = 0
vbv_buffer_size = 0
fps_num = 60
fps_den = 1
[x264.lan]
# inherits default
[x264.wan]

You can define six separate parameter sets for each network connection type selected on the client side. First, define the default parameter set in [x264.default]. Each connection type will inherit the parameter set defined by default, unless explicitly overridden.

List of available connection types:

  • lan
  • wan
  • broadband_high
  • satellite
  • broadband_low
  • modem

Currently, xrdp does not support connection type autodetection. If autodetection is selected on the client side, it will be treated as if LAN is selected.

OpenH264

OpenH264 section defines encoding parameters that will be passed to OpenH264. Only the parameters listed in the following example can be configured.

[OpenH264.default]
# NOTE: OpenH264 specifies bitrate in unit of bps, not kbps.
EnableFrameSkip = false
TargetBitrate = 20_000_000
MaxBitrate =    0          # unspecified
MaxFrameRate = 60.0

[OpenH264.lan]
# inherits default
[OpenH264.wan]

The explanation for each parameter is as follows.

  • EnableFrameSkip - allows the encoder to skip frames in order to keep the bitrate within the limits if it is about to exceed the maximum bitrate set by MaxBitrate.
  • MaxBitrate - sets an upper limit on the bitrate in unit of bps.
  • TargetBitrate - sets the desired average bitrate (in unit of bps) the encoder will attempt to achieve during the entire encoding process.
  • MaxFrameRate - sets the maximum frame rate that the encoder will process per second.

You can define six separate parameter sets for each network connection type selected on the client side as well as x264. See x264 section above for details.

Known Issues

  • The client bundled with Windows (mstsc.exe) cannot display H.264 encoded screen if a single screen exceeds 4096 pixels or the height exceeds 2304 pixels. This limitation does not apply to the total screen size in the case of a multi-screen setup, but only the screens that exceed the size will not be displayed.
Clone this wiki locally