Path: blob/master/stream/README.md
641 views
Batch Video Processing
Upload Videos from a folder to Stream via file-upload.
Stream Monitor
Monitor Stream HEALTH through it's logs. This script exposes a single API endpoint that returns responses in this format:
active
is true if the stream container is running, so you need to check it before checking cameras
.
1. Installation
Optional arguments:
For example, you can start the script with:
2. Calling the API endpoint
In another terminal, you can query Stream status.
Remove Stream Images
By Time
This script runs nightly to remove images that are over xx hours in Stream folder. However, if you wouldn't want to save images locally at all, you may refer to this guide.
Make sure to have this remove_images.py script inside the Stream folder.
Format: python remove_images.py --age --threshold <integer> --directory /path/to/stream
Notes:
1. Don't forget to update the --threshold
(time duration in hours) to remove images older than xx hours.
2. --threshold
should be an integer between 1
and 23
(hours).
_3. --directory
Stream working directory, default value = .
Schedule running of script
For Linux:
Note: Make sure cron is installed.
For Windows:
Run this in a command promt or powershell to add the script to Windows Task Scheduler.
Lastly, to make sure this runs on the Stream directory. Open Task Scheduler, click on the newly created scheduler task, then choose Properties. Go to the Actions tab, then click on Edit. Set the Start in (optional) to be the path of your Stream Directory then click Ok.
Uninstall
To uninstall the service, just remove the script from the Stream directory.
To remove the scheduled running of the script,
For Linux, run this in the terminal:
For Windows, run this in command promt or powershell:
By Disk Space Percentage
This script automatically deletes the oldest images in the Stream folder to free up disk space when the disk usage exceeds a certain threshold. The script checks if disk usage is above a trigger percentage (y%) and deletes images until it reaches a target free space percentage (x%).
Make sure to have this remove_images.py
script inside the Stream folder.
python remove_images.py --usage --target_free <integer> --trigger_usage <integer> --directory /path/to/images
Notes:
_1. Don't forget to update the --target_free
(desired free space %) and --trigger_usage
(disk usage % that triggers cleanup).
_2. Both --target_free
and --trigger_usage
must be integers between 1 and 99. _3. --directory
Stream working directory, default value = .
Schedule running of script
For Linux:
Note: Make sure cron is installed.
For Windows:
Create a scheduled task in Command Prompt or PowerShell:
Example: Run daily at midnight.
Then, open Task Scheduler → find your new task → right-click Properties → Actions tab → click Edit, and set the Start in (optional) path to your Stream folder.
Uninstall
To uninstall the scheduled task:
For Linux, run:
For Windows, run:
Important Reminders:
The scripts only delete .jpg files.
The script deletes the oldest files first (FIFO).
You can always test the script manually before fully automating to avoid accidental data loss.