|
1 | | -# recording-scripts |
| 1 | +# recording-scripts v2 |
2 | 2 | This repository holds the scripts and a systemd service template I have used when making my bash-based NVR system. You can find a link to the presentation |
3 | 3 | outlining the project [here](https://bit.ly/3n8DRRl). |
4 | 4 |
|
5 | 5 | The scripts are written in bash. |
6 | 6 |
|
7 | | -I will outline their purpose here in short. |
| 7 | +This is version 2 of the scripts. The second version uses the systemd service template concept as well as the environment file concept |
| 8 | +to make deployment of each camera service simpler. All the variable parts of the recording script are stored in an environment file. |
| 9 | +The user will create one environment file per camera. The file should specify the camera properties, the base path for the recordings |
| 10 | +and the path to record.sh. |
8 | 11 |
|
9 | | - 1. cleanup.sh - This will remove any video files in X path after the given X days that are specified as a command line argument |
10 | | - 2. location-room.service - this system service will execute the recording script and make sure it restarts in case of system reboot |
11 | | - 3. record-location-room.sh - this is the main recording script. it calls ffmpeg and creates an apendable video file for the whole day |
12 | | - 4. remux.sh - this script will convert the previous days recording into an mp4 file extension |
13 | | - 5. watchdog.sh - this script serves a watchdog function that will check if the ffmpeg recording has stalled and restart it |
| 12 | +There is only one recording script - record.sh. The user should read it to get familiar with the variables and their role. There is no need |
| 13 | +to modify the recording script. |
14 | 14 |
|
15 | | -Another possible approach when recording is to use the built-in segmentation feature of ffmpeg and have it record in smaller chunks with |
16 | | -a non-appendable format. That way you can still recover from errors and use less space. The drawback is that you will have to concatenate |
17 | | -these small chunks at one point. The operation is not resource intensive but you need to have additional space available during that time, |
18 | | -write a script for it and schedule it with crontab. |
| 15 | +There is only one systemd service file - [email protected]. The user needs to edit the file before copying to the systemd service folder and specify |
| 16 | +the base path to the environment files and the path to the watchdog script. |
| 17 | + |
| 18 | + |
| 19 | +In order to deploy a script (once copied to the systemd folder) the user will execute the following command template: |
| 20 | + |
| 21 | + sudo systemd daemon-reload |
| 22 | + sudo systemd start [email protected] |
| 23 | + sudo systemd enable [email protected] |
| 24 | + |
| 25 | +As a result of this command systemd will look for an environment file named camera.env located in the folder specified in the service file. |
| 26 | +It will load all the variables contained within and run watchdog.sh. Watchdog will then run the recording script and poll for liveness every |
| 27 | +16 seconds. |
| 28 | + |
| 29 | +The recordings will be written in TS format to allow for appending in case of service failure. There will be only one recording per day. |
| 30 | +Each recording will have the format of YYYY_MM_DD.ts |
| 31 | + |
| 32 | +If you have any questions or think you have encountered a bug, please open an issue on [Github](https://github.com/Path-Variable/recording-scripts/issues). |
0 commit comments