This Python script connects to an RTSP camera stream, detects motion via pixel difference analysis, overlays timestamps on frames, and saves them on motion detection or regular intervals.
- 🟡 Overlay timestamps with a visual background strip
- 📹 Real-time RTSP stream display
- 📦 Saves frames on:
- Motion detection
- Regular time intervals (based on frame count and FPS)
- ⚙️ Simple motion detection using pixel difference count
- Python 3.7 or higher
- An RTSP camera or local RTSP stream URL
- Clone the repo or download the script.
- Install required packages:
pip install -r requirements.txt- Update the script:
rtsp_link = r'rtsp://localhost:8554/stream' # Replace with your RTSP linkRun the script:
python motion_capture.py- Motion frames:
motion_YYYYMMDD_HHMMSS.jpg - Regular frames:
regular_YYYYMMDD_HHMMSS.jpg
- Motion detection sensitivity is adjustable via:
return count > 1000 # Lower = more sensitive- Change
save_intervalto adjust regular snapshot frequency (in seconds).
