webstation-broker
Deployment

Playing on a TV or streaming stick

Why a game can run slow or choppy on a TV through a Fire TV or other streaming stick, what the broker already does about it, and a three-line setup for a TV.

This page is for playing on a TV through a streaming stick or box, such as an Amazon Fire TV. It explains in plain terms why the game can feel slow or choppy there, what the container already does about it, and what to add for a TV.

The short version

For a TV that can show 60 fps, such as a Fire TV 4K Max, add these three lines under the existing environment: of the webstation container, then recreate it (docker compose up -d):

      - SELKIES_FRAMERATE=60,60-60
      - SELKIES_ENCODER=h264enc,jpeg
      - SELKIES_VIDEO_BITRATE=15000

With these, a Fire TV 4K Max on 5 GHz Wi-Fi streams at a steady 60 fps. RetroArch games need nothing extra: the broker already stops them from slowing down with the stream (see Fix 1).

On Unraid, add each one as a Variable in the container template, as on the Unraid page.

If something still isn't right, see The game runs slow or choppy on a TV or streaming stick in Troubleshooting.

What goes wrong

Two separate things can happen, and it helps to keep them apart.

The stream slows down. Selkies (the part of the container that turns the screen into video) listens to the player. When the player says "I can only show 10 frames a second", Selkies sends only 10. That is meant to help a weak device, but a Fire TV 4K Max reports about 11 frames a second right after the stream starts, far below what it can really show, and the stream then stays low for minutes.

The game slows down with it. RetroArch normally waits for the screen before drawing the next frame (that is what VSync does). In this container the "screen" is the stream, so when the stream drops to 10 fps, RetroArch drops to 10 fps too. The game itself then runs at a sixth of its speed: music, timers and all. This is worse than a choppy picture, because the game becomes unplayable rather than just less smooth.

Fix 1: the game keeps its own speed

This one is automatic for RetroArch. When the broker starts a RetroArch game it adds five settings that make RetroArch keep time by its own timer and the sound output instead of waiting for the stream:

SettingValueWhat it does
video_vsyncfalseDon't wait for the stream before drawing the next frame.
vrr_runloop_enabletrueRun the game at its own speed using RetroArch's timer.
audio_synctrueAlso pace the game by the sound output, a second real-time clock.
video_refresh_rate60Assume a 60 Hz screen, so a low rate measured during a slow start can't stick.
video_frame_delay_autofalseTurn off automatic frame delay, which would also adjust itself to the slow stream.

With these, a slow stream only skips frames: the picture may be choppy, but the game runs at full speed.

How they are applied:

  • They only apply to games the broker launches. RetroArch opened by hand from the desktop keeps your own settings, and the broker does not edit your retroarch.cfg.
  • They win over the same settings in your retroarch.cfg. RetroArch's own override files (per core, per folder, per game) load after them, so a value set in one of those wins.
  • They are on by default. To turn them off, set RETROARCH_STREAM_PACING=0 on the container and recreate it (docker compose up -d).

Fix 2: the stream doesn't drop too low

This one is about how smooth the picture is. SELKIES_FRAMERATE tells Selkies what frame rate to start at and how low and how high the player may push it, written as start,lowest-highest:

ValueMeaningGood for
60,60-60Always 60. The player can't lower it.A TV or stick that can show 60 fps, such as a Fire TV 4K Max.
60,30-60Start at 60, never go below 30 or above 60.A player that can't keep up with 60: it can still ask for as few as 30.

When nothing is set, Selkies allows anything from 8 to 240 fps, so a slow start can pull the stream down to 10, the lowest rate a player ever asks for. Console games run at 60 fps or less, so a ceiling of 60 costs them nothing. The ceiling holds for every player of the container, so a desktop browser on a 120 or 144 Hz monitor also gets 60.

To see what your container uses now, run:

docker exec webstation printenv SELKIES_FRAMERATE

No output means nothing is set. Use your own container name in place of webstation if it differs.

The other two TV settings

SELKIES_ENCODER=h264enc,jpeg makes H.264 the video format and leaves JPEG as the only other choice. Every Fire TV decodes H.264 in hardware. H.264 is already the default, but a player can pick another format that your server can encode (such as H.265, VP8, VP9 or AV1) in the Selkies side panel, and the browser remembers that pick. This line takes those formats off the list.

SELKIES_VIDEO_BITRATE=15000 sets the bitrate the stream aims for to 15 Mbps. The number is in kilobits per second, so 15000 is 15 Mbps. 15 Mbps holds steady on a Fire TV 4K Max on 5 GHz Wi-Fi.

These settings apply to the whole container

They apply to everyone who plays from that container, desktop browsers included. Docker fixes a container's settings when it creates the container, so recreate it after changing them (docker compose up -d; on Unraid, Apply in the template). With docker run, add the same three -e lines:

  -e SELKIES_FRAMERATE=60,60-60 \
  -e SELKIES_ENCODER=h264enc,jpeg \
  -e SELKIES_VIDEO_BITRATE=15000 \

next to the others in Running the container.

On this page