@@ -202,22 +202,20 @@ def test_deprecated_output_modules_emits_warning_on_import():
202202 from scenedetect .video_splitter import split_video_ffmpeg as _
203203
204204
205- class TestImageExtractorTemporalMargin :
206- """Tests for _ImageExtractor temporal margin functionality using PTS-based selection."""
205+ class TestImageExtractorMargin :
206+ """Tests for _ImageExtractor margin functionality using PTS-based selection."""
207207
208- def test_temporal_margin_uses_seconds_not_frames (self ):
209- """Test that temporal_margin operates on presentation time, not frame count.
208+ def test_margin_uses_seconds_not_frames (self ):
209+ """Test that margin operates on presentation time, not frame count.
210210
211211 With a 0.1s margin on a scene from 0s to 3s at 30fps:
212212 - First image should be at ~0.1s (frame 3)
213213 - Last image should be at ~2.9s (frame 87)
214214 """
215215 from scenedetect .output .image import _ImageExtractor
216216
217- # 30 fps, 0.1s temporal margin
218- extractor = _ImageExtractor (
219- num_images = 3 , temporal_margin = FrameTimecode (timecode = 0.1 , fps = 30.0 )
220- )
217+ # 30 fps, 0.1s margin
218+ extractor = _ImageExtractor (num_images = 3 , margin = FrameTimecode (timecode = 0.1 , fps = 30.0 ))
221219
222220 # Scene from frame 0 to 90 (0s to 3s at 30fps)
223221 scene_list = [
@@ -233,18 +231,16 @@ def test_temporal_margin_uses_seconds_not_frames(self):
233231 # Last image: end.seconds - margin = 3.0 - 0.1 = 2.9s → frame 87
234232 assert timecodes [2 ].seconds == pytest .approx (2.9 , abs = 0.05 )
235233
236- def test_temporal_margin_different_framerates (self ):
237- """Test temporal margin works consistently across different framerates.
234+ def test_margin_different_framerates (self ):
235+ """Test margin works consistently across different framerates.
238236
239- The same temporal margin (0.1s) should result in different frame offsets
237+ The same margin (0.1s) should result in different frame offsets
240238 but the same time offset regardless of framerate.
241239 """
242240 from scenedetect .output .image import _ImageExtractor
243241
244242 for fps in [24.0 , 25.0 , 30.0 , 60.0 ]:
245- extractor = _ImageExtractor (
246- num_images = 3 , temporal_margin = FrameTimecode (timecode = 0.1 , fps = fps )
247- )
243+ extractor = _ImageExtractor (num_images = 3 , margin = FrameTimecode (timecode = 0.1 , fps = fps ))
248244 # 3 second scene
249245 scene_list = [
250246 (FrameTimecode (0 , fps = fps ), FrameTimecode (int (3 * fps ), fps = fps )),
@@ -256,14 +252,12 @@ def test_temporal_margin_different_framerates(self):
256252 assert timecodes [0 ].seconds == pytest .approx (0.1 , abs = 0.05 ), f"Failed at { fps } fps"
257253 assert timecodes [2 ].seconds == pytest .approx (2.9 , abs = 0.05 ), f"Failed at { fps } fps"
258254
259- def test_temporal_margin_clamped_to_scene_bounds (self ):
260- """Test that temporal margin is clamped when scene is shorter than 2x margin."""
255+ def test_margin_clamped_to_scene_bounds (self ):
256+ """Test that margin is clamped when scene is shorter than 2x margin."""
261257 from scenedetect .output .image import _ImageExtractor
262258
263259 # 0.5s margin on a 0.5s scene - should clamp to scene bounds
264- extractor = _ImageExtractor (
265- num_images = 3 , temporal_margin = FrameTimecode (timecode = 0.5 , fps = 30.0 )
266- )
260+ extractor = _ImageExtractor (num_images = 3 , margin = FrameTimecode (timecode = 0.5 , fps = 30.0 ))
267261
268262 # Scene from frame 0 to 15 (0s to 0.5s at 30fps)
269263 scene_list = [
@@ -276,13 +270,11 @@ def test_temporal_margin_clamped_to_scene_bounds(self):
276270 for tc in timecodes :
277271 assert 0.0 <= tc .seconds <= 0.5
278272
279- def test_temporal_margin_zero (self ):
280- """Test that zero temporal margin selects frames at scene boundaries."""
273+ def test_margin_zero (self ):
274+ """Test that zero margin selects frames at scene boundaries."""
281275 from scenedetect .output .image import _ImageExtractor
282276
283- extractor = _ImageExtractor (
284- num_images = 3 , temporal_margin = FrameTimecode (timecode = 0.0 , fps = 30.0 )
285- )
277+ extractor = _ImageExtractor (num_images = 3 , margin = FrameTimecode (timecode = 0.0 , fps = 30.0 ))
286278
287279 scene_list = [
288280 (FrameTimecode (30 , fps = 30.0 ), FrameTimecode (90 , fps = 30.0 )),
@@ -295,11 +287,11 @@ def test_temporal_margin_zero(self):
295287 # Last image near scene end (3s)
296288 assert timecodes [2 ].seconds == pytest .approx (2.97 , abs = 0.1 )
297289
298- def test_temporal_margin_with_pts_timecodes (self ):
299- """Test temporal margin works correctly with PTS-based FrameTimecodes.
290+ def test_margin_with_pts_timecodes (self ):
291+ """Test margin works correctly with PTS-based FrameTimecodes.
300292
301293 PTS (Presentation Time Stamp) based timecodes use a time_base rather than
302- a fixed framerate. This test verifies that temporal margin calculations
294+ a fixed framerate. This test verifies that margin calculations
303295 work correctly when scenes are defined using PTS.
304296 """
305297 from fractions import Fraction
@@ -314,10 +306,10 @@ def test_temporal_margin_with_pts_timecodes(self):
314306 start = FrameTimecode (timecode = Timecode (pts = 0 , time_base = time_base ), fps = 30.0 )
315307 end = FrameTimecode (timecode = Timecode (pts = 3000 , time_base = time_base ), fps = 30.0 )
316308
317- # 100ms (0.1s) temporal margin, also as PTS-based
309+ # 100ms (0.1s) margin, also as PTS-based
318310 margin = FrameTimecode (timecode = Timecode (pts = 100 , time_base = time_base ), fps = 30.0 )
319311
320- extractor = _ImageExtractor (num_images = 3 , temporal_margin = margin )
312+ extractor = _ImageExtractor (num_images = 3 , margin = margin )
321313
322314 scene_list = [(start , end )]
323315 timecode_list = extractor .generate_timecode_list (scene_list )
@@ -330,7 +322,7 @@ def test_temporal_margin_with_pts_timecodes(self):
330322 # Last image: 3s - 0.1s margin = 2.9s
331323 assert timecodes [2 ].seconds == pytest .approx (2.9 , abs = 0.05 )
332324
333- def test_temporal_margin_pts_preserves_time_base (self ):
325+ def test_margin_pts_preserves_time_base (self ):
334326 """Test that output timecodes preserve the time_base from input PTS timecodes."""
335327 from fractions import Fraction
336328
@@ -346,7 +338,7 @@ def test_temporal_margin_pts_preserves_time_base(self):
346338 # 0.1s margin = 9000 pts at 1/90000 time_base
347339 margin = FrameTimecode (timecode = Timecode (pts = 9000 , time_base = time_base ), fps = 30.0 )
348340
349- extractor = _ImageExtractor (num_images = 2 , temporal_margin = margin )
341+ extractor = _ImageExtractor (num_images = 2 , margin = margin )
350342
351343 scene_list = [(start , end )]
352344 timecode_list = extractor .generate_timecode_list (scene_list )
@@ -357,7 +349,7 @@ def test_temporal_margin_pts_preserves_time_base(self):
357349 assert timecodes [1 ].seconds == pytest .approx (1.9 , abs = 0.01 )
358350
359351 def test_frame_margin_backwards_compatibility (self ):
360- """Test that frame_margin still works when temporal_margin is not set.
352+ """Test that frame_margin still works when margin is not set.
361353
362354 This ensures backwards compatibility with existing code using frame_margin.
363355 """
@@ -380,16 +372,16 @@ def test_frame_margin_backwards_compatibility(self):
380372 # Last image: 3s - 3 frames = 2.9s
381373 assert timecodes [2 ].seconds == pytest .approx (2.9 , abs = 0.05 )
382374
383- def test_temporal_margin_overrides_frame_margin (self ):
384- """Test that temporal_margin takes precedence over frame_margin when both are set."""
375+ def test_margin_overrides_frame_margin (self ):
376+ """Test that margin takes precedence over frame_margin when both are set."""
385377 from scenedetect .output .image import _ImageExtractor
386378
387- # Set frame_margin to 30 frames (1s at 30fps), but temporal_margin to 0.1s
388- # temporal_margin should win
379+ # Set frame_margin to 30 frames (1s at 30fps), but margin to 0.1s
380+ # margin should win
389381 extractor = _ImageExtractor (
390382 num_images = 3 ,
391383 frame_margin = 30 , # Would be 1s at 30fps
392- temporal_margin = FrameTimecode (timecode = 0.1 , fps = 30.0 ), # 0.1s
384+ margin = FrameTimecode (timecode = 0.1 , fps = 30.0 ), # 0.1s
393385 )
394386
395387 scene_list = [
@@ -398,6 +390,6 @@ def test_temporal_margin_overrides_frame_margin(self):
398390 timecode_list = extractor .generate_timecode_list (scene_list )
399391 timecodes = list (timecode_list [0 ])
400392
401- # Should use temporal_margin (0.1s), not frame_margin (1s)
393+ # Should use margin (0.1s), not frame_margin (1s)
402394 assert timecodes [0 ].seconds == pytest .approx (0.1 , abs = 0.05 )
403395 assert timecodes [2 ].seconds == pytest .approx (2.9 , abs = 0.05 )
0 commit comments