Skip to content

Reolink PTZ Streamer

Sven337 edited this page Aug 15, 2024 · 1 revision

Reolink PTZ Streamer

This program is a PyQt6 application that allows users to view and control a Reolink PTZ (Pan-Tilt-Zoom) camera. It was written for a TrackMix camera which has two lenses. It displays two video streams from the camera and provides controls for moving the camera and zooming.

Features

  • Displays two video streams from the camera: wide-angle and telephoto
  • Allows camera movement using arrow keys
  • Supports zooming using the mouse wheel
  • Reads camera configuration from a file

Dependencies

  • PyQt6
  • reolinkapi

Usage

  1. Ensure you have a camera.cfg file in the same directory as the script with the following structure:
[camera]
ip=<camera_ip>
username=<username>
password=<password>
  1. Run the script:
python script_name.py

Classes

ZoomSlider

A custom QSlider that ignores arrow key events.

CameraPlayer

The main widget that displays the video streams and handles user input.

Methods

  • __init__(self, rtsp_url_wide, rtsp_url_telephoto, camera: Camera): Initializes the widget and sets up the video streams.
  • keyPressEvent(self, event): Handles key press events for camera movement.
  • keyReleaseEvent(self, event): Handles key release events to stop camera movement.
  • start_move(self, key): Starts camera movement based on the pressed key.
  • stop_move(self): Stops camera movement.
  • move_camera(self, direction): Moves the camera in the specified direction.
  • handle_wheel_event(self, event: QWheelEvent): Handles mouse wheel events for zooming.
  • zoom_in(self): Initiates zooming in.
  • zoom_out(self): Initiates zooming out.
  • start_zoom(self, direction: str): Starts zooming in the specified direction.
  • stop_zoom(self): Stops zooming.
  • show_error_message(self, title, message): Displays error messages.
  • handle_error(self, error): Handles media player errors.

Main Execution

The script performs the following steps when executed:

  1. Reads camera configuration from camera.cfg.
  2. Connects to the camera using the provided credentials.
  3. Creates RTSP URLs for wide-angle and telephoto streams.
  4. Initializes the QApplication and CameraPlayer.
  5. Displays the CameraPlayer widget.

Notes

  • The script disables SSL warnings for self-signed certificates.
  • Error handling is implemented for various camera operations.
  • The camera movement and zoom operations are designed to work with Reolink cameras that support the PTZ API.