Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add flags to download.sh, improve README
  • Loading branch information
Helias committed Sep 11, 2022
commit cacf6a5acf844010c6ff1b3596ed3858f55a1ec0
61 changes: 53 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@

This repository contains different bash scripts and commands for reolink camera.

Comment thread
Helias marked this conversation as resolved.
Resolved
## download.sh
### Requirements

This script uses `ffmpeg` to download via RTSP the video and audio from your camera saving it in the MP4 format, the name will start with the `date` of the day (ex. `2022-08-26--22-00-00-capture-0000.mp4`) and a file will be recorded and saved every `$TIME` seconds.
The name of the files starts with a date to make it easier the management of the files, like removing easily all the records of a specific month, day or year.
These scripts use **ffmpeg**, to install it you can:

```bash
apt install ffmpeg # linux debian-based
brew install ffmpeg # mac
```

### Why ffmpeg?
If you are using Windows you can download it from [here](https://ffmpeg.org/download.html).

I tried **openRTSP** ❌ but half of the video in the MP4 format is without audio and I don't know why.
<details>
<summary>Why ffmpeg?</summary>
I tried **openRTSP** ❌ but half of the video in the MP4 format is without audio and I don't know why.

example:

```
```bash
openRTSP -D 1 -c -B 10000000 -b 10000000 -q -Q -F cam_eight -d 28800 -P 10 -t rtsp://"admin":"mypassword"@192.168.0.176:554
```

Expand All @@ -23,12 +29,51 @@ I tried **VLC** ❌ but I got some issues saving the files with the audio and ma

example command:

```
```bash
cvlc rtsp://admin:password@192.168.0.176:554//h264Preview_01_main --sout=file/ts:mystream.mpg
```

FFmpeg was the best, so I chose it. ✅

## clean_record.sh
</details>

---

### Usage

Download and use the script:

```bash
git clone https://github.com/ReolinkCameraAPI/scripts
cd scripts
```

### download.sh

How to use it:

```bash
chmod +x download.sh
./download.sh -u myusername -p mypassowrd -i 192.168.1.197 -t 60 -n 554 -o tmp
```

- `-u` username of your camera
- `-p` password of your camera
- `-i` camera local IP address
- `-t` is the time in seconds that any file will contain (default value 60)
- `-n` is the port (default value 554)
- `-o` output directory path (default `.`, the current directory)

To stop the execution you can type `Ctrl + C`.

This script uses `ffmpeg` to download via RTSP the video and audio from your camera saving it in the MP4 format, the name will start with the `date` of the day (ex. `2022-08-26--22-00-00-capture-0000.mp4`) and a file will be recorded and saved every `$TIME` seconds.
The name of the files starts with a date to make it easier the management of the files, like removing easily all the records of a specific month, day or year.

### clean_record.sh

```bash
chmod +x clean_record.sh
./clean_record.sh
```

This script deletes all the records inside a `tmp` directory of the previous month.
22 changes: 16 additions & 6 deletions download.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
USERNAME="admin"
PASSWORD="mypassword"
TIME=60 # seconds
IP="192.168.1.197"
# default parameters value
TIME=60
PORT=554
OUTPUT_PATH="."

while getopts u:p:i:t:n:o: flag
do
case "${flag}" in
u) USERNAME=${OPTARG};;
p) PASSWORD=${OPTARG};;
i) IP=${OPTARG};;
t) TIME=${OPTARG};;
n) PORT=${OPTARG};;
o) OUTPUT_PATH=${OPTARG};;
esac
done

ffmpeg -i rtsp://$USERNAME:$PASSWORD@$IP:$PORT/h264Preview_01_main \
Comment thread
Helias marked this conversation as resolved.
Resolved
-c copy \
Expand All @@ -12,5 +23,4 @@ ffmpeg -i rtsp://$USERNAME:$PASSWORD@$IP:$PORT/h264Preview_01_main \
-segment_time $TIME \
-strftime 1 \
-segment_format mp4 \
"%Y-%m-%d--%H-%M-%S--capture-%04d.mp4"

"$OUTPUT_PATH/%Y-%m-%d--%H-%M-%S--capture-%04d.mp4"