cctv-scheduler/README.md

200 lines
7.6 KiB
Markdown
Raw Normal View History

2023-01-29 16:21:32 +03:00
# cctv-scheduler
2023-03-11 22:20:57 +03:00
2023-01-29 16:21:32 +03:00
PTZ IP-Camera management
2023-03-12 14:27:03 +03:00
____
- [`cctv-scheduler.py`](https://git.hmp.today/pavel.muhortov/cctv-scheduler#cctv-scheduler-py)
- [`converter.sh`](https://git.hmp.today/pavel.muhortov/cctv-scheduler#converter-sh)
- [`publisher.sh`](https://git.hmp.today/pavel.muhortov/cctv-scheduler#publisher-sh)
____
2023-01-29 09:32:54 +03:00
![cctv-scheduler](info/images/cctv-scheduler-0.3.png)
2023-03-11 22:20:57 +03:00
2023-02-12 15:51:56 +03:00
## `Installation`
2023-03-11 22:20:57 +03:00
2023-02-12 15:51:56 +03:00
### `Requirements`
2023-03-11 22:20:57 +03:00
2023-03-05 14:18:11 +03:00
Cameras settings:
2023-03-11 22:20:57 +03:00
>
2023-03-05 15:24:08 +03:00
> - Configuration -> System -> Security -> Authentication -> RTSP Authentication: digest/basic
> - Configuration -> System -> Security -> Authentication -> WEB Authentication: digest/basic
2023-03-05 14:18:11 +03:00
> - Configuration -> Network -> Advanced Settings -> Integration Protocol -> Enable Hikvision-CGI: Enabled
2023-03-05 15:24:08 +03:00
> - Configuration -> Network -> Advanced Settings -> Integration Protocol -> Hikvision-CGI Authentication: digest/basic
2023-03-05 14:18:11 +03:00
2023-02-12 15:51:56 +03:00
Look at the description of dependencies and install the necessary.
2023-03-11 22:20:57 +03:00
2023-02-12 15:51:56 +03:00
### `Downloading`
2023-03-11 22:20:57 +03:00
2023-02-12 15:51:56 +03:00
Download scripts and configs.
2023-03-11 22:20:57 +03:00
2023-02-12 15:51:56 +03:00
```bash
2023-03-12 14:27:03 +03:00
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
2023-02-12 15:51:56 +03:00
wget https://git.hmp.today/pavel.muhortov/cctv-scheduler/raw/branch/master/converter.sh -O /home/user/cctv-scheduler/converter.sh
wget https://git.hmp.today/pavel.muhortov/cctv-scheduler/raw/branch/master/converter.conf -O /home/user/cctv-scheduler/converter.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
```
2023-03-11 22:20:57 +03:00
2023-02-12 15:51:56 +03:00
### `Configuration`
2023-03-11 22:20:57 +03:00
2023-02-12 15:51:56 +03:00
Edit configs.
2023-03-11 22:20:57 +03:00
2023-02-12 15:51:56 +03:00
```bash
2023-03-12 14:27:03 +03:00
nano /home/user/cctv-scheduler/cctv-scheduler.conf
2023-02-12 15:51:56 +03:00
nano /home/user/cctv-scheduler/converter.conf
nano /home/user/cctv-scheduler/publisher.conf
```
2023-03-11 22:20:57 +03:00
2023-02-12 15:51:56 +03:00
### `Scheduler`
2023-03-11 22:20:57 +03:00
2023-02-12 15:51:56 +03:00
Look at examples and edit scheduler tasks:
2023-03-11 22:20:57 +03:00
2023-02-12 15:51:56 +03:00
```bash
crontab -e
```
2023-03-11 22:20:57 +03:00
2023-03-12 14:27:03 +03:00
## `cctv-scheduler`.py
2023-03-11 22:20:57 +03:00
2023-01-29 09:32:54 +03:00
**Description:**
> [Hikvision](https://git.hmp.today/pavel.muhortov/cctv-scheduler/src/branch/master/info/hikvision/manual/isapi.pdf) PTZ IP-Camera management. Media streaming.
2023-01-29 16:21:32 +03:00
> Additionally:
2023-03-11 22:20:57 +03:00
>
2023-02-12 15:10:33 +03:00
> - getting temperature from DS18B20 over SSH,
2023-01-29 16:21:32 +03:00
> - saving pictures to FTP.
2023-02-11 22:08:06 +03:00
>
> This is only a local "proof of conept" for testing and debugging.
2023-01-29 09:32:54 +03:00
**Dependencies:**
2023-03-11 22:20:57 +03:00
>
2023-03-12 14:27:03 +03:00
> - [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/))
2023-01-29 09:32:54 +03:00
2023-03-12 14:27:03 +03:00
| PARAMETERS | DESCRIPTION | DEFAULT|
|-------------|-------------|--------|
|**[-h]**|print help and exit||
|**[-b, --broadcast]**|streaming media to destination|`None`|
2023-03-12 14:27:03 +03:00
|**[-s, --sequences]**|run sequences from config file|`None`|
|**[--config]**|custom configuration file path|`./cctv-scheduler.conf`|
2023-01-29 09:32:54 +03:00
2023-03-12 14:27:03 +03:00
Example usage in terminal with make the script executable:
2023-03-11 22:20:57 +03:00
2023-02-01 13:31:36 +03:00
```bash
2023-03-12 14:27:03 +03:00
chmod u+x ./cctv-scheduler.py
./cctv-scheduler.py -s --config /home/user/cctv-scheduler/cctv-scheduler.conf
2023-01-29 09:32:54 +03:00
```
2023-03-11 22:20:57 +03:00
2023-01-29 16:21:32 +03:00
Example usage with cron:
2023-03-11 22:20:57 +03:00
2023-02-01 13:31:36 +03:00
```bash
# crontab -e
* * * * * /usr/bin/python3 /home/user/cctv-scheduler/cctv-scheduler.py -b
2023-03-12 14:27:03 +03:00
0 * * * * /usr/bin/python3 /home/user/cctv-scheduler/cctv-scheduler.py -s
2023-01-29 09:32:54 +03:00
```
2023-03-11 22:20:57 +03:00
2023-02-01 13:31:36 +03:00
____
2023-03-11 22:20:57 +03:00
2023-02-12 15:51:56 +03:00
## `converter`.sh
2023-03-11 22:20:57 +03:00
2023-02-01 13:31:36 +03:00
**Description:**
> JPEG to MP4 converter.
2023-02-11 22:08:06 +03:00
>
> This is only a local "proof of conept" for testing and debugging.
2023-02-01 13:31:36 +03:00
**Dependencies:**
2023-03-11 22:20:57 +03:00
>
2023-02-12 15:10:33 +03:00
> - [bash](https://www.gnu.org/software/bash/) (tested version 5.1.4 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/))
2023-02-01 13:31:36 +03:00
> - filesystem organization:
2023-03-11 22:20:57 +03:00
>
2023-02-01 13:31:36 +03:00
>```bash
> # filesystem organisation 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
>```
| POSITION | PARAMETERS | DESCRIPTION | DEFAULT |
|-----------|--------------|------------------------|---------------|
| 1 | **[qn]** |execution without pauses||
2023-03-12 14:27:03 +03:00
| 2 | **[/path/to/conf]** |path to config| `./converter.conf` |
| 3 | **[-d\|-w\|-m\|-y]** |periods: '' - today \| '-d' - yesterday \| '-w' - last week \| '-m' - last month \| '-y' - last year|`''`|
2023-02-01 13:31:36 +03:00
Example usage in terminal with bash for today's MP4 making:
2023-03-11 22:20:57 +03:00
2023-02-01 13:31:36 +03:00
```bash
bash ./converter.sh - ./converter.conf
```
2023-03-11 22:20:57 +03:00
2023-02-01 13:31:36 +03:00
Example usage with cron:
2023-03-11 22:20:57 +03:00
2023-02-01 13:31:36 +03:00
```bash
# crontab -e
1 0 * * * bash /home/user/cctv-scheduler/converter.sh qn - -d
7 0 * * 1 bash /home/user/cctv-scheduler/converter.sh qn - -w
30 0 1 * * bash /home/user/cctv-scheduler/converter.sh qn - -m
36 0 1 1 * bash /home/user/cctv-scheduler/converter.sh qn - -y
2023-02-11 22:08:06 +03:00
```
2023-03-11 22:20:57 +03:00
2023-02-11 22:08:06 +03:00
____
2023-03-11 22:20:57 +03:00
2023-02-12 15:51:56 +03:00
## `publisher`.sh
2023-03-11 22:20:57 +03:00
2023-02-11 22:08:06 +03:00
**Description:**
2023-02-12 15:10:33 +03:00
> Uploading MP4 to [Wordpress](https://wordpress.com/) and [Telegram](https://web.telegram.org/).
2023-02-11 22:08:06 +03:00
> Additionally:
2023-03-11 22:20:57 +03:00
>
2023-02-12 15:10:33 +03:00
> - 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)
2023-02-11 22:08:06 +03:00
>
> This is only a local "proof of conept" for testing and debugging.
**Dependencies:**
2023-03-11 22:20:57 +03:00
>
2023-02-12 15:10:33 +03:00
> - [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/))
2023-02-11 22:08:06 +03:00
>
2023-02-01 13:31:36 +03:00
2023-02-11 22:08:06 +03:00
| POSITION | PARAMETERS | DESCRIPTION | DEFAULT |
|-----------|--------------|------------------------|---------------|
| 1 | **[qn]** |execution without pauses||
2023-03-12 14:27:03 +03:00
| 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`|
2023-02-11 22:08:06 +03:00
| 5 | **[--onlytg\|--onlywp]** |'--onlytg' - only publish to Telegram \|'--onlywp' - only publish to Wordpress||
2023-03-11 22:20:57 +03:00
Example usage in terminal with bash for publish to Telegram today's MP4:
2023-02-11 22:08:06 +03:00
```bash
2023-03-11 22:20:57 +03:00
bash ./publisher.sh - ./publisher.conf - - - - --onlytg
2023-02-11 22:08:06 +03:00
```
2023-03-11 22:20:57 +03:00
2023-02-11 22:08:06 +03:00
Example usage with cron:
2023-03-11 22:20:57 +03:00
2023-02-11 22:08:06 +03:00
```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
2023-02-01 13:31:36 +03:00
```