Skip to content

Commit

Permalink
Completed preliminary dashcam rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
connervieira committed Dec 18, 2024
1 parent 16c77c9 commit d3a9840
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 113 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,22 @@ November 20th, 2024

## Version 12.0

### Dashcam Update 3

*Release date to be determined*

- Updated object recognition behavior.
- Removed the existing object recognition implementation from real-time and pre-recorded mode.
- Implemented object recognition support for dash-cam mode's parking functionality.
- Updated dash-cam mode parking functionality.
- Overhauled dash-cam recording back-end.
- Combined the separated dash-cam recording and writing threads into a single process.
- Restructed underlying function calls.
- Predator now has organized functions for each recording state (normal, parked-dormant, parked-event)
- Sub-functions are called as separate threads by a supervisor process.
- Changed the dash-cam video file name template.
- Saved dash-cam videos now follow this structure: "YYYY-MM-DD HHMMSS Predator X.ext"
- `YYYY-MM-DD HHMMSS` is replaced by the current date and time in 24 hour format.
- `X` is replaced by the recording mode.
- "N" indicates normal recording.
- "P" indicates parked recording.
- `ext` is replaced by the file extension.
2 changes: 2 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ These are the features actively planned for Predator and are likely to be added
- [X] Finish alert documentation (ALERTS.md)
- [X] Fix frame counting for side-car mode.
- [X] Document `developer>frame_count_method` configuration value in `docs/CONFIGURE.md.
- [ ] Add sound effect for parking mode.
- [ ] Validate multi-channel recording.


## Hypothetical
Expand Down
4 changes: 3 additions & 1 deletion assets/support/configdefault.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,11 @@
"extension": "wav",
"device": "",
"format": "S16_LE",
"rate": 44100,
"merge": true,
"record_as_user": "pi",
"start_delay": 0.2
"start_delay": 0.2,
"display_output": false
}
},
"parked": {
Expand Down
4 changes: 3 additions & 1 deletion assets/support/configoutline.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,11 @@
"extension": "str",
"device": "str",
"format": ["S8", "U8", "S16_LE", "S16_BE", "U16_LE", "U16_BE", "S24_LE", "S24_BE", "U24_LE", "U24_BE", "S32_LE", "S32_BE", "U32_LE", "U32_BE", "FLOAT_LE", "FLOAT_BE", "FLOAT64_LE", "FLOAT64_BE", "IEC958_SUBFRAME_LE", "IEC958_SUBFRAME_BE", "MU_LAW", "A_LAW", "IMA_ADPCM", "MPEG", "GSM", "S20_LE", "S20_BE", "U20_LE", "U20_BE", "SPECIAL", "S24_3LE", "S24_3BE", "U24_3LE", "U24_3BE", "S20_3LE", "S20_3BE", "U20_3LE", "U20_3BE", "S18_3LE", "S18_3BE", "U18_3LE", "U18_3BE", "G723_24", "G723_24_1B", "G723_40", "G723_40_1B", "DSD_U8", "DSD_U16_LE", "DSD_U32_LE", "DSD_U16_BE", "DSD_U32_BE"],
"rate": "+int",
"merge": "bool",
"record_as_user": "str",
"start_delay": "+float"
"start_delay": "+float",
"display_output": "bool"
}
},
"parked": {
Expand Down
232 changes: 128 additions & 104 deletions dashcam.py

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions docs/CONFIGURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,11 @@ This document describes the configuration values found `config.json`.
- "XVID" is used for'.avi' files, and is the default option.
- "MP4V" is used for '.mp4' files, and is great for video player compatability.
- Note that this codec will often result in the current vidoe segment being lost in the event of a sudden power loss.
- `extension` is the video file extension.
- `extension` is the video file extension (not including the dot).
- When audio/video merging is enabled, the resulting file will always have the "mkv" extension, irrespective of this setting.
- `trigger` is the name of a file inside the interface directory that will trigger Predator to save the current and previous dashcam segments.
- To trigger a save, create this file in the interface directory. Predator will save the video then automatically remove the trigger file.
- When this file is created, Predator will immediately save the previous and current dashcam video segments. Once the current segment is done recording, Predator will re-save it, such that the saved video doesn't cut off at the moment the saved was triggered.
- If Predator is terminated between the initial save and the second save, only video captured after the save trigger won't be saved.
- Predator will check for the presence of this file at the end of each segment, and copy the relevant files to the saving directory.
- `segment_length` is a number that sets how many seconds long each video segment will be before another segment is created.
- `looped_recording` contains settings that control how and when Predator will erase old dashcam segments to make space for new ones.
- `mode` determines the method by which Predator determines how to erase old files. This can only be set to one of 3 strings:
Expand Down Expand Up @@ -261,12 +261,16 @@ This document describes the configuration values found `config.json`.
- You can get a list of the names of the available sound inputs by running the `arecord -L` command.
- Leaving this value as a blank string will cause Predator to use the default audio input determined by `arecord`.
- `format` specifies the format that will be used by the `arecord` process.
- `rate` is an integer that specifies the audio sample rate in Hz (16000, 44100, 48000, etc.)
- `merge` is a boolean that determines whether or not Predator will merge the separate audio and video files when each segment is done recording.
- This setting is ignored during parked event recording, and audio/video is always saved separately.
- `record_as_user` specifies the user on the system that the audio recording process will be run as.
- This is useful if the user you normally run Predator with does not have permission to access audio devices.
- `start_delay` determines a length of time (in seconds) that Predator will wait before starting audio recording for each segment.
- This delay allows the audio capture device to be release by the previous segment before it is re-opened for the current segment.
- This value should be as short as possible to reduce the period of silence at the start of each video, but not so short that the audio capture device fails to open due to being already claimed by the previous segment.
- `display_output` is a boolean that determines whether Predator will display the console output of the audio recording command for sake of debugging.
- Under normal circumstances, this should be set to `false` to avoid unexpected behavior.
- `parked` contains settings to configure the dashcam's parking behavior. Parking mode is experimental, and not recommended for daily use.
- `enabled` is a boolean that determines whether Predator will ever go into a parked state.
- When this value is set to `false` Predator will never enable parked mode, even if the conditions defined in this configuration section are met.
Expand Down
4 changes: 1 addition & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1430,12 +1430,10 @@
# Dash-cam mode
elif (mode_selection == "3" and config["general"]["modes"]["enabled"]["dashcam"] == True): # The user has set Predator to boot into dash-cam mode.
print("\nStarting dashcam recording")
dashcam.dashcam()
debug_message("Started dash-cam mode")
try:
print("Press Ctrl+C to exit")
while global_variables.predator_running:
time.sleep(1)
dashcam.dashcam()
except:
global_variables.predator_running = False
display_message("Dashcam recording halted.", 1)
Expand Down

0 comments on commit d3a9840

Please sign in to comment.