File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ NB_MODULE(_viteo, m) {
4040 nb::gil_scoped_release release;
4141 frame_data = self.next_frame ();
4242 }
43+ if (!frame_data) return nb::none ();
4344 return create_mlx_array (frame_data, self.height (), self.width ());
4445 },
4546 " Get next frame as MLX array (None when done)" )
Original file line number Diff line number Diff line change @@ -123,6 +123,38 @@ def test_iterator(sample_video):
123123 assert count == 10
124124
125125
126+ def test_run_to_end (sample_video ):
127+ """Test running through all frames to the end."""
128+ path = sample_video ["path" ]
129+ if not path .exists ():
130+ pytest .skip (f"Test video not found: { path } " )
131+
132+ with viteo .open (path ) as video :
133+ frame_count = 0
134+ for frame in video :
135+ frame_count += 1
136+
137+ assert frame_count == video .total_frames
138+
139+
140+ def test_last_frame_is_none (sample_video ):
141+ path = sample_video ["path" ]
142+ if not path .exists ():
143+ pytest .skip (f"Test video not found: { path } " )
144+
145+ i = 0
146+ with viteo .open (path ) as video :
147+ while True :
148+ frame = video .next_frame ()
149+ if not isinstance (frame , mx .array ):
150+ break
151+
152+ i += 1
153+
154+ assert frame is None
155+ assert i == video .total_frames
156+
157+
126158def test_reset (sample_video ):
127159 """Test reset functionality."""
128160 path = sample_video ["path" ]
You can’t perform that action at this time.
0 commit comments