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
2022-06-22 09:09:14 +02:00
.gitignore Added sleep to config 2021-05-21 15:55:31 +02:00
config.example.json added new parameters 2021-05-28 10:33:18 +02:00
README Update 'README' 2021-05-28 10:46:27 +02:00
record.php small facelift 2022-06-22 09:09:14 +02:00

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 OR RTMP stream 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" &