Overview
Video mode records an MP4 video clip for the entire duration a person is present in the camera frame. Recording starts when a person enters and stops when they exit, capturing the complete event timeline.How It Works
When running in video mode (--save video):
- Detection: The system analyzes every Nth frame for person presence
- Entry Detection: When a person enters the frame, recording begins immediately
- Continuous Recording: Every frame is written to the MP4 file while at least one person is detected
- Exit Detection: After 3 consecutive detection cycles with no person, recording stops and the file is saved
- Waiting State: The system continues monitoring for the next entry event
Video mode captures full presence duration, not just a snapshot. This is ideal for reviewing behavior, incidents, or complete interactions.
Basic Usage
- Single Stream
- Multiple Streams
- Headless (No Display)
Output Files
File Naming Convention
Single Stream:person_clip_1_20260309_143022_1741528222.mp4
Multiple Streams:
output/stream_1/person_clip_1_20260309_143022_1741528222.mp4
File Structure
Clip duration varies based on how long the person remains in frame. Short clips (< 5 seconds) may indicate a person walking through quickly.
Video Codec and Settings
Default Settings
The system automatically configures video encoding:- Codec: MP4V (MPEG-4 Part 2)
- FPS: Matches source stream (auto-detected, defaults to 25 fps if unknown)
- Resolution: Original stream resolution (no resizing)
- Format:
.mp4container
FPS Detection
Fromstream_processor.py:79-81:
Video Writer Initialization
Fromstream_processor.py:153-156:
All recorded clips preserve the original stream’s frame rate and resolution. No transcoding or resizing is performed during recording.
Use Cases
Incident Review
Record complete events for later review:Each clip contains the full event timeline from entry to exit.
Behavior Analysis
Capture interactions and movement patterns:Review customer behavior, dwell times, and traffic patterns.
Multi-Camera Recording
Monitor multiple locations simultaneously:Each camera records independently when motion is detected.
Exit Detection Behavior
Three-Strike Rule
The system uses a conservative exit detection to prevent premature clip termination: Fromstream_processor.py:77:
frame-skip 15:
- Frame 15: Person detected → recording
- Frame 30: Person detected → still recording
- Frame 45: No person (1/3) → continue recording
- Frame 60: No person (2/3) → continue recording
- Frame 75: No person (3/3) → stop recording
This prevents clips from stopping when detection temporarily fails (person turns away, occlusion, etc.). You’ll capture a few extra frames after exit, which is usually preferable to cutting off early.
Storage Considerations
Estimating Disk Usage
Approximate file sizes for MP4V codec:| Resolution | FPS | Bitrate | 10 sec | 30 sec | 60 sec |
|---|---|---|---|---|---|
| 1920×1080 | 30 | ~4 Mbps | 5 MB | 15 MB | 30 MB |
| 1280×720 | 30 | ~2 Mbps | 2.5 MB | 7.5 MB | 15 MB |
| 640×480 | 25 | ~1 Mbps | 1.2 MB | 3.6 MB | 7.2 MB |
- 4 cameras at 1280×720, 30 fps
- Average 20 person entries per camera per day
- Average 15 seconds per clip
- Daily storage: 4 × 20 × 7.5 MB = 600 MB/day
Managing Storage
Advanced Configuration
Adjusting Exit Sensitivity
The exit threshold is hardcoded instream_processor.py:77. To customize, modify the source:
Custom Output Directory
Editconfig.cfg:
Frame Skip Optimization
Balance detection speed vs. CPU usage:frame-skip only affects detection frequency. All frames are recorded to the video file, regardless of the skip value.Monitoring Live Recording
Console Output
The console shows real-time recording status:Live Display
Enable grid display for multiple streams:Troubleshooting
Clips stop recording too early
Clips stop recording too early
The person may be temporarily undetected. Try:
- Lower
--confidencethreshold - Reduce
--frame-skipfor more frequent detection - Increase
NO_PERSON_EXIT_THRESHOLDin source code
Clips are too long
Clips are too long
Recording continues until 3 consecutive non-detections. This is intentional to prevent premature cutoff. If you need shorter clips, modify
NO_PERSON_EXIT_THRESHOLD in stream_processor.py:77.Video file corruption
Video file corruption
If the program crashes during recording, the clip may be corrupted. The system releases the video writer in a
finally block, but sudden termination (kill -9, power loss) can corrupt the file.Prevention:- Use proper shutdown (Ctrl+C)
- Run in a container with restart policies
- Implement external monitoring
High disk usage
High disk usage
Video mode uses significantly more storage than image mode. Solutions:
- Increase
--frame-skipto detect less frequently - Increase
--area-thresholdto ignore distant persons - Implement automatic cleanup scripts
- Use external archival storage
Recording never starts
Recording never starts
Check:
- Detection thresholds (try lowering
--confidence) - Stream resolution and quality
- Use
--test-imageto verify detection works