From 98f22e59dd0778156c80c7904b12979f7a5f7a96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ascenso?= <80411357+joaoascenso02@users.noreply.github.com> Date: Tue, 23 Sep 2025 15:03:29 +0100 Subject: [PATCH] Fix randint error in video tutorial by casting frame count diff to int In frames_from_video_file, cv2.VideoCapture().get(cv2.CAP_PROP_FRAME_COUNT) returns a float. This causes random.randint to fail with: TypeError: 'float' object cannot be interpreted as an integer Fix: cast (video_length - need_length) to int before passing to randint. --- site/en/tutorials/load_data/video.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/en/tutorials/load_data/video.ipynb b/site/en/tutorials/load_data/video.ipynb index 4243940494..67b5474da9 100644 --- a/site/en/tutorials/load_data/video.ipynb +++ b/site/en/tutorials/load_data/video.ipynb @@ -630,7 +630,7 @@ " if need_length > video_length:\n", " start = 0\n", " else:\n", - " max_start = video_length - need_length\n", + " max_start = int(video_length - need_length)\n", " start = random.randint(0, max_start + 1)\n", "\n", " src.set(cv2.CAP_PROP_POS_FRAMES, start)\n",