An intelligent application that automatically triggers OBS Studio recordings when motion or audio is detected. Perfect for security monitoring, wildlife observation, or any scenario where you need automatic recording based on environmental triggers.
- Motion Detection: Uses computer vision to detect movement in camera feed
- Audio Detection: Monitors microphone input for sound above threshold
- Automatic Recording: Triggers 1-hour OBS recordings when activity is detected
- Cooldown Period: Prevents multiple triggers in quick succession
- Configurable Settings: Customize thresholds, devices, and recording duration
- Logging: Comprehensive logging of all activities and detections
- OBS Studio must be installed and running
- OBS WebSocket Plugin must be enabled:
- In OBS: Tools > obs-websocket Settings
- Enable WebSocket server
- Note the port (default: 4455) and set password if needed
- Python 3.7+ must be installed
- Camera and microphone must be accessible to the system
- Clone or download this repository
- Install dependencies:
pip install -r requirements.txt
- Copy the example environment file:
cp .env.example .env
- Edit
.envto configure your settings (optional, defaults work for most setups)
All settings can be configured via the .env file:
OBS_HOST: OBS WebSocket host (default: localhost)OBS_PORT: OBS WebSocket port (default: 4455)OBS_PASSWORD: OBS WebSocket password (if set)
MOTION_THRESHOLD: Minimum motion area to trigger (default: 1000)MOTION_SENSITIVITY: Motion detection sensitivity 0-255 (default: 25)CAMERA_INDEX: Camera device index (default: 0)FRAME_WIDTH: Camera frame width (default: 640)FRAME_HEIGHT: Camera frame height (default: 480)
AUDIO_THRESHOLD: Minimum audio level to trigger 0-1 (default: 0.01)AUDIO_DEVICE_INDEX: Audio input device index (default: 0)
RECORDING_DURATION: Recording length in seconds (default: 3600 = 1 hour)COOLDOWN_PERIOD: Seconds between detections (default: 30)
- Start OBS Studio and ensure WebSocket server is enabled
- Run the application:
python main.py
- The app will start monitoring for motion and audio
- When detected, it will automatically start OBS recording for the configured duration
- Press
Ctrl+Cto stop the application
- Initialization: Connects to OBS WebSocket and initializes camera/audio
- Monitoring: Continuously monitors camera feed and audio input
- Detection: When motion or audio exceeds thresholds, triggers recording
- Recording: Starts OBS recording for specified duration (default: 1 hour)
- Cooldown: Prevents retriggering for cooldown period
- Auto-Stop: Automatically stops recording after duration expires
"Failed to connect to OBS"
- Ensure OBS Studio is running
- Check that WebSocket server is enabled in OBS settings
- Verify host/port/password in
.envfile
"Could not open camera"
- Check camera permissions
- Try different
CAMERA_INDEXvalues (0, 1, 2, etc.) - Ensure camera isn't being used by another application
"Failed to initialize audio"
- Check microphone permissions
- Try different
AUDIO_DEVICE_INDEXvalues - Run the app to see available audio devices in logs
"No motion detected"
- Adjust
MOTION_THRESHOLD(lower = more sensitive) - Adjust
MOTION_SENSITIVITY(lower = more sensitive) - Ensure adequate lighting for camera
"No audio detected"
- Lower
AUDIO_THRESHOLDvalue - Check microphone levels in system settings
- Ensure microphone isn't muted
The application logs available cameras and audio devices on startup. Check the logs to find the correct indices for your devices.
The application creates detailed logs in obs_auto_record.log and displays them in the console. Monitor these logs to understand detection events and troubleshoot issues.
You can extend the detection system by modifying the callback functions in main.py to add custom logic or additional trigger conditions.
To monitor multiple cameras, you can run multiple instances with different CAMERA_INDEX values.
Modify obs_controller.py to switch to specific scenes before recording or use different recording settings.
This project is open source and available under the MIT License.