Daily Video Output: 8 Videos Breakdown
Video Structure (Per Day)
Amcrest Camera (4 videos)
amcrest_day_20250827.mp4
– 8:00am to 4:00pmamcrest_evening_20250827.mp4
– 4:00pm to 12:00amamcrest_night_20250827.mp4
– 12:00am to 8:00amamcrest_sunset_20250827.mp4
– 30min before sunset → 30min after sunset
Reolink Camera (4 videos)
reolink_day_20250827.mp4
– 8:00am to 4:00pmreolink_evening_20250827.mp4
– 4:00pm to 12:00amreolink_night_20250827.mp4
– 12:00am to 8:00amreolink_sunset_20250827.mp4
– 30min before sunset → 30min after sunset
Total: 8 videos per day
Sunset Video Special Characteristics
Timing (Using Douglas, MI coordinates)
// Already in your script:
private $latitude = 42.5596;
private $longitude = -86.2355;
private function getGoldenHourWindow($timestamp = null) {
$sun_info = date_sun_info($timestamp, $this->latitude, $this->longitude);
$sunset_timestamp = $sun_info['sunset'];
return [
'start' => $sunset_timestamp - (30 * 60), // 30min before
'end' => $sunset_timestamp + (30 * 60), // 30min after
'sunset' => $sunset_timestamp
];
}
Cross-Period Collection
Sunset videos span period boundaries:
Example August 27, 2025:
Sunset: 7:45 PM
Golden Hour: 7:15 PM → 8:15 PM
Segments collected from:
├── 7:15-8:00 PM (end of "evening" period)
└── 8:00-8:15 PM (start of "night" period)
Current Script Advantage
Your script already identifies golden hour segments:
- Tags them with
_gh
suffix - Stores them in the same period directories
- Calculates the exact golden hour window
Append Strategy for Sunset Videos
Challenge: Time-Based vs Period-Based
- Period videos: Append every 15 minutes predictably
- Sunset videos: Only append during golden hour window (~1 hour per day)
Implementation Approach
public function receiveSegment() {
$is_golden_hour = $this->isSegmentGoldenHour($timestamp);
// Always append to period video
$this->appendToPeriodVideo($camera, $period, $segment);
// Also append to sunset video if golden hour
if ($is_golden_hour) {
$this->appendToSunsetVideo($camera, $segment);
}
}
private function appendToSunsetVideo($camera, $segment) {
$today = date('Ymd');
$sunset_video = "/final_videos/{$camera}_sunset_{$today}.mp4";
$temp_video = "/temp_build/{$camera}_sunset_{$today}_building.mp4";
if (!file_exists($sunset_video)) {
// First golden hour segment of the day
copy($segment, $sunset_video);
} else {
// Append to existing sunset video
$this->fastAppend($sunset_video, $segment, $temp_video);
rename($temp_video, $sunset_video);
}
}
File Naming Convention
/final_videos/
├── amcrest_day_20250827.mp4 ← 8am-4pm, ~480 min
├── amcrest_evening_20250827.mp4 ← 4pm-12am, ~480 min
├── amcrest_night_20250827.mp4 ← 12am-8am, ~480 min
├── amcrest_sunset_20250827.mp4 ← Sunset±30min, ~60 min
├── reolink_day_20250827.mp4 ← 8am-4pm, ~480 min
├── reolink_evening_20250827.mp4 ← 4pm-12am, ~480 min
├── reolink_night_20250827.mp4 ← 12am-8am, ~480 min
└── reolink_sunset_20250827.mp4 ← Sunset±30min, ~60 min
Sunset Video Timing Examples
Date | Sunset Time | Golden Hour Window | Expected Duration |
---|---|---|---|
June 21 | 8:15 PM | 7:45 PM – 8:45 PM | ~60 minutes |
August 27 | 7:45 PM | 7:15 PM – 8:15 PM | ~60 minutes |
December 21 | 5:30 PM | 5:00 PM – 6:00 PM | ~60 minutes |
Duration = ~60 min = 4 segments (15-min intervals)
Processing Efficiency Gains
Current Script Waste
- Builds 3 video types per period (regular/complete/golden_only)
- Re-concatenates everything every 20 minutes
- ~432 rebuilds per day
Your Append Approach
- 4 videos per camera, append-only
- Constant 2-3 second processing per segment
- ~96 appends per day (24 hrs × 4 segments/hr × 2 cameras)
Result: 98% reduction in processing overhead