-
Notifications
You must be signed in to change notification settings - Fork 984
Record Live Stream
To follow this tutorial, ensure you have:
- The SendRecordedToEncoder plugin installed and enabled.
- Streamer and Nginx Live Stream Server running on the same server.
- If Streamer and Nginx are on separate servers, configure
getRecordedFile.php
accordingly.
Make sure your Streamer and Encoder are up to date. Follow this tutorial if you are unsure how to update them.
Create a directory where your recorded streams will be stored and grant Apache and Nginx permission to write to it. Ensure this path matches the record_path
parameter in your Nginx configuration.
Example:
sudo mkdir /var/www/tmp && sudo chmod 777 /var/www/tmp
Edit your nginx.conf file:
sudo nano /usr/local/nginx/conf/nginx.conf
Add the following lines:
recorder video{
record all manual;
record_path /var/www/tmp;
record_notify on;
record_max_size 2048M;
record_suffix -%d-%b-%y-%T.flv;
}
Ensure your RTMP section looks like this:
rtmp {
server {
listen 1935;
allow play all;
application live {
allow play all;
live on;
hls on;
hls_nested on;
hls_path /HLS/live;
hls_fragment 10s;
on_publish http://your-server-url/plugin/Live/on_publish.php;
on_publish_done http://your-server-url/plugin/Live/on_publish_done.php;
on_play http://your-server-url/plugin/Live/on_play.php;
on_record_done http://your-server-url/plugin/Live/on_record_done.php;
recorder video{
record all manual;
record_path /var/www/tmp;
record_notify on;
record_max_size 2048M;
record_suffix -%d-%b-%y-%T.flv;
}
}
}
}
Note: Ensure the
on_record_done
directive correctly points to the Live Stream Plugin.
Restart Nginx to apply the changes:
sudo /usr/local/nginx/sbin/nginx -s stop && sudo /usr/local/nginx/sbin/nginx
Go to your plugin menu and enable the SendRecordedToEncoder plugin.
You can manually trigger the recording using the following URL:
{$global['webSiteRootURL']}plugin/SendRecordedToEncoder/recordStart.json.php?key={live key/name}
If you are an admin or the video owner, the recording will start immediately. If triggered from a third-party app, you may need to validate it with the Start Recorder Callback.
This option allows you to convert the live chat into comments once the stream ends. If enabled, chat messages during the stream will be automatically transferred and displayed as comments on the recorded video, preserving audience interaction.
The plugin provides different automatic recording modes:
- Save All Lives: All live streams are recorded automatically.
- All Users Can Record: Allows any user to trigger a recording.
- Only Selected Users: Restricts recording to specific users.
- Enable Save DVR: When enabled, this saves the DVR (Digital Video Recorder) version of the live stream.
-
Save DVR Label (
saveDVRLabel
): The label displayed in the user interface. -
Save DVR On DVR Title (
saveDVROnDVRTitle
): The title displayed when DVR is enabled.
- Enable Save The Moment: Allows users to save a portion of their live stream.
-
Save The Moment Segments Count (
saveTheMomentSegmentsCount
): Defines the number of segments to save. Example: Ifhls_fragment=4s
andSegments Count=6
, the plugin will save 24 seconds.
- Enable Download The Moment: Allows users to download a portion of their live stream.
-
Download The Moment Segments Count (
downloadTheMomentSegmentsCount
): Defines the number of segments to download.
Limits how many times a user can save or download a moment per minute. Set to 0
for unlimited saves.
This URL validates recording requests and responds with a JSON:
- If the request is denied:
{"error":true, "msg":"error message"}
- If the request is approved:
{"error":false, "msg":"message", "recordLimit":3600, "username":"admin", "password":"123"}
Defines how much of the live stream is available for DVR. Example:
hls_playlist_length 60m;
This keeps 60 minutes of DVR saved on the server.
Determines the length of each HLS segment. A smaller value reduces latency but increases load. Example:
hls_fragment 5s;
This means each segment is 5 seconds long.
The segment count affects how much of the live stream is saved:
- Example:
hls_fragment 5s;
Save The Moment Segments Count = 4
When clicking "Save", the last 4 segments (5s each) are saved, creating a 20-second MP4 file.
By following this guide, you can successfully record live streams and manage recordings using the SendRecordedToEncoder plugin.