08. Encoder Configuration h264 (CPU) - Moehammered/switch-remote-play GitHub Wiki

Encoder Configuration - h264 (CPU)

This page will help explain some of the codec settings for the h264 (CPU) available on the Encoder Configuration screen.

This page will not be able to solve your performance issues. That is dependent on your hardware limitations. But you can use this page to understand the different settings and then experiment on your own to see what works best for you.

For more information about encoding and the h264 codec, please see:

Table of Contents

General Codec Options

Make sure to set the codec option to h264 (CPU)

general codec options cpu

Then press left or right on the d-pad to go to the h264 Codec - CPU page

H264 Codec - CPU Options

h264 cpu options

Constant Rate Factor

This setting is a quality control option to tell ffmpeg how to encode frames on your PC. See this guide to learn how CRF works.

  • Range is 0 - 30
    • The higher this number is:
      • The quicker the encoder can work
      • More compression will be applied to the encoded video
    • The lower the number is:
      • The slower the encoder can work
      • ffmpeg will be strict and try its best to reduce compression in the encoded video
    • When this number is 0
      • ffmpeg will attempt to encode in a lossless video mode
      • This will be slower but can work depending on the game

In short, lower number = better picture, slower performance. Higher number = worse picture, better performance.

Keep this number as high as possible for best performance.

Preset

This setting controls the behaviour of ffmpeg when encoding video on your PC and how much time it should spend on a frame. In general, you can think of this as 'compression speed'. The options are:

  • veryslow
    • Offers best compression size
    • Means video data is smaller, so quicker to transfer over the network
    • Can introduce latency if CPU takes too long to encode and compress the video
    • Usually good to pair with CRF of 0 for great picture quality
  • slow
    • Similar to veryslow but a bit more quicker to encode and compress
  • medium
    • Good balance of compression size and encoding time
    • A good setting to try
  • fast
    • Favors encoding time and compression speed over size
    • Video data is slightly compressed, so the data will take a bit longer to transfer over the network
    • A good setting to try with moderate quality settings applied
  • very fast
    • Similar to fast, only faster with more priority for encoding and compression time
    • A great setting to try with low bitrate and high control rate factor
  • ultra fast
    • Fastest encoding time option
    • Video data will not be compressed as much as the other options
    • Good for transferring data over the network with low latency
    • Works fantastically with low bitrate and high control rate factor
    • Also works great with CRF of 0 and a bitrate less than ~10000

In general:

  • if you want great picture, pick a high bitrate, low control rate factor, and slow preset.
    • Latency may occur!
  • if you want low latency and better framerates, pick a low bitrate, high control rate factor, and fast preset.

Rate Control Mode

This setting tells ffmpeg how it should handle quality and bitrate when encoding video data on your PC. See this guide on rate control modes to learn more.

The options are:

  • constant bitrate
    • ffmpeg will try to make sure to follow your requested bitrate as strictly as possible
    • good for maintaining a constant quality of picture
  • variable bitrate
    • ffmpeg will try to use your requested bitrate as a guide and fluctuate from frame to frame
    • good for allowing ffmpeg to dynamically adjust quality depending on the picture on screen

Overall, this setting isn't too important. It can play a role however in picture quality, so choose which one works best on your machine.

Profile

This setting controls the available encoding techniques ffmpeg can use when processing frames on your PC. See the wikipedia page on profiles to learn more about them or read the ffmpeg encode guide and look for the profile section.

In general, this option can affect performance. The options are:

  • Baseline
    • This is the fastest performing profile option
    • Will limit the encoding techniques to keep the video output in a simple format
    • Encodes video very quickly
    • Produces poor picture quality
  • Main
    • This is a good medium between the Baseline and High profiles
    • Produces video best suited for standard definition
    • Encodes video quickly
    • Produces average picture quality
  • High
    • Best suited for high definition video
    • Produces best picture quality
    • Encodes video slower than the other options

For best performance, choose Baseline or Main.

For best picture, choose High.

Sample Settings

Before I give examples, I'd like to remind everyone that these settings are still dependent on your machine and network. If the stream is slow, has latency, or doesn't capture at a desired framerate you'd like, that is a hardware limitation.

My setup for reference:

  • PC
    • Ryzen 2600 @3.4 GHz
    • 5600XT Radeon GPU Tuning left on Automatic and Default profiles
    • 16 GB Ram @2933 MHz
    • 1TB Samsung Evo 840 SSD + ~500GB Transcend SSD
    • Intel WiFi 6 AX 2600 160MHz

Best Performance

  • General Codec Options Page
    • Desktop Resolution: 1280x720
    • Desired Framerate: 60
    • Bitrate(KB/s): 5120 or less
    • Vsync Mode: variable frame rate
    • HW Accel Mode: Auto
    • Codec: h264 (CPU)
  • h264 Codec - CPU Options Page
    • Constant Rate Factor: 30
    • Preset: Ultra Fast or Very Fast
    • Rate Control Mode: Constant Bitrate
    • Profile: Baseline

Best Picture

  • General Codec Options Page
    • Desktop Resolution: 1280x720
    • Desired Framerate: 60
    • Bitrate(KB/s): 5120 ~ 10240
    • Vsync Mode: variable frame rate
    • HW Accel Mode: Auto
    • Codec: h264 (CPU)
  • h264 Codec - CPU Options Page
    • Constant Rate Factor: 0 ~ 10
    • Preset: very slow or slow
    • Rate Control Mode: Variable Bitrate
    • Profile: High

Balanced Picture

  • General Codec Options Page
    • Desktop Resolution: 1280x720
    • Desired Framerate: 60
    • Bitrate(KB/s): 5120
    • Vsync Mode: variable frame rate
    • HW Accel Mode: Auto
    • Codec: h264 (CPU)
  • h264 Codec - CPU Options Page
    • Constant Rate Factor: 18 ~ 23
    • Preset: medium or fast
    • Rate Control Mode: Variable Bitrate
    • Profile: Main or High