Skip to content

Advanced Option

mrlt8 edited this page Jun 13, 2023 · 9 revisions

The following are all optional.

Persistent Connection

The bridge will establish a connection with each camera as needed, and automatically disconnect when the client terminates the connection.

However, if there is a specific requirement to maintain a persistent connection with the cameras at all times, you can achieve this by setting the ON_DEMAND parameter to False. By doing so, the Bridge system will continuously maintain a connection with the cameras, regardless of client activity.

- ON_DEMAND=False

Please note that enabling a persistent connection may result in increased wifi activity and system resource usage.

Snapshot/Still Images

  • SNAPSHOT=API Will run ONCE at startup and will grab a high-quality thumbnail from the wyze api and save it to /img/cam-name.jpg on docker installs or /config/www/cam-name.jpg in Home Assistant mode.

  • SNAPSHOT=RTSP Will run every 180 seconds (configurable) and wll grab a new frame from the RTSP stream every iteration and save it to /img/cam-name.jpg on standard docker installs or /config/www/cam-name.jpg in Home Assistant mode. Can specify a custom interval with SNAPSHOT=RTSP(INT) e.g. SNAPSHOT=RTSP30 to run every 30 seconds

  • SNAPSHOT_FORMAT can be used in combination with SNAPSHOT to specify the output file to be used for snapshot. e.g. SNAPSHOT_FORMAT={cam_name}/%Y-%m-%d/%H-%M.jpg could be used to create a timelapse with the snapshots.

  • IMG_DIR=/img/ Specify the directory where the snapshots will be saved within the container. Use volumes in docker to map to an external directory.

  • IMG_TYPE Specify the file type of the image, e.g. IMG_TYPE=png. Will default to jpg.

Timelapse/Save multiple snapshots

SNAPSHOT_FORMAT can be used in combination with SNAPSHOT to save multiple snapshots which can be used to create a timelapse:

- SNAPSHOT=RTSP30
- SNAPSHOT_FORMAT={cam_name}/%Y-%m-%d/%H-%M-%S.jpg

MQTT Config

MQTT auth and discovery should be automatic in Home Assistant mode - can be disabled by setting MQTT_HOST to False.

ENV Name Description Example
MQTT_HOST IP/Hostname AND Port of the MQTT broker core-mosquitto:1883
MQTT_AUTH Username AND password; leave blank if none user:pass
MQTT_TOPIC Optional - Specify topic prefix myhome
MQTT_DTOPIC Optional - Discovery topic for home assistant homeassistant

See the Camera Commands page for available topics.

Custom FFmpeg Commands

You can pass a custom command to FFmpeg by using FFMPEG_CMD in your docker-compose.yml:

For all cameras

environment:
    ..
    - FFMPEG_CMD=-f h264 -i - -vcodec copy -f flv rtmp://rtsp-server:1935/{cam_name}

For a specific camera

where CAM_NAME is the camera name in UPPERCASE and _ in place of spaces and hyphens:

- FFMPEG_CMD_CAM_NAME=ffmpeg -f h264 -i - -vcodec copy -f flv rtmp://rtsp-server:1935/{cam_name}

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

- CAM_NAME: Cam Name
  FFMPEG: ffmpeg -f h264 -i - -vcodec copy -f flv rtmp://rtsp-server:1935/{cam_name}

Additional info:

  • The ffmpeg command is implied and is optional.
  • The camera name is available as a variable {cam_name} for lowercase and {CAM_NAME} for uppercase.
  • The audio pipe and format are available as the variable {audio_in}.

Custom FFmpeg Flags

Custom ffmpeg flags can easily be tested with:

environment:
    ..
    - FFMPEG_FLAGS=-fflags +flush_packets+genpts+discardcorrupt+nobuffer

or where CAM_NAME is the camera name in UPPERCASE and _ in place of spaces and hyphens:

- FFMPEG_FLAGS_CAM_NAME=-flags low_delay

MediaMTX

MediaMTX options can be customized as an environment variable in your docker-compose.yml by prefixing MTX_ to the UPPERCASE parameter.

e.g. use - MTX_RTSPADDRESS=:8555 to overwrite the default rtspAddress.

or - MTX_PATHS_ALL_READUSER=123 to customize a path specific option like paths: all: readuser:123

For camera specific options with spaces in the name of the camera (e.g. Front Door), be sure to replace the spaces with the URI_SEPARATOR which defaults to -. So Front Door would be represented as FRONT-DOOR, and paths: Front Door: runOnReady: ffmpeg... could be set in your docker-compose as:

environment:
  ...
  - MTX_PATHS_FRONT-DOOR_RUNONREADY=ffmpeg...
  • 🏠 For Home Assistant: Enter each customization into MEDIAMTX, e.g. use paths_all_readuser=123 for paths: all: readuser:123.

    UI config:

    paths_all_readuser=123
    

    YAML config:

    MEDIAMTX: 
      - paths_all_readuser=123

Offline camera IFTTT webhook

This option can send a trigger to IFTTT's webhooks integration when the camera is detected as being offline (-90).

Note:This is still experimental as the connection will sometimes just timeout a number of times before going "offline".

  - OFFLINE_IFTTT=MyEventName:my_IFTTT_Webhooks_Key

The bridge should then trigger your event with the following values:

{
  "value1" : "cam-name", // camera name
  "value2" : -90, // error no
  "value3" : "IOTC_ER_DEVICE_OFFLINE" // error name
}

Proxy stream from RTSP firmware

For cameras on official RTSP FW (4.19.x, 4.20.x, 4.28.x, 4.29.x, 4.61.x.) only.

The bridge can pull the credentials from the camera and proxy the stream over the bridge.

The secondary stream will be available with the -fw suffix e.g., cam-name-fw.

# Add cameras that have RTSP enabled in the app:
RTSP_FW=true
# or use force to turn on the rtsp stream:
RTSP_FW=force

Debugging options

environment options:

  • FRESH_DATA (bool) Remove local cache and pull new data from wyze servers.

  • LOG_LEVEL (debug|info|warning|error) Adjust the logging level.

  • LOG_TIME (bool) Add timestamps to the log output.

  • LOG_FILE (bool) Write log file to /logs/debug.log or /config/wyze-bridge/logs/ in Home Assistant.

  • URI_SEPARATOR (-|_|#) Customize the separator used to replace spaces in the URI; available values are -, _, or use # to remove spaces.

  • CONNECT_TIMEOUT (int) Adjust the number of seconds to wait before timing out when connecting to camera. Default: 15

  • IGNORE_OFFLINE (bool) Ignore offline cameras until container restarts.

  • OFFLINE_TIME (int) Customize the sleep time when a camera is offline. Default: 10

  • MTX_READTIMEOUT (str) Adjust the max number of seconds of missing frames allowed before a stream is restarted. Be sure to include the s after the number. Default: 20s

  • MTX_LOGLEVEL (debug|info|warn) Adjust the verbosity of rtsp-simple-server; available values are "warn", "info", "debug".

  • DEBUG_FFMPEG (bool) Enable additional logging from FFmpeg.

  • FORCE_FPS_CAM_NAME (int) Force a specific camera to use a different FPS, where CAM_NAME is the camera name in UPPERCASE and _ in place of spaces and hyphens.

  • FPS_FIX (bool) Set camera parameter to match the actual FPS being sent by the camera. Potential fix slow/fast SD card and cloud recordings.