DEV Community

Joe Block
Joe Block

Posted on • Originally published at unixorn.github.io on

Setting up Shinobi and a Wyze G2 Camera

I wanted to set up a security camera outside, but I didn't want to be dependent on an outside cloud service - if my internet goes out, I don't want to lose my ability to record footage.

Wyze cameras are nice and cheap, and you can reflash them to support RTSP in addition to streaming to the Wyze cloud.

Setup

Prerequisites

  • A camera that supports the RTSP protocol (I'm using a Wyze G2)
  • A spare microSD card for reflashing the Wyze G2 camera
  • An x86 machine running docker. As of 2021-03-14, Shinobi only publishes an amd64 version of the shinobisystems/shinobi docker image.
  • A reasonable amount of disk space - the Wyze G2 I'm using generates around 330 megs per hour of stored 1080p video.

Camera Setup

I wanted a camera that supported the Real Time Streaming Protocol (RTSP) because that is an open standard which works with a wide variety of tooling, both Open Source and commercial.

I looked at a variety of camera options, and Wirecutter's Best Wifi Home Security Camera listed the Wyze G2 as runner-up. It and the first choice (Eufy 2K Indoor cam) both support RTSP, but the Wyze was in stock (and half the price at $26) so I went with it.

I did have to reflash the Wyze G2 to enable a beta firmware that supports both Wyze's cloud and RTSP. Conveniently, it can stream to both simultaneously, so I can watch the streams with the Wyze app when away from home and still record everything to my homelab cluster.

Reflash the Wyze Camera

Wyze now has a beta firmware that simultanously supports both their cloud offering and RTSP. Note that they've explicitly stated that the RTSP branch will get features later than the mainline firmware. I personally don't care, but it is something to consider if you're going to want to use bleeding edge features.

The official instructions for reflashing the G2 camera are on the Wyze Cam RTSP page and clear, so I'm not going to rehash them here. You'll need a FAT32 formatted microSD card to do the firmware reflash.

After you reflash the camera, you'll need to configure a username/password combination for the camera stream using the Wyze phone app.

Before you configure the camera, I recommend that you go into your router's configuration and assign the camera a static IP so that your DVR doesn't lose the stream connection when the camera or router are rebooted. You can also hardcode an IP address into the G2 camera's configuration, but I prefer to keep all the static IP assignments for my network in one place, the DHCP configuration on my router.

You'll end up with a rtsp url that looks like rtsp://username:password@192.168.1.CAMERAIP/live.

DVR Setup

I don't use any IOT devices that require a cloud service to function. In this case, I especially do not want to be unable to record security footage just because the internet is down, so I set up shinobi as a local DVR to record my security footage.

Start shinobi

I'm running shinobi in a docker container. As of 2021-03-14, there is only an AMD64 build of this docker image so I'm running it on the an Intel machine in my homelab cluster.

Here's a shinobi-start script:

#!/usr/bin/env bash
#
# Start shinobi
#
# Copyright 2021, Joe Block <jpb@unixorn.net>
#
# License: Apache 2.0

SHINOBI_D=${SHINOBI_D:-'/data/shinobi'}

set -o pipefail
if [[ -n "$DEBUG" ]]; then
  set -x
fi

for dvr_d in config customAutoLoad database plugins video
do
  mkdir -p "$SHINOBI_D/$dvr_d"
done

exec docker run -d -p 8080:8080 \
  --name='shinobi' \
  -v ${SHINOBI_D}/config:/config:rw \
  -v ${SHINOBI_D}/customAutoLoad:/home/Shinobi/libs/customAutoLoad:rw \
  -v ${SHINOBI_D}/database:/var/lib/mysql:rw \
  -v ${SHINOBI_D}/plugins:/plugins:rw \
  -v ${SHINOBI_D}/videos:/home/Shinobi/videos:rw \
  -v /dev/shm/Shinobi/streams:/dev/shm/streams:rw \
  -v /etc/localtime:/etc/localtime:ro \
  -v /etc/timezone:/etc/timezone:ro \
  --restart always \
  shinobisystems/shinobi
Enter fullscreen mode Exit fullscreen mode

Run this with SHINOBI_D=/path/to/local/dvr/files shinobi_start and it will create any missing required directories for you and start shinobi.

Configure shinobi

First, set up a new admin account
  1. Login at http://your.shinobi.server:8080/super with username admin@shinobi.vido and password admin
  2. Create a new admin account
  3. Don't forget to reset the password for the admin@shinobi.video account!
Add the camera
  1. Login at http://your.shinobi.server:8080
  2. Click on the + icon in the toolbar at the top of the page
  3. Set mode to record
  4. Change the name to something human friendly like "Mailbox Camera"
  5. Set input type (in the connection section) to H.264 / H.265 / H.265+
  6. Set the full URL path to the rtsp stream url you got from the camera
  7. Optionally set Skip Ping to Yes
  8. Set Stream Type to HLS (includes audio)
  9. Set Record File Type to MP4
  10. Set Video codec to copy
  11. Set Audio Codec to Auto
  12. Save

You can optionally set retention times for the camera data.

It took about 30-45 seconds before my camera stream was visible in shinobi.

Top comments (0)