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:
- ffmpeg documentation to learn more
- control rate factor guide
- understanding rate control modes
- encoder profiles
Table of Contents
General Codec Options
Make sure to set the codec option to h264 (CPU)
Then press left
or right
on the d-pad
to go to the h264 Codec - CPU page
H264 Codec - 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
- The higher this number is:
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
- Similar to
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
- Similar to
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
andHigh
profiles - Produces video best suited for standard definition
- Encodes video quickly
- Produces average picture quality
- This is a good medium between the
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
andDefault
profiles - 16 GB Ram @
2933 MHz
- 1TB Samsung Evo 840 SSD + ~500GB Transcend SSD
- Intel WiFi 6 AX 2600 160MHz
- Ryzen 2600 @
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)
- Desktop Resolution:
- h264 Codec - CPU Options Page
- Constant Rate Factor:
30
- Preset:
Ultra Fast
orVery Fast
- Rate Control Mode:
Constant Bitrate
- Profile:
Baseline
- Constant Rate Factor:
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)
- Desktop Resolution:
- h264 Codec - CPU Options Page
- Constant Rate Factor:
0
~10
- Preset:
very slow
orslow
- Rate Control Mode:
Variable Bitrate
- Profile:
High
- Constant Rate Factor:
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)
- Desktop Resolution:
- h264 Codec - CPU Options Page
- Constant Rate Factor:
18
~23
- Preset:
medium
orfast
- Rate Control Mode:
Variable Bitrate
- Profile:
Main
orHigh
- Constant Rate Factor: