project-management-only/home-tv-station#11: Dynamic Publishing



Issue Information

Issue Type: issue
Status: closed
Reported By: btasker
Assigned To: btasker

Milestone: v0.2
Created: 04-Aug-24 08:51



Description

At the moment, the container comes up and sits publishing media.

Strictly speaking, that's not the most efficient thing to do.

What I'd quite like, assuming that we can get it to work is:

  • Stand up a small HTTP server (python?)
  • Have the nginx-rtmp on-play hook(s) call it when a subscriber connects
  • Have the HTTP server do something to trigger playback
  • When the last subscriber disconnects, we should block publishing of new media (but let the current playback finish, in case they reconnect)


Toggle State Changes

Activity


assigned to @btasker

At it's simplest, this could be a small Flask script which touches a file on disk. stream_video.sh would then check for existence of that file.

If the file exists, rather than playing media, it'd need to loop checking periodically (I guess it'd have to be once a second - we don't want to introduce too long a startup delay).

Because there'd be a delay, we probably need to look at tuning the HLS settings to help minimise the impact

Looks like the container already has python in, so it probably makes as much sense to use that over anything else.

verified

mentioned in commit github-mirror/Home-TV-Station@803ae1bd69c75ed16cde991c63fadaa0c3edddc5

Commit: github-mirror/Home-TV-Station@803ae1bd69c75ed16cde991c63fadaa0c3edddc5 
Author: B Tasker                            
                            
Date: 2024-08-04T11:07:41.000+01:00 

Message

feat: cobble together a small control server for playback hooks (project-management-only/home-tv-station#11)

+61 -1 (62 lines changed)
verified

mentioned in commit github-mirror/Home-TV-Station@d5a03f9bff9516ce4edba0c2f4e5d8778c40a1ce

Commit: github-mirror/Home-TV-Station@d5a03f9bff9516ce4edba0c2f4e5d8778c40a1ce 
Author: B Tasker                            
                            
Date: 2024-08-04T11:42:47.000+01:00 

Message

feat: implement control process so publishing only triggers if there are subscribers (project-management-only/home-tv-station#11)

+68 -1 (69 lines changed)

The logic for this is now in place, but disabled by default.

To enable, set CONTROL_FILES_ENABLED to true.

Then:

  • the ffmpeg publishing will not begin unless there's at least one subscriber connected
  • When the subscriber disconnects, the stream will continue, but the next will not start until a a subscriber connects.

However, this can only ever work with RTMP. There isn't a callback available for HLS playback, so it's not possible to do the same.

Under the hood, the control stack writes files into /tmp/control to track state and player count.