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

Conversation

sven337
Copy link
Contributor

@sven337 sven337 commented Aug 13, 2024

This PR adds a GUI app to review videos from Linux in a GUI app, since nothing exists to do it well.
The best UI I found is the Reolink mobile app, and critically this GUI replicates the "trigger source" information so that you can tell at a glance why the camera was recording (this is based on the reolink_aio reverse engineered trigger sources, I know for a fact they are not fully correct and may try to improve them in the future).

In this series are some fixes to the API code, fixes to download_motions proper, and then the rest of the changes turn download_motions into a full-featured pyqt app for exploration of the videos.
Screenshot:
screenshot_2024-08-13_15-22-43

Features:

  • list videos and present a sortable table
  • list trigger causes
  • play video on click, start 5 seconds in (to skip pre-record) at 2x playback speed by default
  • mpv button to open the video in MPV

Requires "video_storage_dir" to be defined in the configuration file (I use /tmp).

@Benehiko
Copy link
Member

Hey @sven337 thank you for the awesome contribution! :)

I would like to suggest we move the new code from download_motions.py into a new example file. Something like motions_gui.py (other suggested names are welcome). Fixes to download_motions.py can remain, but I think it's important that users looking at the example code don't get too overwhelmed, especially if they'd like to do something simple at first.

@Benehiko Benehiko self-assigned this Aug 13, 2024
@sven337
Copy link
Contributor Author

sven337 commented Aug 13, 2024

Thanks, I am still iterating on this GUI app, will move it to a separate file.
Fixes to download_motions are still needed as far as my camera is concerned (out of the box it failed).
Will update.

@sven337
Copy link
Contributor Author

sven337 commented Aug 14, 2024

PR updated, the download_motion script gets a few fixes but otherwise stays the same, everything is in video_review_gui.py

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.
- 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
Copy link
Member

@Benehiko Benehiko left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution, this is honestly great stuff! I just have one question and then I think we can merge it :)

Comment on lines 36 to +43
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)
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).

@Benehiko Benehiko changed the title Reolink Video Review GUI app based on download_motions feat: example video review application based on motion recordings Aug 14, 2024
@Benehiko Benehiko merged commit ba49720 into ReolinkCameraAPI:master Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants