Skip to content

feat: example video review application based on motion recordings #77

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

Merged
merged 3 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 16 additions & 6 deletions examples/download_motions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,32 @@ def read_config(props_path: str) -> dict:

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

ip = config.get('camera', 'ip')
un = config.get('camera', 'username')
pw = config.get('camera', 'password')

# Connect to camera
cam = Camera(ip, un, pw)
cam = Camera(ip, un, pw, https=True)

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

dl_dir = os.path.join(os.path.expanduser('~'), 'Downloads')
start = dt.now() - timedelta(days=1)
end = dt.combine(start, dt.max.time())
processed_motions += cam.get_motion_files(start=start, end=end, streamtype='main', channel=1)
Comment on lines 36 to +43
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 41-43 seems a bit superfluous to me.

why do you need to re-assign start and end here. can't we just set start to 1 day ago instead of start of today? Same with end, can't we just set it from the beginning to dt.now()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My camera (maybe others, but my for sure) does not support searches that span more than a single day.
So the first search is for "today", and the second one for "yesterday", which is how I make sure to cover > 24h and see all videos.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah okay, that makes sense! Thank you

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My current use case is every day, review the videos of the past day.
The web app and mobile apps expose a calendar, but I don't think it works all that great. So longer term maybe we want a GUI to select what date range to look for (and I can make it default to whatever I like).



output_files = []
for i, motion in enumerate(processed_motions):
fname = motion['filename']
# Download the mp4
resp = cam.get_file(fname, output_path=os.path.join(dl_dir, f'motion_event_{i}.mp4'))
print("Getting %s" % (fname))
output_path = os.path.join('/tmp/', fname.replace('/','_'))
output_files += output_path
if not os.path.isfile(output_path):
resp = cam.get_file(fname, output_path=output_path)
Loading