07. Encoder Configuration - Moehammered/switch-remote-play GitHub Wiki

Encoder Configuration

This page gives some insight into the Encoder Configuration screen available on the Switch application and the different settings.

This page will not show you how to solve performance or stream issues, that unfortunately is entirely up to you to experiment and figure out what works for your machine.

For detailed information about ffmpeg and the many, many parameters that it has, please see the ffmpeg documentation to learn more.

Table of Contents

General Codec Options

general codec options page

Desktop Resolution

This setting controls the capture resolution for ffmpeg. switch-remote-play-host will attempt to change the resolution of your desktop to the specified resolution.

  • The listed resolutions are 16:9 aspect ratio resolutions
    • This is to match the Switch's aspect ratio
  • The lower this resolution is, the better and quicker the encoder will be at sending video data
  • If your monitor doesn't support 16:9 aspect ratio resolutions, then it will fail to resize your monitor and the video sent through might not capture your entire desktop

For best performance, keep this at 1280 x 720

Switch Resolution

This setting is to control the render resolution of the Switch. It is set and stuck to 1280 x 720. There are 2 reasons for this:

  1. The Switch ffmpeg library is using the software decoder. Keeping the resolution low will help make sure the decoder can keep up and render quickly enough
  2. This project uses SDL to render the frames coming in. Changing the SDL frame at run time can be done but will complicate the code if someone attempts to set this at 1920 x 1080 when in handheld mode. You won't be able to see the menus or anything unless you manually delete the configuration file

In short: Higher Switch resolution = lower performance and not worth the potential issues

Desired Framerate

This setting is to control what target framerate the ffmpeg encoder on your PC should aim for. You can choose either 30 or 60.

It does not guarantee framerate. There are settings to force constant framerate but that will then introduce latency because your PC will be forced to queue and process every single frame to guarantee the requested frames you've asked. Then your Switch will be forced to process every single frame once they arrive and it can fall behind, causing the stream to increase in delay the longer you play for.

In short, set it to 30 if you're having performance issues or set it to 60 and forget it.

Bitrate(KB/s)

This setting is to control and act as a guide for the bitrate the ffmpeg encoder on your PC will use when processing frames.

  • The range is 3072 - 15360 kilobytes per second.
  • Has different effects depending on the codec settings, but in general will help with latency and fps.
  • Keep this as low as possible.
  • Anything above ~10000 can cause latency
    • But you're welcome to try it of course. Heck if it works for your machine that's great!
  • The bigger this setting is:
    • The harder the encoder works
    • The bigger the frames are to send, so more latency can occur

For best performance, keep this setting as low as you can. I use 5120kb myself.

Vsync Mode

This setting is to control how ffmpeg will behave on your PC when trying to create frames for encoding. The following options are available:

  • Auto
    • ffmpeg decides what vsync option to use. Generally picks what is good for video capture, but not for streaming.
  • Passthrough
    • ffmpeg will render frames with timestamps attached to them.
  • Constant Frame Rate
    • ffmpeg will force itself to follow the framerate you choose. Meaning it will wait and capture every frame that occurs
    • No frames will be dropped or skipped
    • This will force latency to occur
  • Variable Frame Rate
    • ffmpeg will capture and render frames as fast as it can. Great for streaming
    • Frames can be skipped or dropped (but it is hard to notice personally unless the quality settings are too high)
    • This will make sure ffmpeg produces frames with as little latency as it can
  • Drop time
    • Just like passthrough except it will drop the timestamps and generate new ones

See the ffmpeg documentation and look for the vsync parameter for more info.

In short, keep this at Variable Frame Rate. If you're watching a movie or netflix, then use Constant Frame Rate.

HW Accel Mode

This setting will control how ffmpeg chooses acceleration options when encoding and capturing frames. There are 2 supported options:

  • Auto
    • This is the default and best option to go with
  • DXVA2
    • This option will make the picture look noticeably different. Give it a go and see if it helps

I usually keep this setting at Auto. Feel free to change it. I haven't noticed performance differences myself.

Codec

This setting will control which encoder ffmpeg uses on your PC to create and encode the video. The 2nd page of the Encoder Configuration screen changes depending on which codec you have selected. The follow options are available:

  • h264 (CPU)
    • This encoder works using your CPU
    • Default and simplest encoder to use
  • h264 AMF (AMD)
    • This encoder works using your AMD GPU
      • Ryzen CPUs with integrated graphics cards should potentially work. But I have no way to test that.
    • Difficult to configure and use
    • Offers better capture framerate (depending on the game!)
    • Can introduce latency depending on the settings
  • h264 NVENC (NVIDIA) [unsupported]
    • Currently not implemented in the switch-remote-play-host or switch-remote-play applications
    • I have an old 1050ti but it is not installed in my machine. Implementing this codec is extremely low priority for me.
  • h264 Quick Scan Video (Intel) [unsupported]
    • Currently not implemented in the switch-remote-play-host or switch-remote-play applications
    • I have 2 machines (a laptop and GPD Win 3) that use an Intel CPU that I can test this with
    • This will be implemented at a later time and will bring with it support for hardware encoding on Intel CPUs that support QSV.

I recommend trying the h264 (CPU) codec first and looking at the codec options for it (press dpad left or right to go to the next page)

Monitor Number

This setting will control which monitor is targeted and streamed to your Switch. It does so by asking Windows for the list of monitors, finding the location of the target monitor, then calculating the region of the desktop to capture with ffmpeg.

  • Primary monitor will always be 0
  • Secondary monitors are 1 and above
    • See Windows display settings to figure out the order of your monitors for your PC

Sample Settings

Honestly, it really is hard to give sample settings because they are dependent on your own hardware and require you to play around with it. Your PC and network environment will have different limitations than my own.

That said, if you'd like to see example settings: