From 2982e1d186ee28e11f8ac3d413e64018200ef79d Mon Sep 17 00:00:00 2001 From: leminlimez <59540996+leminlimez@users.noreply.github.com> Date: Thu, 27 Mar 2025 12:54:09 -0400 Subject: [PATCH] add 300 fps limit --- controllers/video_handler.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/controllers/video_handler.py b/controllers/video_handler.py index c1b41e6..7b334c7 100644 --- a/controllers/video_handler.py +++ b/controllers/video_handler.py @@ -43,6 +43,10 @@ def get_thumbnail_from_contents(contents: bytes, output_file: str = None): def create_caml(video_path: str, output_file: str, update_label=lambda x: None): cam = cv2.VideoCapture(video_path) assets_path = os.path.join(output_file, "assets") + frame_count = int(cam.get(cv2.CAP_PROP_FRAME_COUNT)) + FRAME_LIMIT = 300 + if frame_count > FRAME_LIMIT: + raise Exception(f"Videos must be under {FRAME_LIMIT} fps to loop. Either reduce the frame rate or make it shorter.") try: # creating a folder named data if not os.path.exists(assets_path): @@ -59,7 +63,6 @@ def create_caml(video_path: str, output_file: str, update_label=lambda x: None): with open(os.path.join(output_file, "main.caml"), "w") as caml: # write caml header fps = cam.get(cv2.CAP_PROP_FPS) - frame_count = int(cam.get(cv2.CAP_PROP_FRAME_COUNT)) duration = frame_count / fps caml.write(f"""