Simple PHP hackjob to automatically record live streams from Restreamer. It is copying the HLS output with FFmpeg when the Restreamer instance report type connected.
Go to file
Sándor abb80b89af Initial commit 2021-05-21 03:35:51 +02:00
README Initial commit 2021-05-21 03:35:51 +02:00
config.example.json Initial commit 2021-05-21 03:35:51 +02:00
record.php Initial commit 2021-05-21 03:35:51 +02:00

README

With this utility it is possible to record live streams that is available through a Restreamer instance.
This monitors the Restreamer API to check if the local repeater is connected. When it is, it probes the 
HLS endpoint and depending on the HTTP Code in the response it starts an FFmpeg process that copies the 
HLS output to a specified location on the filesystem. Then it can be played back.
It is also possible to provide a "rewindable" live stream, but keep in mind that it will introduce big 
latency.

To set this up, clone this repository and move or copy config.example.json to config.json, then edit it.
Then, run the following command to start monitoring and recording streams: php -q /path/to/record.php

Create a cronjob or systemd service to make it run on boot and handle potential failures/exits.
Example cronjob: * * * * * flock -n /tmp/hls-recorder-flock -c "php -q /path/to/record.php" &