RTSP Camera Stream Monitor with Raspberry Pi

I spent hours trying to figure out how to monitor Wyze cams on a TV that would stay on and display the cameras automatically after a power or connection loss, without any manual intervention.

Most guides I found online were outdated because omxplayer is no longer supported. So, I came up with a solution using FFMPEG and mpv.

Initially, I thought about launching Chromium on boot using wayfire.ini to automatically navigate to the Wyze web monitor. However, this approach didn’t work as expected. The Wyze web monitor frequently logged out, and the camera streams would disconnect after just a few minutes—this happened even on a MacBook, so it seems to be an issue with Wyze itself.

That’s when I decided to enable RTSP (Real-Time Streaming Protocol) on my Wyze cams. By enabling RTSP, I could access the camera streams directly via their IP addresses (using rtsp://), eliminating the need to log in to Wyze every time. This method proved much more reliable for a constant, hands-free monitoring setup.

Wyze RTSP Firmware

To install the RTSP firmware on your Wyze cameras you need to download the file for your camera from this repository. Next, format the SD Card (32GB and smaller = FAT32, larger than 32GB = exFAT) and drop the file into it. I did this with two different SD cards, a Sandisk and a cheap off brand one from Amazon, and it never worked with the off brand one no matter how many times I tried. Opt for a high quality SD card if you can, as once you install you can simply remove it and use it on another camera.

Afterwards you’ll need to insert the SD card and power on the camera while having the setup button pressed down. This is pretty tricky so I reccomend simply unplugging it and plugging it back in again instead of using the micro USB connector to plug it in. Once the LED turns purple you can release the SETUP button.

After the camera restarts you might have to set it up again. Once set up, navigate to the advanced settings page and you should see a page for RTSP. Once there you can enable it and setup a username and password.

Finally, you’ll be given the RTSP URL.

Raspberry Pi Monitor Setup

I setup the Raspberry Pi with Raspbian.

First we’ll need to install FFMpeg and mpv with this command.

sudo apt update && sudo apt install -y ffmpeg mpv

This updates your package lists (Your apps in the appstore) and installs both tools, confirming automatically the storage space taken and the prerequisite installs.

FFMPEG is a tool for handling multimedia content like audio and video. It allows you to record, convert, and stream videos. In this setup, it processes the camera streams by scaling, combining, and preparing them for display.

mpv is a lightweight media player that can play various types of video files and streams. Here, it’s used to display the processed video streams from FFMPEG on your monitor or TV.

Next, create a script named cameras.sh and paste this inside

#!/bin/bash
while true; do
  ffmpeg \
    -i rtsp://admin:[email protected]/live \
    -i rtsp://admin:[email protected]/live \
    -reconnect 1 \
    -reconnect_at_eof 1 \
    -reconnect_streamed 1 \
    -reconnect_delay_max 30 \
    -threads 4 \
    -buffer_size 64M \
    -filter_complex "
      [0:v]scale=640:360,setpts=PTS-STARTPTS[stream1];
      [1:v]scale=640:360,setpts=PTS-STARTPTS[stream2];
      [stream1][stream2]hstack=inputs=2[tiled];
      [tiled]pad=width=1280:height=720:x=0:y=180:color=black[out]
    " -map "[out]" -an -f rawvideo -pix_fmt yuv420p -r 30 -s 1280x720 - | mpv --fs --no-border --demuxer=rawvideo --demuxer-rawvideo-w=1280 --demuxer-rawvideo-h=720 --demuxer-rawvideo-fps=30 --demuxer-rawvideo-mp-format=yuv420p --vd-lavc-threads=4 -
  sleep 5
done

Replace the IPs I provided with your own and set the number of threads to the number you have available.

This script takes two RTSP and tiles them side by side.

I also added some quality of life improvements such as automatically reconnecting if disconnected and automatically restarting if mpv crashes or is closed.

To have this script start on boot I put it in the wayfire.ini file at /home/YOURUSERNAME/.config/wayfire.ini

You simply need to add two lines to the end of it.

[autostart]
program1 = bash /home/raspberrypi/cameras.sh

Replace the path with the path to your script.

To keep everything running smoothly I also made the Raspberry Pi reboot every day at 3am using crontab.

Edit the cron jobs:

sudo crontab -e

Add this line to schedule a daily reboot at 3 AM:

0 3 * * * /sbin/reboot

And that’s it!