Skip to content

Commit

Permalink
Improved looped recording
Browse files Browse the repository at this point in the history
  • Loading branch information
connervieira committed Jun 14, 2024
1 parent 24c7a10 commit a027c63
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ This update focuses on improving the reliability of Predator, especially when op
- Added the ability to disable capture devices without removing them from the configuration entirely.
- Predator now changes the status light color when a video is being locked.
- Dashcam video save events can now be triggered using buttons via GPIO pins.
- Improved looped recording.
- Each thread now checks to see if old segments have already been deleted before deleting them themselves.
- Updated status lighting.
- Moved the status lighting configuration to the "general" section.
- Network requests are only made to update the status lighting if it has changed since the last update.
Expand Down
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ These are the features actively planned for Predator and are likely to be added
- [X] Add custom relay status stamps through GPIO.
- [X] Add default config support for values that involve adding entries.
- [X] Improve the efficiency of the GPS stamp.
- [ ] Check to see if old dashcam video files actually exist before deleting them.
- [X] Check to see if old dashcam video files actually exist before deleting them.

## Hypothetical

Expand Down
4 changes: 3 additions & 1 deletion dashcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,9 @@ def delete_old_segments():
if (len(dashcam_files) > int(config["dashcam"]["saving"]["looped_recording"]["manual"]["history_length"])): # Check to see if the current number of dashcam segments in the working directory is higher than the configured history length.
videos_to_delete = dashcam_files[0:len(dashcam_files) - int(config["dashcam"]["saving"]["looped_recording"]["manual"]["history_length"])] # Create a list of all of the videos that need to be deleted.
for video in videos_to_delete: # Iterate through each video that needs to be deleted.
os.system("timeout 5 rm '" + config["general"]["working_directory"] + "/" + video + "'") # Delete the dashcam segment.
video_file = config["general"]["working_directory"] + "/" + video
if (os.path.exists(video_file)): # Check to see if this video file still exists (it hasn't been deleted by another thread).
os.system("timeout 5 rm '" + video_file + "'") # Delete the dashcam segment.
elif (config["dashcam"]["saving"]["looped_recording"]["mode"] == "automatic"): # Check to see if looped recording is in automatic mode.
free_disk_percentage = psutil.disk_usage(path=config["general"]["working_directory"]).free / psutil.disk_usage(path=config["general"]["working_directory"]).total # Calculate the initial free disk percentage.
videos_deleted_this_round = 0 # This is a placeholder that will be incremented for each video deleted in the following step.
Expand Down

0 comments on commit a027c63

Please sign in to comment.