GPU and transcoding

When ZiiX.TV plays a file directly, repackages it or converts it, how to convert on an NVIDIA graphics card, and how to limit how many videos are converted at once.

ZiiX.TV plays every file in the way that costs the server least, and converts only what the device cannot play.

Direct, repackaged or converted

Each app and browser tells the server which formats it can play. For each file, ZiiX.TV then chooses:

WhenCost
Direct playThe device plays the container, video and first audio track as they areNothing: the file is sent as it is
RepackagedThe picture is H.264 (not HDR) in an MKV file, but the device needs another container or audioLittle: the picture is copied, only the sound is converted
ConvertedEverything elseConverted to H.264 and AAC stereo, up to 1080p

A file is also converted when you choose an audio track other than the first, when subtitles made of pictures (such as PGS from Blu-ray) are shown, since those are drawn into the picture, or when the browser fails to play it directly.

HDR video is tone-mapped to look right on screens without HDR. A device that can play HDR HEVC itself gets the file directly.

Conversion runs only while someone watches, a little ahead of the viewer, and starts again where you jump to.

Converting on an NVIDIA graphics card

ZiiX.TV can use an NVIDIA graphics card (NVENC) to convert video and to decode it. Intel Quick Sync and AMD graphics are not supported; without an NVIDIA card, the CPU is used.

  1. Install the NVIDIA driver and the NVIDIA Container Toolkit on the server, and check that Docker sees the card:

    docker run --rm --gpus all ubuntu nvidia-smi
    
  2. Next to docker-compose.yml, add docker-compose.nvidia.yml:

    services:
      ziix-tv:
        deploy:
          resources:
            reservations:
              devices:
                - driver: nvidia
                  count: all
                  capabilities: [gpu]
    
  3. Start with both files:

    docker compose -f docker-compose.yml -f docker-compose.nvidia.yml up -d
    

Settings → Server shows Video conversion: NVIDIA graphics card when the card is in use.

ZIIX_HWACCEL

ValueWhat it does
auto (default)Tries the NVIDIA card at start and uses it if it works, otherwise the CPU
nvencRequires the NVIDIA card; the server will not start without it
offAlways the CPU

If the card fails on a particular file, that stream carries on on the CPU, and the log says so.

Seek-bar pictures and intro detection always use the CPU.

How many at once

Under Settings → Video you can limit the number of videos being repackaged or converted:

  • Most per user (3 by default): when a user starts one more, their oldest stream is stopped.
  • Most on the whole server (half the CPU cores, at least 4, by default): beyond that, new streams are refused until one ends.

0 means no limit. Direct play does not count.

What a CPU can manage

As a rough guide, converting one 1080p film keeps one to two modern CPU cores busy. Repackaging and direct play take next to nothing. A Raspberry Pi is fine for direct play, but usually too slow to convert video.