Video streaming¶
TS6 Manager includes a Go/Pion media sidecar for low-latency video delivery to TeamSpeak clients and the browser preview.
Starting from the console¶
Open Bot Hub, then Open console on the bot you want to use. If it is offline, press Start bot first. The console's Play something panel has Music · Link · Radio · IPTV source tabs; Now playing shows the active session and offers Stop stream while video or IPTV is running.
For a video URL, open Link, paste the source, choose Stream as video, then press Stream as video. The folded Video options row shows what the stream will use; open it to change Quality, Encoder, Stop with no viewers after, and Source type for that start only. Quality starts on Use bot default, which uses the bot's saved stream preset. Encoder and the no-viewer stop start on Use server default, with the current setting shown in parentheses. These come from Media Library → Streaming defaults, or from VIDEO_ENCODER and VIDEO_NO_VIEWER_TIMEOUT_SECONDS when nothing is saved there. The server resolves inherited settings when the stream starts. Choose Auto explicitly for automatic quality or encoder selection, or select another value for this stream; selecting the default option again restores inheritance. A URL can also use Play as music to play its audio.
To stream a file already under MUSIC_DIR, enter its plain filename in Link, for example clip.mp4, then press Stream. Files outside the music folder are rejected. A filename selects Stream as video and disables Play as music; use the Music tab to play a music-folder file as audio.
Opening a console or following an IPTV link only selects a source; press Stream to start it.
Queue videos and playlists¶
A bot can play several videos back to back on one stream.
Queue a video. While a video is streaming on the bot, the button in Link reads Queue as video. It adds the source to Up next instead of replacing what is playing. The video that is already streaming keeps playing, and the queued ones follow it.
Queue a YouTube playlist. Paste a playlist link, one with list= and no v=, and choose Stream as video. Every video is added in playlist order. If nothing is streaming, the first one starts. A link to a single video that also carries &list= adds that video only. One link adds up to 25 videos and the queue holds up to 100; the confirmation says (first 25) when a playlist was cut, and a full queue refuses new videos until you remove some.
What Up next shows. While a video streams, Up next lists the queued videos. Drag a row to reorder it, press play on a row to switch to it now, or remove it. Skip moves to the next video and stops the stream after the last one. Clear empties the list and leaves the playing video alone. There is no shuffle or repeat for videos. If music is also queued on the bot, it waits as one line under the list with its own Play queue.
Moving to the next video. When a video ends, the bot switches the running stream to the next one. Viewers stay connected and the quality, encoder and no-viewer timeout of the stream carry over. There is a short gap while the next video loads. A queue nobody watches still stops after the no-viewer timeout, because the countdown belongs to the stream and not to each video.
Live sources never end by themselves, so a live entry plays until you press Skip. A video that cannot be played is skipped, and the bot says so in the channel: Skipped "<title>": could not play it. After three failures in a row the stream stops and the remaining videos stay queued.
What a stop does to the queue.
| The stream stops because | The queue |
|---|---|
| you pressed Stop stream | is cleared |
| the last queued video ended | is empty |
| nobody watched, or the channel was empty | is kept, with the interrupted video first |
| music or another bot's stream replaced it | is kept |
| the sidecar failed, the bot was stopped, or TeamSpeak disconnected | is kept |
A kept queue shows Up next (n) is kept. Nothing is streaming. Press Play queue to start it again with the quality and encoder the session used before.
Restarts and disconnects. The queue is saved in the database (table VideoQueueEntry, created by the startup schema step) and is still there after the backend restarts. Nothing starts by itself: press Play queue. A bot that loses its TeamSpeak connection while streaming now stops the stream with the reason server disconnect before it reconnects, and keeps the queue.
Queueing is a console feature. In chat, !stream on a bot that is already streaming still switches the source at once.
Supported inputs¶
The streaming path can accept supported YouTube, Twitch, direct media URLs, local video files, and IPTV sources.
- YouTube is downloaded with yt-dlp to a short-lived file under the music directory (avoids googlevideo 403s from datacenter IPs), then encoded.
- YouTube, streamed directly (optional): with Settings → YouTube → Stream YouTube videos directly on, a YouTube video is not downloaded. yt-dlp resolves its media URLs and ffmpeg reads them as it plays, so a stream starts in seconds whatever the video's length, and live broadcasts work. Above 720p, and for some live broadcasts, YouTube delivers video and audio as two streams, which the sidecar reads as two inputs. Max video duration is not applied in this mode, since nothing is stored; the no-viewer timeout still ends an unwatched stream. Auto quality takes the picture size from yt-dlp, so there is no probe. It is off by default because YouTube refuses direct playback from some networks (the 403s above); if streams fail to start with it on, turn it off. The media URLs expire after some hours, which ends a stream that runs that long.
- Twitch (live or VOD) is resolved with yt-dlp to a direct media URL and fed to ffmpeg — it is not downloaded to a
.stream-*.mp4temp file (live Twitch cannot finish that path).
Quality¶
Pick Auto or a fixed preset: 480p, 720p, 1080p, 1440p or 2160p.
Streaming defaults also offer Performance / Balanced / Quality profiles (default Balanced): they set Auto limit, bitrate clamp, and software encode speed (cpu-used). Open Advanced quality settings for manual Auto limit, bitrate, encode speed, and encoder knobs.
- Auto probes the source with
ffprobeand uses the largest preset the source fits without upscaling, up to the Auto limit (default 1080p under Balanced). A 720p channel stays 720p even when the limit is 2160p. If the probe fails, Auto uses 720p (or the limit, if lower) and says so. - Fixed presets skip the probe. Prefer them for IPTV services that allow only one connection, since the probe is a second one.
- Auto adapts while the stream runs. If the encoder cannot keep up, Auto steps down one preset; once encoding has been steady again, it steps back up. Fixed presets never change by themselves. See Adaptive Auto quality.
- The stream panel shows requested → actual, e.g.
Auto → 1080p, orAuto → 720p (reduced from 1080p)after an automatic step down. - Leave the bitrate empty to use the preset's bitrate. Admins can set a bitrate limit that clamps every stream.
- Every stream is capped at 9500 kbps, whatever the preset, custom bitrate or limit says: TeamSpeak drops a stream above 10 Mbit/s, which would look like an encoder failure. 2160p therefore uses 9500 kbps.
- Software VP8 and VP9 are held at the target bitrate (
-minrate); without it libvpx overshoots on detailed video.
1440p and 2160p need a fast CPU with software encoders; a hardware encoder is recommended.
Encoders¶
| Encoder | Codec | Notes |
|---|---|---|
| VP8 (software) | VP8 | Default; libvpx realtime |
| VP9 (software) | VP9 | libvpx-vp9 realtime |
| H.264 (software) | H.264 | libx264, offered as Constrained High — the only H.264 profile the TeamSpeak client renders |
| VP8 / VP9 / H.264 (VAAPI) | same | GPU encode through VAAPI; H.264 uses Constrained High as well |
| H.264 (NVENC) | H.264 | GPU encode on NVIDIA; Constrained High. NVIDIA has no VP8 or VP9 encoder |
| H.264 (AMF) | H.264 | AMD GPU encode with a native Windows sidecar and AMF-enabled FFmpeg; explicitly requests Constrained High (-profile:v constrained_high) with no B frames for TeamSpeak |
| H.264 (VideoToolbox) | H.264 | Apple hardware encode with a native macOS sidecar; High profile with no B frames. Not yet verified on Apple hardware, see Apple VideoToolbox (macOS) |
Auto uses software VP8, unless Auto prefers hardware is enabled: then it uses the first hardware encoder (H.264 on VAAPI, H.264 on NVENC, H.264 on AMF, H.264 on VideoToolbox, then VP9 and VP8 on VAAPI) that passed the sidecar's test encode.
VideoToolbox is test-encoded only when the sidecar runs on macOS, and AMF is not test-encoded there. On any other system Check encoders shows the VideoToolbox row as unavailable with the reason "VideoToolbox is only available on macOS", without running FFmpeg. VAAPI, NVENC and AMF are checked on Linux and Windows exactly as before.
If a hardware encoder cannot open the device or exits during startup, the sidecar restarts with the software encoder of the same codec (so connected viewers keep working) and the stream panel shows the fallback and its reason. Use Check encoders under Streaming defaults to run the test encodes on demand; routine status polling never runs them.
An encoder that the sidecar's FFmpeg was not built with is not launched at all. The sidecar reads ffmpeg -hide_banner -encoders once, and Check encoders and a stream that asks for it show This FFmpeg build has no h264_amf encoder (AMF needs an FFmpeg built with AMF support and an AMD driver) (or the same for another hardware encoder) before it starts on the software encoder. Older versions showed FFmpeg's own Unrecognized option 'header_spacing' / Option not found instead, which means the same thing. This is expected when the sidecar runs under WSL or in the Docker image with a stock Linux FFmpeg, such as the static build checked for this change: it has no AMF encoder. AMF is documented here only for the native Windows sidecar with an AMF-enabled FFmpeg. To see what your FFmpeg has, run ffmpeg -hide_banner -encoders | grep amf. If FFmpeg cannot list its encoders, the sidecar skips this check and behaves as before.
Enabling VAAPI (Intel / AMD GPUs)¶
- Pass the render node through to the sidecar container, for example in
docker-compose.yml:
-
The sidecar and all-in-one images include Mesa's VAAPI driver (
mesa-va-drivers, AMD and older Intel) and, on amd64, Intel'sintel-media-va-driver. For the all-in-one image, pass/dev/drito that container instead. -
Open Streaming defaults → Check encoders and confirm the VAAPI rows pass. Set
VAAPI_DEVICEif your render node is not/dev/dri/renderD128. -
Optionally set
VIDEO_HW_DECODE=1to decode on the GPU too. The decoded frames then stay on the GPU: they are scaled withscale_vaapiand go straight to the encoder, with no copy through system memory. That is the fast path: on an Intel Pentium Gold 8505 (UHD Graphics), 4K60 VP9 to 1080p ran at about 6× real time and 65 % sidecar CPU, against 3× and 384 % when decoding on the CPU (the default). A source the GPU cannot decode still streams; it is decoded on the CPU and uploaded. There is no padding on this path: a source that is not 16:9 keeps its own shape inside the preset (a 4:3 source as 1440×1080 at 1080p), and the TeamSpeak client draws the bars.VIDEO_GPU_FILTERS=0turns it off.
Enabling NVENC (NVIDIA GPUs)¶
- Install the NVIDIA driver and the NVIDIA Container Toolkit on the host (
nvidia-container-toolkit, thennvidia-ctk runtime configure --runtime=docker). - Start the stack with the NVIDIA override, which reserves the GPU for the sidecar and sets
NVIDIA_DRIVER_CAPABILITIES=compute,video,utility(videois what loads the encoder):
The image needs nothing extra: its FFmpeg already includes h264_nvenc.
3. Open Streaming defaults → Check encoders and confirm the H.264 (NVENC) row passes. Select it, or leave the encoder on Auto with Auto prefers hardware on.
4. Optionally set VIDEO_HW_DECODE=1 on the sidecar to decode on the GPU too (-hwaccel cuda).
NVENC encodes H.264 only. The preset is p4 with the low-latency tune; VIDEO_NVENC_PRESET changes the preset. When the host has no NVIDIA GPU or container runtime, Check encoders shows NVIDIA GPU/runtime not present on that row instead of ffmpeg's generic parameter hint. A summarized ffmpeg error stays under ffmpeg output.
AV1 decoding on the GPU¶
FFmpeg 5.1 decodes AV1 with libdav1d, a software decoder that ignores -hwaccel, so AV1 sources decode on the CPU even with VIDEO_HW_DECODE=1. YouTube downloads prefer VP9 (-S res,fps,vcodec:vp9), which does decode on the GPU, so AV1 only comes up when a video's best format exists in AV1 alone.
FFmpeg's own AV1 decoder does use the GPU, but it has no software path: on a GPU without AV1 decoding the stream would not start. So the sidecar uses it only when all of these hold:
VIDEO_HW_DECODE=1and a VAAPI or NVENC encoder (AMF and VideoToolbox decode on the CPU);- the source is known to be AV1: the sidecar reads local files (downloaded videos) with ffprobe, and the backend passes the codec yt-dlp chose for a YouTube stream in direct mode. IPTV and other links are not checked and decode as before;
- a test decode on that GPU passed. The sidecar decodes a small embedded AV1 sample once per GPU and keeps the result. A crash, a timeout or any failed frame counts as not supported.
If a stream with the GPU decoder still exits during startup, or fails to decode frames in its first 15 seconds (an AV1 profile the GPU cannot decode, such as 4:4:4, keeps FFmpeg running without a picture), the sidecar starts it again on libdav1d with the same encoder, and the stream panel shows AV1 GPU decoding failed, decoding on the CPU with ffmpeg's reason. Only a failure after that falls back the encoder as usual. System → Diagnostics shows the test decode for each GPU under Encoders → AV1 decoding.
NVIDIA needs nothing extra: with NVENC on an RTX 5080, a 4K60 AV1 stream took about 50 % sidecar CPU with the GPU decoder, against 200 % on libdav1d.
Intel and the non-free driver. The images ship Debian's free intel-media-va-driver. On many Intel GPUs it lists AV1 decoding but cannot do it: on an Alder Lake GPU every frame fails with "internal decoding error", and FFmpeg exits or crashes (Debian #1087837, intel/media-driver#1921). The test decode catches that, and AV1 decodes on the CPU. Intel's non-free build of the same driver decodes AV1 on those GPUs: on an Intel Pentium Gold 8505 (UHD Graphics), 4K60 AV1 to 1080p30 h264_vaapi ran at 5.1× real time and 36 % CPU with it, against 2.4× and about 400 % on libdav1d, and a stream at real time took about 20 % sidecar CPU instead of 300 %. To use it, build the image yourself:
docker build -f Dockerfile.sidecar --build-arg INTEL_VAAPI_DRIVER=nonfree -t ts6-manager-sidecar:intel-nonfree .
docker build -f Dockerfile.all-in-one --build-arg INTEL_VAAPI_DRIVER=nonfree -t ts6-manager:intel-nonfree .
What that changes:
- It installs
intel-media-va-driver-non-freefrom Debian'snon-freecomponent instead ofintel-media-va-driver. Both are the same driver release; the non-free build keeps the pre-built GPU kernels Intel ships without their source, which the free build removes. - The driver's licence is MIT either way. Debian files the package under
non-freebecause of those kernels, so the image then contains GPU code without source. - Debian's security team does not support
non-free(security FAQ): a security fix for this package comes only if its maintainer provides one. - It replaces the free driver for everything on an Intel GPU, so VAAPI encoding also runs on it.
- The sidecar image grows by about 35 MB.
- AMD (
mesa-va-drivers) and NVIDIA (the host's driver) need no change and are not affected. The argument only matters on amd64; any value other thanfreeornonfreefails the build.
A native sidecar uses the host's FFmpeg and VA-API or NVIDIA driver instead, and the same test decode decides.
AMD AMF (Windows)¶
AMF is a supported production encoder when the media sidecar runs natively on Windows, with a compatible AMD GPU/driver and an AMF-enabled Windows FFmpeg build. The Linux Docker sidecar cannot use Windows AMF directly. VAAPI requires /dev/dri; NVENC needs a working NVIDIA driver (and NVIDIA container runtime when containerized); AMF needs neither. Windows-native NVENC and software encoders remain available when that FFmpeg build and hardware support them. On hosts without AMF, its test encode fails normally and Auto can choose another encoder.
Download a Windows FFmpeg build with AMF support from a provider listed on the FFmpeg download page, extract it, and add the directory containing ffmpeg.exe and its companion ffprobe.exe to PATH (or configure their full paths below). Use a compatible AMD Windows graphics driver. Verify in PowerShell:
The output must include h264_amf. AV1/HEVC AMF encoders may also be present, but TS6 Manager currently selects only H.264 AMF. The capability check performs a real small encode; an encoder appearing in this list alone does not prove the driver can initialize it.
From 1.11.0, each GitHub Release includes a Windows sidecar archive built from that release's tag, so AMF no longer requires building the sidecar. Downloads, version matching, background operation and the security requirements are in Native media sidecar. This is the normal cross-platform media sidecar; AMF is one runtime capability.
Breaking change for source builds¶
Sidecar source builds require Go 1.26.11 or newer, including native Windows builds. Upgrade your Go toolchain before following the build steps below.
The rest of this section builds from source, which is what the PR-test setup below uses. Build from the same checkout/release as the backend, using Go 1.26.11 or newer. From the repository root:
New-Item -ItemType Directory -Force .\bin | Out-Null
Push-Location .\packages\sidecar
try {
go build -o ..\..\bin\sidecar.exe .
if ($LASTEXITCODE -ne 0) { throw "Sidecar build failed" }
} finally { Pop-Location }
Configure a strong SIDECAR_SECRET in the backend environment and pass exactly the same value to the Windows process. The following example reads only that entry from a local .env file without printing it (supports the simple unquoted or quoted values used by the example). Supply secrets through your service environment/secret store for unattended production operation:
$secretLine = Get-Content -LiteralPath .\.env |
Where-Object { $_ -match '^\s*SIDECAR_SECRET\s*=' } |
Select-Object -Last 1
if (-not $secretLine) { throw "SIDECAR_SECRET is MISSING in .env" }
$env:SIDECAR_SECRET = ($secretLine -split '=', 2)[1].Trim().Trim('"').Trim("'")
if (-not $env:SIDECAR_SECRET) { throw "SIDECAR_SECRET is MISSING in .env" }
Remove-Variable secretLine
$env:SIDECAR_PORT = "9800"
$env:FFMPEG_PATH = (Get-Command ffmpeg -ErrorAction Stop).Source
$env:FFPROBE_PATH = (Get-Command ffprobe -ErrorAction Stop).Source
# Choose a persistent Windows directory containing the backend's shared files.
New-Item -ItemType Directory -Force .\media | Out-Null
$env:MUSIC_DIR = (Resolve-Path .\media).Path
$env:WEBRTC_UDP_PORT = "10000"
$env:WEBRTC_NAT1TO1_IP = "127.0.0.1" # Browser preview on this Windows host only.
.\bin\sidecar.exe
For TeamSpeak viewers, or browsers on another machine, replace the advertised IP with the Windows host's reachable LAN or Tailscale IPv4 before starting the sidecar. You may advertise both 127.0.0.1 and that IPv4 as a comma-separated list. The TeamSpeak client does not use loopback even on the same machine. WEBRTC_UDP_PORT is owned by the native process; it requires no Docker mapping, and the Docker-only WEBRTC_BIND_IP setting does not apply.
Set the backend's SIDECAR_URL to the Windows host's private HTTP address. A Docker Desktop backend on the same Windows machine uses http://host.docker.internal:9800; a backend on another machine uses a reachable private LAN/Tailscale address instead. Keep the HTTP API private and trusted: the fixed UDP mux listens on all interfaces, and so does the native HTTP listener unless SIDECAR_HOST names one address. Windows Firewall must allow TCP 9800 only from the backend's trusted address/network (including the Docker Desktop path when used), and UDP 10000 from intended viewers. Do not expose TCP 9800 to the public Internet; its mutating endpoints require the shared bearer secret, but health/status endpoints are not a substitute for network isolation. Use a private encrypted network or HTTPS reverse proxy when the backend is across machines. Do not disable the firewall to troubleshoot connectivity.
Local video files and downloaded clips must be accessible to both processes. Mount the Windows media directory into the backend at its MUSIC_DIR (for example /data/music) and set the sidecar's MUSIC_DIR to the Windows path to those same files. The backend sends a portable music://filename reference for local sources under its music root; the sidecar resolves it under its own root and rejects traversal. Existing absolute paths remain supported for deployments sharing one path, and HTTP/HTTPS media URLs are unchanged. A shared directory is still required: the reference does not transfer file contents.
In a second PowerShell window, verify health and then open Streaming defaults → Check encoders. H.264 (AMF) should show available and hardware; its FFmpeg diagnostics remain visible on failure. Select AMF explicitly, or enable Auto prefers hardware. AMF uses software decoding, NV12 frames in system memory, explicitly requests H.264 Constrained High (-profile:v constrained_high) and disables B frames. AMF's plain High profile is a separate setting; disabling B frames alone does not select Constrained High. VIDEO_HW_DECODE currently applies only to VAAPI/NVENC. Software fallback stays H.264 (libx264).
Invoke-RestMethod http://localhost:9800/health
# For the PR-test container; adapt the container name for your deployment:
docker exec ts6-pr-backend curl -fsS http://host.docker.internal:9800/health
Apple VideoToolbox (macOS)¶
Not verified on Apple hardware. This encoder has been checked by unit tests only. It has not been run on an Intel or Apple Silicon Mac, and playback of its output in a TeamSpeak client and in the browser preview is unconfirmed. If viewers get a black picture, switch to H.264 (software) and report it. The open checks are listed under Native media sidecar → VideoToolbox on macOS.
VideoToolbox is available when the media sidecar runs natively on macOS. A Linux container cannot use it, so the Docker sidecar always shows the row as unavailable. Install the sidecar as described in Native media sidecar and use an FFmpeg build that includes h264_videotoolbox (Homebrew's does):
Open Streaming defaults → Check encoders and confirm H.264 (VideoToolbox) passes, then select it or enable Auto prefers hardware.
- Profile. The sidecar requests High profile with no B frames (
-profile:v high -bf 0), the same as for libx264, VAAPI and NVENC, and viewers are offered Constrained High as for every H.264 encoder. - Hardware only.
-allow_sw 0makes FFmpeg fail instead of encoding on the CPU. On a Mac without a hardware H.264 encoder the test encode therefore fails. - Fallback. If the test encode failed, or the encoder exits while a stream starts, the stream runs on H.264 software (
libx264) and the stream panel shows the reason. This also applies each time Auto quality restarts the encoder at another preset. A restart tries VideoToolbox again unless Check encoders has already found it unavailable. - Late joiners. FFmpeg's VideoToolbox encoder puts SPS and PPS in front of every keyframe when it writes RTP, so no extra option is set. A keyframe that arrives without them is still covered: the sidecar puts the parameter sets it last saw in the stream in front of a late joiner's first keyframe, as it does for the other H.264 encoders. That needs them in the stream at least once. This is how FFmpeg's source reads; it has not been observed on a Mac.
- Decoding. The source is decoded and scaled on the CPU.
VIDEO_HW_DECODEandVIDEO_GPU_FILTERSdo not apply to VideoToolbox. - HEVC and ProRes VideoToolbox encoders are not offered.
Windows AMF PR-test¶
The dedicated docker-compose.pr-test.windows-amf.yml builds TeamSpeak, backend and frontend only. Run it alone, rather than combining it with the normal PR-test compose, which still runs a Linux Docker sidecar for software/VAAPI/NVENC testing. Both harnesses use the same container names and persistent data volumes; stop the other harness before switching.
Requirements: Docker Desktop with Linux containers, Go, Windows FFmpeg/ffprobe, and the checkout containing this feature. From the repository root in PowerShell:
# Once, if .env does not already exist; this contains disposable test secrets.
if (-not (Test-Path .\.env)) { Copy-Item .\.env.pr-test.example .\.env }
New-Item -ItemType Directory -Force .\bin, .\.pr-test\music | Out-Null
Push-Location .\packages\sidecar
try {
go build -o ..\..\bin\sidecar.exe .
if ($LASTEXITCODE -ne 0) { throw "Sidecar build failed" }
} finally { Pop-Location }
$secretLine = Get-Content -LiteralPath .\.env |
Where-Object { $_ -match '^\s*SIDECAR_SECRET\s*=' } |
Select-Object -Last 1
if (-not $secretLine) { throw "SIDECAR_SECRET is MISSING in .env" }
$env:SIDECAR_SECRET = ($secretLine -split '=', 2)[1].Trim().Trim('"').Trim("'")
if (-not $env:SIDECAR_SECRET) { throw "SIDECAR_SECRET is MISSING in .env" }
Remove-Variable secretLine
$env:SIDECAR_PORT = "9800"
$env:FFMPEG_PATH = (Get-Command ffmpeg -ErrorAction Stop).Source
$env:FFPROBE_PATH = (Get-Command ffprobe -ErrorAction Stop).Source
$env:MUSIC_DIR = (Resolve-Path .\.pr-test\music).Path
$env:WEBRTC_UDP_PORT = "10000"
$env:WEBRTC_NAT1TO1_IP = "127.0.0.1" # Add reachable LAN/Tailscale IPv4 for TeamSpeak.
.\bin\sidecar.exe
Keep this terminal running. In a second PowerShell window at the repository root:
docker compose -f docker-compose.pr-test.windows-amf.yml up --build -d
Invoke-RestMethod http://localhost:9800/health
docker exec ts6-pr-backend curl -fsS http://host.docker.internal:9800/health
Open http://localhost:3000/setup, create an admin and log in. The bundled TeamSpeak connection is seeded as in the normal PR test. Under Media Library → Streaming defaults, run Check encoders, then select H.264 (AMF) or Auto with hardware preference. Test a downloaded video and a file copied into .pr-test/music; the backend sees /data/music while the native sidecar sees the Windows directory. Use a reachable advertised IPv4 and the restricted UDP firewall allowance described above when testing TeamSpeak viewing. All Docker published ports in this harness bind 127.0.0.1; no Docker service publishes UDP 10000 or HTTP 9800.
Stop the stack with docker compose -f docker-compose.pr-test.windows-amf.yml down, then stop the native sidecar with Ctrl+C. Downloaded/local media in .pr-test/music persists independently of Docker named volumes.
Source type and stream health¶
Every stream has a source type:
| Type | Used for | Behaviour |
|---|---|---|
| Live | IPTV channels (default), live URLs | never loops; if it stops, the stream stops as source unreachable |
| On demand | remote videos | paced playback; stops as source ended when it finishes |
| Local file | files under the music directory, downloaded clips | paced; admin backgrounds loop |
Detect (the default for URLs) uses the Auto-quality probe: a source without a duration is live. The URL itself (for example .m3u8) is never used to guess, because IPTV providers often use opaque URLs. With a fixed preset there is no probe, so a URL is treated as on demand unless you pick Live.
While a stream runs, the backend samples the sidecar's encode stats every 10 seconds (in-memory counters, not a diagnostic probe). The stream panel and Bot Hub show the source type and encode speed (for example 1.01x · 30 fps). If encoding stays below 0.9x for 20 seconds after a 15-second startup grace, a warning names the speed, dropped packets, preset, encoder and source type — for example Encoding below realtime (0.62x for 40 s) at 1080p with VP8 (software) from a live source. Use a lower preset or a hardware encoder.
Adaptive Auto quality¶
A stream started with Auto quality follows what the host can encode. It uses the same encode stats as the warning above, and only those: there is no measurement of viewers' connections, and the encoder and codec never change.
- Step down. When encoding has stayed below 0.9x for 30 seconds, the stream moves to the next preset down (1080p → 720p → 480p).
- Step up. When encoding has held at 0.97x or better for 2 minutes without a break, the stream moves one preset back up.
- Limit. Auto never goes above the preset it started the source at, which is itself never above the Auto limit. Each new source (a switch, or the next queued video) starts again from Auto's own choice.
- No flapping. Two changes are at least 1 minute apart. Speeds between 0.9x and 0.97x change nothing. Encode speed is capped at realtime, so the only way to learn whether a higher preset now fits is to try it; if that step up fails, because encoding falls behind again or the encoder does not start at the higher preset, the next attempt waits twice as long (4 minutes, then 8, up to 30). A step up that holds for 2 minutes clears the back-off.
- Fixed presets (480p … 2160p) are never changed. Pick one when a stream must stay at one resolution.
A change restarts ffmpeg, so viewers see a short interruption, as they do after a volume change. An on-demand video or local file resumes from where it was. A live source rejoins at the live edge. A video in its last 15 seconds is left alone. If the encoder does not start at the new preset, the stream goes back to the preset that was running; if that fails too, the stream stops with encoder failure.
Resuming needs a sidecar from 1.11.0 or newer, which reports the playback position. Behind an older sidecar, Auto adapts live sources only and leaves on-demand video at its starting preset, because a restart would replay it from the beginning. The backend log says so once per source.
The Bot Hub and the console's Now playing card show the requested and the effective quality, for example Auto → 720p (reduced from 1080p), with the reason for the last change: Auto reduced quality to 720p: Encoding stayed below realtime (0.62x for 30 s) at 1080p · 3 min ago. The same line is written to the backend log. A full recovery stays on screen for 10 minutes.
A source that is itself slow (a stalling IPTV channel) also reads as encoding below realtime, so Auto may step down for it even though a lower preset does not help. It steps back up once the source recovers. Use a fixed preset for a source like that.
If ffmpeg stops on its own, the stream stops instead of showing a frozen picture, with a reason: source ended, source unreachable (network/HTTP errors, or a live source ending), or encoder failure.
Volume¶
The bot has one volume. !vol and the volume sliders in Bot Hub and the console all set it. Music and radio apply it on each PCM frame. Video and IPTV pass it to the sidecar as an ffmpeg volume filter, including streams started from the console's IPTV tab or !tv with no separate level. Changing it during a video or IPTV stream restarts the encoder once (on slider release, not on every drag step) so the new gain takes effect; the picture and audio drop for that restart.
Live pacing (issue #72)¶
Live inputs are read with -re like everything else. Measured on a 4-core host with the sidecar's 720p30 VP8 pipeline against live HLS (MPEG-TS) and CMAF (fMP4 with a moov repeated in every segment): -re held a steady ~1.01x at 30 fps, while reading without it burst to ~2x at startup (the buffered live-edge segments) before settling. The Found duplicated MOOV Atom. Skipped it messages from such CMAF sources were harmless in that test. Sustained ~0.5x therefore points at host encode capacity (or a provider-specific timestamp problem), which the health warning now makes visible. Set VIDEO_LIVE_PACING=source on the sidecar to let live sources set their own pace instead.
HTTP connections and HLS segments¶
Some IPTV providers stutter when FFmpeg reuses a connection for later HLS segments. FFmpeg normally reconnects when the hostname or port changes, but connection affinity, rotating edge addresses or unreliable keep-alive handling can still cause trouble. The reconnect flags retry connection failures; they do not prevent connection reuse.
The sidecar sends the standard Connection: close HTTP header for remote playback and probing by default. FFmpeg propagates it to HLS playlists, segments and redirects, so opaque addresses such as /get.php work without guessing the format or fetching the stream ahead of FFmpeg. HTTP servers close each response connection; the egress proxy also closes its corresponding upstream connection. HTTPS uses the same header inside the proxy's CONNECT tunnel. MPEG-TS and progressive MP4 inputs continue to work because no HLS-only demuxer option is added. Local files are unchanged.
Set these variables on the sidecar container or process. The supplied Docker Compose file forwards them from .env or the shell environment. They are process-wide; there is no per-channel setting.
| Variable | Default | Effect |
|---|---|---|
FFMPEG_HTTP_PERSISTENT |
auto |
auto and 0 send Connection: close for remote HTTP(S) inputs. 1 leaves FFmpeg's default connection behavior and custom headers unchanged. |
FFMPEG_EXTRA_INPUT_ARGS |
unset | Extra options before every remote input, including ffprobe. Custom headers are preserved; their Connection header is managed by FFMPEG_HTTP_PERSISTENT. Use options understood by both ffmpeg and ffprobe. HLS-only options such as -http_persistent can break MP4/MPEG-TS. Values containing -i or a bare scheme:// URL are ignored. |
FFMPEG_EXTRA_OUTPUT_ARGS |
unset | Extra options immediately before each RTP output. Same argument parsing and rejection rules. |
For a provider that benefits from keep-alive, set FFMPEG_HTTP_PERSISTENT=1. Extra arguments are split into arguments, never run as a shell; inside double quotes, \r, \n and \t expand for HTTP header values.
Example, in the shell used to start the sidecar or Docker Compose:
This addresses connection reuse, not every cause of IPTV stutter. Verify sustained playback against the affected provider before treating a channel-specific report as resolved.
One media session at a time¶
- A bot plays music or video, never both.
- Only one video stream runs at a time across all bots, because they share the media sidecar.
Starting something that would replace what is playing asks for confirmation first ("Replace what is playing?"), listing exactly what will stop. The server only replaces the sessions you confirmed, so double clicks, two admins, or a chat command racing a UI click cannot silently stop each other's media. Something that is still starting cannot be replaced — wait for it to finish, then try again.
Chat commands are explicit requests on one bot: !play on a bot that is streaming video stops that bot's stream, and !stream / !tv stop that bot's music. A chat command never stops another bot's stream.
The stop reason says what happened, for example Replaced by music or Replaced by a stream on Bravo.
When TeamSpeak refuses or throttles the bot¶
- If TeamSpeak refuses to start a stream, the start fails at once with the server's reason, for example TeamSpeak refused the stream: insufficient client permissions (error 2568). It no longer waits out a silent 10-second timeout.
- If the server's anti-flood protection blocks the bot (error 524, client is flooding), the bot stops sending chat replies and ignores chat commands for 30 seconds. Each further 524 restarts the 30 seconds, because every command sent while blocked extends the block. Once the hold ends, the bot says once in the channel that commands came in too fast. To exempt the bot entirely, grant its identity
b_client_ignore_antifloodin TeamSpeak. - A bot that TeamSpeak turns away because the server is full, the server password is wrong or the bot is banned stops at once with that reason, instead of retrying.
Stopping and stop reasons¶
A stream stops on its own when:
- nobody watches it — no TeamSpeak client has had it open for the no-viewer timeout (default 5 minutes; Off, 1, 5, 10, 30 minutes or custom). While it counts down, Now playing shows auto-stop in m:ss. The browser preview does not count as a viewer. Each stream can override the timeout without changing the saved default;
- the bot's channel is empty for
BOT_AUTO_STOP_EMPTY_SECONDS(separate setting; default 300 seconds;0disables, including bots created in the UI). A video stream with at least one TeamSpeak viewer is not treated as empty for this timer; the no-viewer timeout still applies when nobody watches; - a downloaded clip ends.
After a stream stops, Now playing shows the last reason, for example Last stream: Stopped after 5 minutes with no viewers · 8 min ago.
With Announce auto-stops in chat enabled in Media Library → Streaming defaults (the default), the bot posts Stopped the stream: nobody watched for 5 minutes. when the no-viewer timer stops a stream, or Stopped the stream: the channel was empty for 5 minutes. when the channel-empty timer stops it. When the configured no-viewer timeout is longer than one minute, the bot also posts Nobody is watching. The stream stops in 1 minute. one minute before stopping; the pending warning is cancelled when a viewer joins. No warning is scheduled for a timeout of 60 seconds or less. Turn the switch off and press Save defaults to disable both the notices and the warning for the next stream; the timers still stop media. Video and IPTV keep the notice setting saved when they start. The same switch controls channel-empty notices for music and radio. The existing TeamSpeak flood hold applies to these messages.
IPTV playlists¶
The IPTV page manages M3U/M3U8 playlist sources for the selected server. Administrators can add a source as either a Playlist URL or an Upload file (.m3u, .m3u8, or .txt with valid M3U content), then refresh, replace (uploads), or delete it. Browse or search its parsed channels and filter by group. Stream on… lets you choose a bot on that server and opens its console with the channel selected. It does not start the stream; start the bot if needed, choose the video options, then press Stream. Stop it from Now playing → Stop stream.
Groups, search, filters, favourites and recent channels¶
The console's IPTV tab brings together channels from every playlist on the selected server. Choose Browse groups to open a group and see its channels, or use Search channels to search by channel name. Playlist defaults to All playlists; select one to narrow the list. Filter groups narrows the group browser, and All groups returns from a group's channels. Groups and channel lists offer 25 / 50 / 100 per page, remembered for each list.
Star a channel to add it to Favourites. Recent shows the last 20 successfully started channels, newest first. Both lists are shared by all bots and administrators on the same server, persist across playlist refreshes when the channel can still be matched, and support playlist and channel-name filtering. The tab opens Favourites when there are saved favourites, otherwise Browse groups. If a saved channel disappears from its playlist, it shows No longer in this playlist with Remove instead of a Stream button.
When channels include tvg-country or tvg-language, Country and Language list the codes found on any playlist for that server. They stay hidden when no playlist has those tags. A channel tagged with several codes, split on ; or ,, matches each one. In Browse groups, the filters combine with Playlist, group and search. In Favourites and Recent, they combine with Playlist and search. All countries and All languages clear them, and a selection returns to all if that code is no longer present. Existing playlists gain the tags on their next refresh.
Opening an IPTV link preselects its channel without starting media. If the channel has disappeared, the console shows That channel is no longer in the playlist. IPTV starts default to Live; quality, encoder and the no-viewer timeout can be changed for that start, and the auto-stop notices above apply to IPTV too.
URL vs uploaded source¶
| Source | Refresh | Auto-refresh | Storage |
|---|---|---|---|
| Playlist URL | Re-fetches over HTTP(S) | Optional (minutes) | URL only in the database |
| Uploaded file | Re-reads/re-parses the stored file | Off by default (file does not change on its own) | File under backend data/iptv/ + metadata in the database |
Uploaded sources are stored as application assets on the backend data volume (not TeamSpeak channel file storage). A full restore of uploaded playlists needs both the database and the backend-data volume. XMLTV/EPG upload, Xtream credential forms, and source export remain separate follow-ups.
Playlists and channels on your local network¶
For safety, ts6-manager refuses links to private addresses (192.168.x.x, 10.x.x.x and so on) and shared addresses (100.64.0.0/10, including Tailscale addresses), so a pasted link cannot make the server reach devices on your network. That also blocks an IPTV proxy running at home, such as Threadfin, xTeVe, TVHeadend or a router's IPTV service, until an admin allows its host.
Admins allow those hosts from the IPTV page header: Local hosts (administrators only) opens the allowlist dialog. The button shows a count when the list is not empty, and an empty playlist page hints at the same dialog. Enter one per line: an IP (192.168.1.20), a range (192.168.1.0/24) or a hostname (threadfin.lan).
- The allowance covers IPTV only: playlist refreshes, channels started from the console's IPTV tab, and
!tv <name>. With!tv, users pick a channel name from your playlist, never a URL. - Links typed in chat (
!stream,!play), the console's Link tab and flow HTTP nodes stay blocked from private addresses. - Loopback (
127.0.0.1), link-local and cloud metadata addresses (169.254.169.254,100.100.100.200,fd00:ec2::254) can never be allowed, even through a hostname or range. Inside a container, loopback is the container itself, so use the host's LAN address instead. - Each redirect of a playlist URL is checked again, so a playlist refresh cannot be redirected away from the allowed hosts.
- Streams get the same rules at every step. The sidecar sends each connection its ffmpeg makes (redirects, HLS playlists and segments, https) through a local checking proxy, which refuses private addresses not on this list and always refuses loopback, link-local and metadata addresses. The Auto quality probe of a URL runs in the sidecar through the same checks. A refused connection appears in the sidecar log as
[Egress] Blocked connectionwith the host name only. - The list is empty by default, and changing it is recorded in the audit log.
Architecture¶
The backend coordinates media preparation and session state. The Go sidecar handles the WebRTC/media relay.
In the standard split-stack compose file:
- the sidecar listens on port 9800 inside the Docker network;
- port 9800 is not published to the host;
- browser WebRTC media uses a separate UDP path (not the HTTP sidecar port);
- set
WEBRTC_UDP_PORTplus an IPv4WEBRTC_NAT1TO1_IP(address advertised to the browser) and publish that UDP port withWEBRTC_BIND_IP(Docker host bind) when the browser is outside the Docker network —docker-compose.pr-test.ymlenables UDP10000on127.0.0.1with advertise IP127.0.0.1for same-host browsers; for LAN/Tailscale clients advertise that reachable IPv4; for public-NAT clients advertise the public IPv4 and forward UDP to the host (bind may stay on a local host address); - TeamSpeak viewers are offered the same addresses. The TeamSpeak client does not connect to
127.0.0.1, even on the Docker host, so to watch a stream in TeamSpeak add the host's LAN or Tailscale IPv4 toWEBRTC_NAT1TO1_IP(comma-separated, for example127.0.0.1,192.168.1.20) and publish the UDP port on it (see Troubleshooting); - backend-to-sidecar mutating requests use
SIDECAR_SECRET; and - the backend and sidecar share the media volume.
The all-in-one image keeps the backend and sidecar on loopback behind nginx. For browser preview from outside that container, publish the same WebRTC UDP mux port and set WEBRTC_NAT1TO1_IP (see commented mappings in docker-compose.all-in-one.yml).
Synchronization¶
The sidecar uses RTCP Sender Reports and adaptive pacing controls for A/V synchronization. Environment variables allow limited tuning of playout buffering, bias, queue sizes, bitrate, and encoder behavior.
Live IPTV timestamps are often discontinuous (PCR breaks, HLS segment edges, non-monotonic DTS). The live ffmpeg command adds igndts so those frames are not dropped, and aresample=async=1000 so Opus stays on a continuous clock. If an RTP timestamp still jumps by more than a second, or steps backwards, the sidecar rebases that track instead of holding playout at the maximum sync delay — a hold that otherwise sounds like the audio cutting out. On-demand files and VOD do not get the live audio filters.
See Environment variables for the available sidecar settings.
Operational notes¶
Do not expose the sidecar directly to the public network.
If a stream does not start, check:
- the backend can reach
SIDECAR_URL, and the sidecar image is the same release as the backend (an older sidecar ignores encoder selection and always sends VP8 — the stream panel says so); - backend and sidecar use the same
SIDECAR_SECRET; - both processes see the same media files under their own
MUSIC_DIR(portable local-video references allow different Linux/Windows paths; legacy absolute references need matching paths); and - the source URL is still available to yt-dlp/FFmpeg.
Use the Runtime / media strip in Media Library → Streaming defaults or beside the IPTV channel browser (Refresh) for a bounded on-demand sidecar and tool probe. Routine music-bot status polling does not call the sidecar health endpoint.
Admins can open System → Diagnostics for a combined media toolchain report. It shows tool versions and executable paths, checks FFmpeg and ffprobe, decodes a short synthetic audio input, encodes one silent Opus frame, lists yt-dlp extractors locally, checks Deno, and reads sidecar health and encoder capabilities. It runs once on page entry and again only with Refresh; focus, reconnect, and routine status polling do not rerun it. Copy diagnostic report copies the results with credential redaction for troubleshooting.
The checks do not download media, install tools, update binaries, or start playback. Missing tools in containers require pulling or rebuilding the image. Encoder results reuse the sidecar cache; its first request may run short test encodes. Use Streaming defaults → Check encoders to refresh that cache. Unavailable hardware encoders are normal on hosts without a GPU. A native sidecar that starts with video playback can show a warning while idle; its version appears only when its health response includes one.
See Troubleshooting for common deployment checks.
