Added a windows DVR type thing or something
This commit is contained in:
parent
4e7b0ed2cf
commit
c2796c9e70
1
Windows DVR/.gitignore
vendored
Normal file
1
Windows DVR/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.env
|
26
Windows DVR/WindowsDVR.ps
Normal file
26
Windows DVR/WindowsDVR.ps
Normal file
@ -0,0 +1,26 @@
|
||||
# Load the .env file
|
||||
$envFilePath = ".\env"
|
||||
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
|
||||
$arguments = "-i $rtspUrl -c copy -f segment -segment_time $chunkSize -segment_format mp4 -strftime 1 $outputPath\%Y-%m-%d_%H-%M-%S.mp4"
|
||||
|
||||
# Start FFmpeg in the background
|
||||
Start-Process -FilePath $ffmpegPath -ArgumentList $arguments -WindowStyle Hidden
|
19
Windows DVR/WindowsDVRCleanup.ps
Normal file
19
Windows DVR/WindowsDVRCleanup.ps
Normal file
@ -0,0 +1,19 @@
|
||||
$envFilePath = ".\env"
|
||||
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
|
||||
}
|
||||
|
||||
$maxAge = [System.Environment]::GetEnvironmentVariable("MAX_AGE")
|
||||
$outputPath = [System.Environment]::GetEnvironmentVariable("OUTPUT_PATH")
|
||||
|
||||
# Get files older than MAX_AGE hours and delete them
|
||||
Get-ChildItem -Path $outputPath -File | Where-Object { $_.LastWriteTime -lt (Get-Date).AddHours($maxAge) } | Remove-Item
|
Loading…
Reference in New Issue
Block a user