Skip to content

Commit ba49720

Browse files
authored
feat: example video review application based on motion recordings (ReolinkCameraAPI#77)
* get_motion_files: take channel as argument For "TrackMix" with two lenses, channel 0 is the wide-angle lens while channel 1 is the telephotolens. The "action" parameter of the Search request is documented in Reolink's PDF as being "0", yet this code passes "1". Not modified in this change as it did not seem to prevent correct operation on my trackmix wifi. * download_motions: various fixes - use https (needed on Trackmix wifi) - download videos from the start of today until right now (search cannot span more than a given day) - download videos from the start of yesterday until start of today (to get good coverage, given that spanning more than a day is impossible) - search videos for both channels in main stream - write file names to disk as they are on the camera for later parsing * examples: add Video Review GUI Some documentation here: https://github.com/sven337/ReolinkLinux/wiki#reolink-video-review-gui
1 parent 701ff9e commit ba49720

File tree

3 files changed

+487
-8
lines changed

3 files changed

+487
-8
lines changed

examples/download_motions.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,32 @@ def read_config(props_path: str) -> dict:
2323

2424
# Read in your ip, username, & password
2525
# (NB! you'll likely have to create this file. See tests/test_camera.py for details on structure)
26-
config = read_config('../secrets.cfg')
26+
config = read_config('camera.cfg')
2727

2828
ip = config.get('camera', 'ip')
2929
un = config.get('camera', 'username')
3030
pw = config.get('camera', 'password')
3131

3232
# Connect to camera
33-
cam = Camera(ip, un, pw)
33+
cam = Camera(ip, un, pw, https=True)
3434

35-
start = (dt.now() - timedelta(hours=1))
35+
start = dt.combine(dt.now(), dt.min.time())
3636
end = dt.now()
3737
# Collect motion events between these timestamps for substream
38-
processed_motions = cam.get_motion_files(start=start, end=end, streamtype='sub')
38+
processed_motions = cam.get_motion_files(start=start, end=end, streamtype='main', channel=0)
39+
processed_motions += cam.get_motion_files(start=start, end=end, streamtype='main', channel=1)
3940

40-
dl_dir = os.path.join(os.path.expanduser('~'), 'Downloads')
41+
start = dt.now() - timedelta(days=1)
42+
end = dt.combine(start, dt.max.time())
43+
processed_motions += cam.get_motion_files(start=start, end=end, streamtype='main', channel=1)
44+
45+
46+
output_files = []
4147
for i, motion in enumerate(processed_motions):
4248
fname = motion['filename']
4349
# Download the mp4
44-
resp = cam.get_file(fname, output_path=os.path.join(dl_dir, f'motion_event_{i}.mp4'))
50+
print("Getting %s" % (fname))
51+
output_path = os.path.join('/tmp/', fname.replace('/','_'))
52+
output_files += output_path
53+
if not os.path.isfile(output_path):
54+
resp = cam.get_file(fname, output_path=output_path)

0 commit comments

Comments
 (0)