3838)
3939from scenedetect ._cli .context import USER_CONFIG , CliContext , check_split_video_requirements
4040from scenedetect .backends import AVAILABLE_BACKENDS
41+ from scenedetect .common import FrameTimecode
4142from scenedetect .detectors import (
4243 AdaptiveDetector ,
4344 ContentDetector ,
@@ -1400,8 +1401,17 @@ def split_video_command(
14001401 metavar = "N" ,
14011402 default = None ,
14021403 type = click .INT ,
1403- help = "Number of frames to ignore at beginning/end of scenes when saving images. Controls temporal padding on scene boundaries.%s"
1404- % (USER_CONFIG .get_help_string ("save-images" , "num-images" )),
1404+ help = "[DEPRECATED] Use --temporal-margin instead. Number of frames to ignore at beginning/end of scenes when saving images.%s"
1405+ % (USER_CONFIG .get_help_string ("save-images" , "frame-margin" )),
1406+ )
1407+ @click .option (
1408+ "-M" ,
1409+ "--temporal-margin" ,
1410+ metavar = "TIME" ,
1411+ default = None ,
1412+ type = click .STRING ,
1413+ help = "Amount of time to ignore at the beginning/end of each scene. Discards frame-margin if set. Can be specified as seconds (0.1), frames (3), or timecode (00:00:00.100).%s"
1414+ % (USER_CONFIG .get_help_string ("save-images" , "temporal-margin" )),
14051415)
14061416@click .option (
14071417 "--scale" ,
@@ -1442,6 +1452,7 @@ def save_images_command(
14421452 png : bool = False ,
14431453 compression : ty .Optional [int ] = None ,
14441454 frame_margin : ty .Optional [int ] = None ,
1455+ temporal_margin : ty .Optional [str ] = None ,
14451456 scale : ty .Optional [float ] = None ,
14461457 height : ty .Optional [int ] = None ,
14471458 width : ty .Optional [int ] = None ,
@@ -1487,6 +1498,14 @@ def save_images_command(
14871498 raise click .BadParameter ("\n " .join (error_strs ), param_hint = "save-images" )
14881499 output = ctx .config .get_value ("save-images" , "output" , output )
14891500
1501+ # Get temporal_margin value (from CLI arg or config), converting to FrameTimecode
1502+ temporal_margin_value = ctx .config .get_value ("save-images" , "temporal-margin" , temporal_margin )
1503+ temporal_margin_tc = None
1504+ if temporal_margin_value is not None :
1505+ temporal_margin_tc = FrameTimecode (
1506+ timecode = temporal_margin_value , fps = ctx .video_stream .frame_rate
1507+ )
1508+
14901509 save_images_args = {
14911510 "encoder_param" : compression if png else quality ,
14921511 "frame_margin" : ctx .config .get_value ("save-images" , "frame-margin" , frame_margin ),
@@ -1498,6 +1517,7 @@ def save_images_command(
14981517 "output" : output ,
14991518 "scale" : scale ,
15001519 "show_progress" : not ctx .quiet_mode ,
1520+ "temporal_margin" : temporal_margin_tc ,
15011521 "threading" : ctx .config .get_value ("save-images" , "threading" ),
15021522 "width" : width ,
15031523 }
0 commit comments