Skip to content

Plex Live TV: improve tuner reliability and session management #1

Description

@trevor-viljoen

Current state

The /api/iptv/live/{identifier} endpoint streams raw MPEG-TS via ffmpeg -c copy -f mpegts pipe:1, which makes us a valid HDHomeRun emulator for Plex. Plex Live TV is working for most channels.

Known gaps / improvements needed

Session deduplication

Each request to /live/{identifier} spawns a new state.start_stream() session and a new FFmpeg process. Plex probes and retries the URL multiple times (especially on slow connections / hotspot). This can exhaust Tablo tuner slots. We should deduplicate: if a session for identifier is already active, reuse it rather than opening a second one.

FFmpeg process lifecycle

The FFmpeg subprocess is killed only when the HTTP streaming generator finishes (client disconnects). If Plex drops and reconnects quickly, the old process may not be dead yet. Add a small cleanup grace period or track live FFmpeg PIDs per identifier.

Tuner count accuracy

/discover.json reads tuner count from /server/info. Verify this matches the actual Tablo model tuner count (2 vs 4) and that we don't report more tuners than the device supports.

Latency on first tune

On slow connections (hotspot, WAN), Plex's initial connect times out before FFmpeg opens the Tablo HLS stream (~2–3s). Consider pre-opening the Tablo stream before returning 200, or lowering the FFmpeg startup buffer.

HDHomeRun lineup.json channel numbers

OTT/streaming channels have no major/minor numbers. They fall back to call_sign as the guide number. Plex may not match these to EPG entries correctly. Investigate whether a synthetic major.minor assignment would help.

Acceptance criteria

  • No duplicate Tablo sessions when Plex probes the same channel URL multiple times
  • Tuner count matches actual device capability
  • First-tune latency <3 s on LAN
  • OTT channels appear correctly in Plex guide with EPG data

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions