Skip to content

H.264 / WebRTC

H.264 Video

About H.264

H.264 (also known as MPEG-4 AVC) is a highly efficient video compression standard widely used for streaming. Compared with MJPEG, H.264 offers:

  • Lower bandwidth usage
  • Better compression efficiency
  • Audio transmission support
  • Lower network latency

Implementation Options

One-KVM provides two H.264 encoding options:

Libx264 (Recommended)

Libx264 is a high-performance H.264 encoding library developed by VideoLAN. This option:

  • Is integrated into the latest version and enabled by default
  • Delivers excellent performance and ease of use
  • Supports WebRTC real-time streaming
  • Source code is available in the ustreamer branch
FFmpeg (Deprecated)

This option uses FFmpeg software encoding and has been deprecated due to performance concerns:

  • High CPU usage
  • Poor experience on low-performance devices
  • Kept only for historical reference

WebRTC Configuration

About WebRTC

WebRTC uses P2P connections and UDP transport to:

  • Reduce network latency
  • Lower server load
  • Provide better real-time performance

Default configuration

WebRTC uses Google STUN servers by default. The configuration is located at /etc/kvmd/override.yaml:

1
2
3
4
5
6
7
janus:
    stun:
        host: stun.l.google.com
        port: 19302
        retries: 5
        retries_delay: 5.0
        timeout: 5.0

Remote access configuration

Two remote access methods are supported:

  1. Port forwarding (not recommended)

    • Requires mapping UDP ports 20000-40000
    • Complex configuration with lower security

    Port Forwarding

  2. Mesh networking (recommended)

    • Use tools like Tailscale to establish a secure tunnel
    • Simple configuration with higher security
    • No need to map a large range of ports

    Tailscale

Video Quality Tuning

Image quality optimization

If the video quality is not ideal, you can:

  1. Adjust the H.264 bitrate in the system menu at the top right of the page
  2. Adjust the resolution according to network conditions
  3. Choose an appropriate quality preset

Demo Video