2024-10-21 06:36:06 +00:00
|
|
|
# Load the .env file
|
2024-10-21 21:49:34 +00:00
|
|
|
$envFilePath = ".\.env"
|
2024-10-21 06:36:06 +00:00
|
|
|
if (Test-Path $envFilePath) {
|
|
|
|
Get-Content $envFilePath | ForEach-Object {
|
|
|
|
if ($_ -match "^(.*?)=(.*)$") {
|
|
|
|
$name = $matches[1]
|
|
|
|
$value = $matches[2]
|
|
|
|
[System.Environment]::SetEnvironmentVariable($name, $value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Write-Output ".env file not found"
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
|
|
|
# Retrieve variables from environment
|
|
|
|
$outputPath = [System.Environment]::GetEnvironmentVariable("OUTPUT_PATH")
|
|
|
|
$rtspUrl = [System.Environment]::GetEnvironmentVariable("RTSP_URL")
|
|
|
|
$chunkSize = [System.Environment]::GetEnvironmentVariable("CHUNK_SIZE")
|
|
|
|
$maxAge = [System.Environment]::GetEnvironmentVariable("MAX_AGE")
|
|
|
|
|
|
|
|
# FFmpeg arguments for recording in 10-minute segments
|
2024-10-22 01:27:11 +00:00
|
|
|
$arguments = "-i $rtspUrl -c copy -f segment -segment_time $chunkSize -segment_format mp4 -strftime 1 " + $outputPath + "\%Y-%m-%d_%H-%M-%S.mp4"
|
2024-10-21 06:36:06 +00:00
|
|
|
|
|
|
|
# Start FFmpeg in the background
|
2024-10-22 01:27:11 +00:00
|
|
|
Start-Process ffmpeg -ArgumentList $arguments
|