Skip to content

9. Archive Streams to Disk

9.1 Overview

The relay can archive streams to disk in real time. Archives are written inside the container to ARCHIVE_PATH; mount a host directory there so the files survive container removal.

9.2 Enable Archive

  1. Create a host directory and give it to the container's nginx user (UID 100, GID 101):

    mkdir -p stream_archive
    sudo chown 100:101 stream_archive
    
  2. In docker-compose.yml, add a volumes: entry to the existing relay service:

    services:
      relay:
        volumes:
          - ./stream_archive:/archive
    
  3. In env/relay.env, set ARCHIVE_PATH to the container side of that mount:

    ARCHIVE_PATH=/archive
    
  4. Recreate the container:

    docker compose up -d --force-recreate
    
  5. Confirm the service is enabled:

    docker compose logs relay | grep -iE "archive|error"
    

    Expected output: Archive configuration complete, and service enabled.

    If you see ERROR: ARCHIVE_PATH is not writable by the nginx user., the container has stopped: the relay does not run at all, not only archiving. Check that ARCHIVE_PATH matches the container side of the mount in step 2, and that step 1's chown succeeded.

9.3 Settings

ARCHIVE_PATH turns archiving on. For its default and valid values, see ARCHIVE_PATH. Archives are always FLV files.

9.4 File Naming

Each stream is written to a new file named:

<stream-name>-<unix-time>_<DDMMYYYY>_<HHMMSS>.flv

For example, a stream published as rtmp://<relay>/relay/live on 25 September 2026 at 14:53:40 UTC produces:

live-1790348020_25092026_145340.flv

The date and time are in UTC, not your local time zone. Because the date is day-first, sorting by filename does not sort by date across months; sort by the Unix time after the stream name instead, or by modification time (ls -t).

9.5 See Also