Skip to content

Stream Recording and Livestreaming

mrlt8 edited this page Jul 22, 2024 · 2 revisions

Recording

The bridge can be configured to record all or select camera streams to the container which can be mapped to a local directory.

Enable recording

environment:
...
  - TZ=America/New_York
  - RECORD_ALL=True
volumes:
  - /local/path/:/record/

Or to specify select cameras, where CAM_NAME is the camera name in UPPERCASE and _ in place of spaces and hyphens:

  - RECORD_CAM_NAME=True
  - RECORD_OTHER_CAM=True

Recording configuration

  • Recording location:

    You can specify the directory where the videos will be saved by mapping your /local/path/on/host/ to the /record/ directory in the container:

    volumes:
          - /local/path/on/host/:/record/
  • File name:

    You can configure the path where the clips will be saved using RECORD_PATH. Available variables are %path or {cam_name}, %Y %m %d %H %M %S %f %s (time in strftime format). The camera name is also available as {cam_name} for lowercase and {CAM_NAME} for uppercase.

    environment:
      - RECORD_PATH=/record/{cam_name}_%Y-%m-%d_%H-%M-%S

    This would record to: /record/my-cam_2024-01-01_09-42-12.mp4

    You can optionally configure the name of the file:

    - RECORD_PATH=/record/{cam_name}/%Y-%m-%d
    - RECORD_FILE_NAME={cam_name}_%H_%M_%S

    This would record to: /record/my-cam/2024-01-01/my-cam_09-42-12.mp4

    The timezone used for the name can be configured using TZ database name:

    environment:
      - TZ=America/New_York
  • File segment length:

    The bridge will split the recordings into 60 second clips. You can use s for seconds , h for hours.

    environment:
      - RECORD_LENGTH=300s
  • Delete old recordings:

    Use s for seconds , h for hours. Set to 0s to disable automatic deletion. Defaults to 0s

    environment:
    - RECORD_KEEP=24h

Livestreaming

Basic livestream support is available for YouTube and Facebook, but you can also specify any custom rtmp server for other services like Twitch.

To use this feature, set a new env in your docker-compose.yml with the service (YOUTUBE_ or FACEBOOK_) prefix followed by the camera name in UPPERCASE with _ in place of spaces and hyphens, and set your stream key as the value. Custom rtmp servers can be specified using the LIVESTREAM_ prefix:

  - YOUTUBE_FRONT_DOOR=MY-STREAM-KEY
  - FACEBOOK_OTHER_CAM=MY-STREAM-KEY
  # twitch example:
  - LIVESTREAM_CAM_NAME=rtmp://jfk.contribute.live-video.net/app/MY-STREAM-KEY

🏠 Home Assistant - Use CAM_OPTIONS and add a new entry for each camera:

- CAM_NAME: Cam Name
  LIVESTREAM: rtmp://jfk.contribute.live-video.net/app/MY-STREAM-KEY
- CAM_NAME: other cam
  LIVESTREAM: rtmp://a.rtmp.youtube.com/live2/my-youtube-key