generated from pavel.muhortov/template-bash
170 lines
6.9 KiB
Markdown
170 lines
6.9 KiB
Markdown
|
# cctv-scheduler
|
||
|
|
||
|
PTZ IP-Camera management
|
||
|
____
|
||
|
|
||
|
- [`cctv-scheduler.py`](https://git.hmp.today/pavel.muhortov/cctv-scheduler#cctv-scheduler-py)
|
||
|
- [`publisher.sh`](https://git.hmp.today/pavel.muhortov/cctv-scheduler#publisher-sh)
|
||
|
|
||
|
____
|
||
|
|
||
|
![cctv-scheduler](info/images/cctv-scheduler-0.4.png)
|
||
|
|
||
|
## `Installation`
|
||
|
|
||
|
### `Requirements`
|
||
|
|
||
|
Cameras settings:
|
||
|
>
|
||
|
> - Configuration -> System -> Security -> Authentication -> RTSP Authentication: digest/basic
|
||
|
> - Configuration -> System -> Security -> Authentication -> WEB Authentication: digest/basic
|
||
|
> - Configuration -> Network -> Advanced Settings -> Integration Protocol -> Enable Hikvision-CGI: Enabled
|
||
|
> - Configuration -> Network -> Advanced Settings -> Integration Protocol -> Hikvision-CGI Authentication: digest/basic
|
||
|
|
||
|
Look at the description of dependencies and install the necessary.
|
||
|
|
||
|
### `Downloading`
|
||
|
|
||
|
Download scripts and configs.
|
||
|
|
||
|
```bash
|
||
|
wget https://git.hmp.today/pavel.muhortov/cctv-scheduler/raw/branch/master/cctv-scheduler.py -O /home/user/cctv-scheduler/cctv-scheduler.py
|
||
|
wget https://git.hmp.today/pavel.muhortov/cctv-scheduler/raw/branch/master/cctv-scheduler.conf -O /home/user/cctv-scheduler/cctv-scheduler.conf
|
||
|
wget https://git.hmp.today/pavel.muhortov/cctv-scheduler/raw/branch/master/publisher.sh -O /home/user/cctv-scheduler/publisher.sh
|
||
|
wget https://git.hmp.today/pavel.muhortov/cctv-scheduler/raw/branch/master/publisher.conf -O /home/user/cctv-scheduler/publisher.conf
|
||
|
wget https://git.hmp.today/pavel.muhortov/cctv-scheduler/raw/branch/master/publisher-template-page-1007.xml -O /home/user/cctv-scheduler/publisher-template-page-1007.xml
|
||
|
```
|
||
|
|
||
|
### `Configuration`
|
||
|
|
||
|
Edit configs.
|
||
|
|
||
|
```bash
|
||
|
nano /home/user/cctv-scheduler/cctv-scheduler.conf
|
||
|
nano /home/user/cctv-scheduler/publisher.conf
|
||
|
```
|
||
|
|
||
|
### `Scheduler`
|
||
|
|
||
|
Look at examples and edit scheduler tasks:
|
||
|
|
||
|
```bash
|
||
|
crontab -e
|
||
|
```
|
||
|
|
||
|
## `cctv-scheduler`.py
|
||
|
|
||
|
**Description:**
|
||
|
> [Hikvision](https://git.hmp.today/pavel.muhortov/cctv-scheduler/src/branch/master/info/hikvision/manual/isapi.pdf) PTZ IP-Camera management. Media streaming. Images to video converting.
|
||
|
> Additionally:
|
||
|
>
|
||
|
> - getting temperature from DS18B20 over SSH,
|
||
|
> - saving pictures to FTP.
|
||
|
> - converting picture collection to video.
|
||
|
>
|
||
|
> This is only a local "proof of concept" for testing and debugging.
|
||
|
|
||
|
**Dependencies:**
|
||
|
>
|
||
|
> - [Python 3](https://www.python.org/downloads/) (tested version 3.9.5 on [Debian GNU/Linux 11](http://ftp.debian.org/debian/dists/bullseye/))
|
||
|
> - [paramiko](https://www.paramiko.org/) Python 3 module (tested version 3.1.0)
|
||
|
> - [ffmpeg](https://ffmpeg.org) (tested version 4.3.4 on [Debian GNU/Linux 11](http://ftp.debian.org/debian/dists/bullseye/))
|
||
|
> - specified record pictures filesystem organization
|
||
|
>
|
||
|
>```bash
|
||
|
> # record pictures filesystem organization example
|
||
|
>/root/
|
||
|
> /2022/
|
||
|
> /12/
|
||
|
> /52/
|
||
|
> /31/
|
||
|
> /image-01_2022.12.31_time.jpeg
|
||
|
> /image-02_2022.12.31_time.jpeg
|
||
|
> /2023/
|
||
|
> /01/
|
||
|
> /01/
|
||
|
> /02/
|
||
|
> /image-01_2023.01.02_time.jpeg
|
||
|
> /image-02_2023.01.02_time.jpeg
|
||
|
> /03/
|
||
|
> /image-01_2023.01.03_time.jpeg
|
||
|
> /image-02_2023.01.03_time.jpeg
|
||
|
>```
|
||
|
|
||
|
| PARAMETERS | DESCRIPTION | DEFAULT|
|
||
|
|-------------|-------------|--------|
|
||
|
|**[-h]**|print help and exit||
|
||
|
|**[-b, --broadcast]**|streaming media to destination|`None`|
|
||
|
|**[-s, --sequences]**|run sequences from config file|`None`|
|
||
|
|**[--config]**|custom configuration file path|`./cctv-scheduler.conf`|
|
||
|
|**[-c, --converter]**|convert JPEG collection to MP4|`None`|
|
||
|
|**[-d, --day]**|day in amount of days from today, for which the publication or conversion is made|`0`|
|
||
|
|**[-w, --week]**|week in amount of weeks from today, for which the publication or conversion is made|`0`|
|
||
|
|**[-m, --month]**|month in amount of months from today, for which the publication or conversion is made|`0`|
|
||
|
|**[-y, --year]**|year in amount of years from today, for which the publication or conversion is made|`0`|
|
||
|
|
||
|
Example usage in terminal with make the script executable:
|
||
|
|
||
|
```bash
|
||
|
chmod u+x ./cctv-scheduler.py
|
||
|
./cctv-scheduler.py -s --config /home/user/cctv-scheduler/cctv-scheduler.conf
|
||
|
```
|
||
|
|
||
|
Example usage with cron:
|
||
|
|
||
|
```bash
|
||
|
# crontab -e
|
||
|
* * * * * /usr/bin/python3 /home/user/cctv-scheduler/cctv-scheduler.py -b
|
||
|
0 * * * * /usr/bin/python3 /home/user/cctv-scheduler/cctv-scheduler.py -s
|
||
|
1 0 * * * /usr/bin/python3 /home/user/cctv-scheduler/cctv-scheduler.py -c -d -1
|
||
|
7 0 * * 1 /usr/bin/python3 /home/user/cctv-scheduler/cctv-scheduler.py -c -w -1
|
||
|
30 0 1 * * /usr/bin/python3 /home/user/cctv-scheduler/cctv-scheduler.py -c -m -1
|
||
|
36 0 1 1 * /usr/bin/python3 /home/user/cctv-scheduler/cctv-scheduler.py -c -y -1
|
||
|
```
|
||
|
|
||
|
____
|
||
|
|
||
|
## `publisher`.sh
|
||
|
|
||
|
**Description:**
|
||
|
> Uploading MP4 to [Wordpress](https://wordpress.com/) and [Telegram](https://web.telegram.org/).
|
||
|
> Additionally:
|
||
|
>
|
||
|
> - editing [Wordpress](https://codex.wordpress.org/XML-RPC_WordPress_API) page from template
|
||
|
> - recompressing video if size [over 50MB](https://core.telegram.org/bots/api#sendvideo)
|
||
|
>
|
||
|
> This is only a local "proof of conept" for testing and debugging.
|
||
|
|
||
|
**Dependencies:**
|
||
|
>
|
||
|
> - [bash](https://www.gnu.org/software/bash/) (tested version 5.1.4 on [Debian GNU/Linux 11](http://ftp.debian.org/debian/dists/bullseye/))
|
||
|
> - [curl](https://curl.se/download.html) (tested version 7.74 on [Debian GNU/Linux 11](http://ftp.debian.org/debian/dists/bullseye/))
|
||
|
> - [ffmpeg](https://ffmpeg.org/download.html) (tested version 4.3.4 on [Debian GNU/Linux 11](http://ftp.debian.org/debian/dists/bullseye/))
|
||
|
> - [libxml2-utils](https://gitlab.gnome.org/GNOME/libxml2) (tested version 2.9.10 on [Debian GNU/Linux 11](http://ftp.debian.org/debian/dists/bullseye/))
|
||
|
> - [jq](https://stedolan.github.io/jq/download/) (tested version 1.6 on [Debian GNU/Linux 11](http://ftp.debian.org/debian/dists/bullseye/))
|
||
|
>
|
||
|
|
||
|
| POSITION | PARAMETERS | DESCRIPTION | DEFAULT |
|
||
|
|-----------|--------------|------------------------|---------------|
|
||
|
| 1 | **[qn]** |execution without pauses||
|
||
|
| 2 | **[/path/to/conf]** |path to config| `./publisher.conf` |
|
||
|
| 3 | **[-d\|-w\|-m\|-y]** |periods: '' - 0 day \| '-d' - -X day \| '-w' - -X week \| '-m' - -X month \| '-y' - -X year|`''`|
|
||
|
| 4 | **[1\|2\|3..XXX]** |multiplier for period: '' - 1 day\|week\|month\|year|`1`|
|
||
|
| 5 | **[--onlytg\|--onlywp]** |'--onlytg' - only publish to Telegram \|'--onlywp' - only publish to Wordpress||
|
||
|
|
||
|
Example usage in terminal with bash for publish to Telegram today's MP4:
|
||
|
|
||
|
```bash
|
||
|
bash ./publisher.sh - ./publisher.conf - - - - --onlytg
|
||
|
```
|
||
|
|
||
|
Example usage with cron:
|
||
|
|
||
|
```bash
|
||
|
# crontab -e
|
||
|
1 1 * * * bash /home/user/cctv-scheduler/publisher.sh qn - -d
|
||
|
7 1 * * 1 bash /home/user/cctv-scheduler/publisher.sh qn - -w
|
||
|
30 1 1 * * bash /home/user/cctv-scheduler/publisher.sh qn - -m
|
||
|
36 1 1 1 * bash /home/user/cctv-scheduler/publisher.sh qn - -y
|
||
|
```
|