From 9243c00c686f9bf5beab6ab3b34b2905c716f1e3 Mon Sep 17 00:00:00 2001 From: Sven337 Date: Sun, 8 Sep 2024 22:20:57 +0200 Subject: [PATCH 1/3] when getting highres, remove corresponding sub stream and re-parent tree --- examples/video_review_gui.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/examples/video_review_gui.py b/examples/video_review_gui.py index 011d8eb..e32dea6 100644 --- a/examples/video_review_gui.py +++ b/examples/video_review_gui.py @@ -375,8 +375,28 @@ def add_video(self, video_path): # Find a potentially pre-existing channel0 item for this datetime, if so, add as a child # This lets channel1 appear as a child, but also main & sub videos appear in the same group channel_0_item = self.find_channel_0_item(start_datetime) + if channel_0_item: - channel_0_item.addChild(video_item) + # Check if the current item is a main stream and the existing channel_0_item is a sub stream + if "RecM" in base_file_name and "RecS" in channel_0_item.text(1): + # Make the current main stream item the new parent + new_parent = video_item + # Move all children of the sub stream item to the new main stream item + while channel_0_item.childCount() > 0: + child = channel_0_item.takeChild(0) + new_parent.addChild(child) + # Remove the old sub stream item + parent = channel_0_item.parent() + if parent: + parent.removeChild(channel_0_item) + else: + index = self.video_tree.indexOfTopLevelItem(channel_0_item) + self.video_tree.takeTopLevelItem(index) + # Add the new main stream item as a top-level item + self.video_tree.addTopLevelItem(new_parent) + else: + # If it's not a main stream replacing a sub stream, add as a child as before + channel_0_item.addChild(video_item) else: self.video_tree.addTopLevelItem(video_item) From 6c527a5b97e43b2aa0580e4c92b26825e29b88b8 Mon Sep 17 00:00:00 2001 From: Sven337 Date: Mon, 9 Sep 2024 11:03:01 +0200 Subject: [PATCH 2/3] use sub instead of main by default now that GetHighRes is there --- examples/video_review_gui.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/video_review_gui.py b/examples/video_review_gui.py index e32dea6..83de09a 100644 --- a/examples/video_review_gui.py +++ b/examples/video_review_gui.py @@ -612,7 +612,7 @@ def signal_handler(sig, frame): signal.signal(signal.SIGINT, signal_handler) parser = argparse.ArgumentParser(description="Reolink Video Review GUI") - parser.add_argument('--sub', action='store_true', help="Search for sub channel instead of main channel") + parser.add_argument('--main', action='store_true', help="Search for main channel instead of sub channel") parser.add_argument('files', nargs='*', help="Optional video file names to process") args = parser.parse_args() @@ -629,7 +629,7 @@ def signal_handler(sig, frame): start = dt.combine(dt.now(), dt.min.time()) end = dt.now() - streamtype = 'sub' if args.sub else 'main' + streamtype = 'sub' if not args.main else 'main' processed_motions = cam.get_motion_files(start=start, end=end, streamtype=streamtype, channel=0) processed_motions += cam.get_motion_files(start=start, end=end, streamtype=streamtype, channel=1) From 3f517acb0f5c4b14e4083ff5f5f1bfef93f034f3 Mon Sep 17 00:00:00 2001 From: Sven337 Date: Sat, 21 Sep 2024 22:27:44 +0200 Subject: [PATCH 3/3] some file sizes are 0 (recording in progress?) --- examples/video_review_gui.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/video_review_gui.py b/examples/video_review_gui.py index 83de09a..6327dca 100644 --- a/examples/video_review_gui.py +++ b/examples/video_review_gui.py @@ -56,7 +56,7 @@ def parse_filename(file_name): # https://github.com/sven337/ReolinkLinux/wiki/Figuring-out-the-file-names#file-name-structure pattern = r'.*?Mp4Record_(\d{4}-\d{2}-\d{2})_Rec[MS](\d)(\d)_(DST)?(\d{8})_(\d{6})_(\d{6})' v3_suffix = r'.*_(\w{4,8})_(\w{4,8})\.mp4' - v9_suffix = r'.*_(\d)_(\w{7})(\w{7})_(\w{4,8})\.mp4' + v9_suffix = r'.*_(\d)_(\w{7})(\w{7})_(\w{1,8})\.mp4' match = re.match(pattern, file_name) out = {} @@ -444,6 +444,7 @@ def on_download_complete(self, video_path, success): item = self.find_item_by_path(os.path.basename(video_path)) if not item: print(f"on_download_complete {video_path} did not find item?!") + return item.setForeground(1, QBrush(QColor(0, 0, 0))) # Black color for normal text font = item.font(1) font.setItalic(False)