The channel card shows everyone watching: each Emby and Jellyfin session on the channel, and the readers polling it #58

Closed
opened 2026-10-30 20:02:25 -04:00 by cmoriarty · 2 comments
Owner

What happened (2026-10-30, UCF vs. Baylor)

Two people watched the same channel at once: the living-room Shield on the LAN, and a remote user on an Apple TV. The Admin card showed one viewer: Emby, 192.168.1.104, VLC/3.0.21.

  • Emby opened a separate reader for each session. Two of its ffmpeg processes polled the channel, both from 192.168.1.104 with the same VLC/3.0.21 agent, each on its own connections. Each made about 30 playlist and 30 segment requests in two minutes. The channel pulled the source once and served both from one timeline.
  • Emby's Sessions API names both sessions: the user, the device and client, local or remote, the play method, and the transcode reasons.
    • Shield: video copied, audio transcoded.
    • Apple TV: a full transcode to 4 Mbps (ContainerBitrateExceedsLimit).
  • Both sessions match the channel exactly. Each session's NowPlayingItem carries ChannelNumber 60, the game's tvg-chno (#42).

Why the card shows one

  • Channel.playlist() keeps only the last poll's address and agent (viewer_ip, viewer_agent), and every poll overwrites them.
  • Both readers have the same address and agent, so even keeping every distinct pair would show one viewer.

Proposed change

  • Read the media servers' own sessions.
    • The app already holds each server's URL and key for the guide refresh.
    • While a channel is playing, read Emby's and Jellyfin's /Sessions every 10 s or so. Keep the sessions whose NowPlayingItem.ChannelNumber is the game's channel number.
    • For each session, keep the user, the device and client, local or remote (not the address), the play method (direct, video copied, or full transcode) with its reasons and bitrate, and since when.
  • Count the readers the servers don't account for. Count the distinct readers that polled the channel in the last 10 s, by connection. The page's player, the recorder or an unknown ffmpeg then show up too, and a server's readers can be checked against its sessions.
  • Show it on the card: a viewer count on the channel row, with the list behind it.
  • Flag a full transcode. It is the session that a splice changing the stream's shape ends (#39).

Done when

  • Two sessions on one channel show as two viewers on the card, each with its user, device, local or remote, and play method.
  • A reader with no session shows as an unnamed reader.
  • A session that stops leaves the card within 15 s.
  • A media server that doesn't answer leaves the card with the reader count only.
  • Tests use fake Emby and Jellyfin Sessions answers, and reuse the guide refresh's settings.

Related: #42 (channel numbers), #45 (the Admin redesign), #39 (a splice keeps the stream's shape).

## What happened (2026-10-30, UCF vs. Baylor) Two people watched the same channel at once: the living-room Shield on the LAN, and a remote user on an Apple TV. The Admin card showed one viewer: Emby, 192.168.1.104, `VLC/3.0.21`. - **Emby opened a separate reader for each session.** Two of its ffmpeg processes polled the channel, both from 192.168.1.104 with the same `VLC/3.0.21` agent, each on its own connections. Each made about 30 playlist and 30 segment requests in two minutes. The channel pulled the source once and served both from one timeline. - **Emby's Sessions API names both sessions:** the user, the device and client, local or remote, the play method, and the transcode reasons. - Shield: video copied, audio transcoded. - Apple TV: a full transcode to 4 Mbps (`ContainerBitrateExceedsLimit`). - **Both sessions match the channel exactly.** Each session's `NowPlayingItem` carries `ChannelNumber` 60, the game's `tvg-chno` (#42). ## Why the card shows one - `Channel.playlist()` keeps only the last poll's address and agent (`viewer_ip`, `viewer_agent`), and every poll overwrites them. - Both readers have the same address and agent, so even keeping every distinct pair would show one viewer. ## Proposed change - **Read the media servers' own sessions.** - The app already holds each server's URL and key for the guide refresh. - While a channel is playing, read Emby's and Jellyfin's `/Sessions` every 10 s or so. Keep the sessions whose `NowPlayingItem.ChannelNumber` is the game's channel number. - For each session, keep the user, the device and client, local or remote (not the address), the play method (direct, video copied, or full transcode) with its reasons and bitrate, and since when. - **Count the readers the servers don't account for.** Count the distinct readers that polled the channel in the last 10 s, by connection. The page's player, the recorder or an unknown ffmpeg then show up too, and a server's readers can be checked against its sessions. - **Show it on the card:** a viewer count on the channel row, with the list behind it. - **Flag a full transcode.** It is the session that a splice changing the stream's shape ends (#39). ## Done when - Two sessions on one channel show as two viewers on the card, each with its user, device, local or remote, and play method. - A reader with no session shows as an unnamed reader. - A session that stops leaves the card within 15 s. - A media server that doesn't answer leaves the card with the reader count only. - Tests use fake Emby and Jellyfin Sessions answers, and reuse the guide refresh's settings. Related: #42 (channel numbers), #45 (the Admin redesign), #39 (a splice keeps the stream's shape).
Author
Owner

Deployed 2026-10-31 (PR #60). Left open until a real session is seen.

Seen live:

  • The app reads Emby's and Jellyfin's /Sessions while a channel plays, with no errors.
  • The card counts the readers polling the channel. My test readers showed up as unnamed readers.

Not seen yet: a real Emby or Jellyfin session on a playing channel's card, because no one watched through either server during the runs.

Done when: the next time a game is watched in Emby or Jellyfin, the card shows each session with its user, device, local or remote, and play method.

**Deployed 2026-10-31 (PR #60). Left open until a real session is seen.** **Seen live:** - The app reads Emby's and Jellyfin's `/Sessions` while a channel plays, with no errors. - The card counts the readers polling the channel. My test readers showed up as unnamed readers. **Not seen yet:** a real Emby or Jellyfin session on a playing channel's card, because no one watched through either server during the runs. **Done when:** the next time a game is watched in Emby or Jellyfin, the card shows each session with its user, device, local or remote, and play method.
Author
Owner

Closing: seen live on 2026-10-31. A real Emby session showed on a playing card.

Chelsea vs. Man Utd, played from Emby on the living-room Shield:

  • The card's header: "Emby · 2 s ago" and a viewer count of 1.
  • The Watching popover: emby · Shield Living Room · local · direct.
  • The admin API: one session (server Emby, client Emby for Android, local, direct play, no transcode reasons) and no unnamed readers. The one reader polling the channel was matched to that session, not counted twice.
Closing: seen live on 2026-10-31. A real Emby session showed on a playing card. **Chelsea vs. Man Utd, played from Emby on the living-room Shield:** - **The card's header:** "Emby · 2 s ago" and a viewer count of 1. - **The Watching popover:** emby · Shield Living Room · local · direct. - **The admin API:** one session (server Emby, client Emby for Android, local, direct play, no transcode reasons) and no unnamed readers. The one reader polling the channel was matched to that session, not counted twice.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
cmoriarty/sports-breaker#58
No description provided.