track ip addresses, lookup mac addresses, etc

Python script to show live video using RTSP

Published on September 22, 2021


This is a simple Python script that shows live video of an RTSP stream. RTSP is a protocol and is short for Real Time Streaming Protocol.

Prepare IP camera with RTSP

For this post, I used a Wyze v2 camera which had the RTSP firmware installed. I installed the RTSP firmware, known as demo.bin from this link on


Now that you have your RTSP camera ready, enable the RTSP live video URL. It will be of this format:


where USERNAME, PASSWORD, IPADDRESS and ENDPOINT will vary depending on your values.

Copy my script to a directory of your choice.

#!/usr/bin/env python
# -*- coding: utf-8 -*-

This Python script shows Wyze v2 cam live using the RTSP link

Author  : Arul John
Created :
Updated :

import cv2

# RTSP info -- change these 4 values according to your RTSP URL
username = 'USERNAME'
password = 'PASSWORD'
endpoint = 'ENDPOINT'

# Stream
stream = cv2.VideoCapture(f'rtsp://{username}:{password}@{ip}/{endpoint}')

    while True:
        # Read the input live stream
        ret, frame =
        height, width, layers = frame.shape
        frame = cv2.resize(frame, (width // 2, height // 2))

        # Show video frame
        cv2.imshow("Wyze v2 camera", frame)

        # Quit when 'x' is pressed
        if cv2.waitKey(1) & 0xFF == ord('x'):
except Exception as e:
    print("ERROR:", e)

# Main function
if __name__ == "__main__":
    # Release and close stream

Edit and replace the four values with your own values.

You may not have the Python module cv2 in your Python environment. Let's install cv2.

pip install cv2

Now that the dependencies are installed, run the script:


You will see a live video using your camera. To quit, press x and the program will stop.

Stay tuned for follow-up posts.

Please let me know if you run into any issues. Thanks for reading this post.

{ % include 'ajrwd' %}

Disclaimer: Our website is supported by our users. We sometimes earn affiliate links when you click through the affiliate links on our website.

Published on September 22, 2021

TAGS: python, wyze, rtsp, ai

← Previous Post How to Install git 2.32 on Raspberry Pi

Wyze Outdoor Plug Review Next Post →

{ % include 'footer' %}