Skip to content

Record Live Stream

Daniel Neto edited this page Feb 26, 2025 · 37 revisions

How to Record Your Live Stream and Send It to the Encoder

Requirements

To follow this tutorial, ensure you have:

  1. The SendRecordedToEncoder plugin installed and enabled.
  2. Streamer and Nginx Live Stream Server running on the same server.
  3. If Streamer and Nginx are on separate servers, configure getRecordedFile.php accordingly.

Step 1: Update Your Streamer and Encoder

Make sure your Streamer and Encoder are up to date. Follow this tutorial if you are unsure how to update them.

Step 2: Create a Directory for Recorded Streams

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

Step 3: Modify the Nginx Configuration

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.

Step 4: Restart Nginx

Restart Nginx to apply the changes:

sudo /usr/local/nginx/sbin/nginx -s stop && sudo /usr/local/nginx/sbin/nginx

Step 5: Enable the Plugin

Go to your plugin menu and enable the SendRecordedToEncoder plugin.

How to Start Recording

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.

Plugin Configuration Options

Convert Chat Into Comments After Live (convertChatIntoCommentsAfterLive)

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.

Automatic Record Modes (automaticRecord)

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.

Save DVR (saveDVREnable)

  • 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.

Save The Moment (saveTheMomentEnable)

  • 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: If hls_fragment=4s and Segments Count=6, the plugin will save 24 seconds.

Download The Moment (downloadTheMomentEnable)

  • 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.

Max Saves Per Minute (maxSavesPerMinute)

Limits how many times a user can save or download a moment per minute. Set to 0 for unlimited saves.

Start Recorder Callback (startRecorderCallback)

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"}

DVR Configuration

hls_playlist_length

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.

hls_fragment

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.

Plugin Segment Count Settings

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.

Clone this wiki locally