-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add README and useful bash scripts #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Helias
wants to merge
6
commits into
ReolinkCameraAPI:master
Choose a base branch
from
Helias:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
eda90cb
feat: add README and useful bash scripts
Helias fa145c9
Update README.md
Helias 1e254ce
Update README.md
Helias cacf6a5
feat: add flags to download.sh, improve README
Helias c1b065c
chore: solve merge conflicts
Helias b59bf4c
chore: add options in clean records.sh
Helias File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
## Reolink Camera Utility Scripts | ||
|
||
This repository contains different bash scripts and commands for reolink camera. | ||
|
||
### Requirements | ||
|
||
These scripts use **ffmpeg**, to install it you can: | ||
|
||
```bash | ||
apt install ffmpeg # linux debian-based | ||
brew install ffmpeg # mac | ||
``` | ||
|
||
If you are using Windows you can download it from [here](https://ffmpeg.org/download.html). | ||
|
||
<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 | ||
``` | ||
|
||
source of command and explanation: https://superuser.com/questions/766437/capture-rtsp-stream-from-ip-camera-and-store | ||
|
||
I tried **VLC** ❌ but I got some issues saving the files with the audio and managing it. | ||
|
||
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. ✅ | ||
|
||
</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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
PATH="tmp/" | ||
MONTHES=1 | ||
|
||
while getopts p:m: flag | ||
do | ||
case "${flag}" in | ||
p) PATH=${OPTARG};; | ||
m) MONTHES=${OPTARG};; | ||
esac | ||
done | ||
|
||
|
||
LAST_MONTH=$(date --date='-$MONTHES month' +'%Y-%m') | ||
rm "$PATH$LAST_MONTH-"* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# 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 \ | ||
Helias marked this conversation as resolved.
Show resolved
Hide resolved
|
||
-c copy \ | ||
-map 0 \ | ||
-reset_timestamps 1 \ | ||
-f segment \ | ||
-segment_time $TIME \ | ||
-strftime 1 \ | ||
-segment_format mp4 \ | ||
"$OUTPUT_PATH/%Y-%m-%d--%H-%M-%S--capture-%04d.mp4" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.