MCPcopy Create free account
hub / github.com/Breakthrough/PySceneDetect / __init__

Method __init__

scenedetect/output/image.py:109–161  ·  view source on GitHub ↗

Multi-threaded implementation of save-images functionality. Uses background threads to handle image encoding and saving images to disk to improve parallelism. This object is thread-safe. Arguments: num_images: Number of images to generate for each scene. Minimu

(
        self,
        num_images: int = 3,
        frame_margin: TimecodeLike = 1,
        image_extension: str = "jpg",
        imwrite_param: list[int] | None = None,
        image_name_template: str = "$VIDEO_NAME-Scene-$SCENE_NUMBER-$IMAGE_NUMBER",
        scale: float | None = None,
        height: int | None = None,
        width: int | None = None,
        interpolation: Interpolation = Interpolation.CUBIC,
    )

Source from the content-addressed store, hash-verified

107
108class _ImageExtractor:
109 def __init__(
110 self,
111 num_images: int = 3,
112 frame_margin: TimecodeLike = 1,
113 image_extension: str = "jpg",
114 imwrite_param: list[int] | None = None,
115 image_name_template: str = "$VIDEO_NAME-Scene-$SCENE_NUMBER-$IMAGE_NUMBER",
116 scale: float | None = None,
117 height: int | None = None,
118 width: int | None = None,
119 interpolation: Interpolation = Interpolation.CUBIC,
120 ):
121 """Multi-threaded implementation of save-images functionality. Uses background threads to
122 handle image encoding and saving images to disk to improve parallelism.
123
124 This object is thread-safe.
125
126 Arguments:
127 num_images: Number of images to generate for each scene. Minimum is 1.
128 frame_margin: Padding around the beginning and end of each scene used when
129 selecting which frames to extract. Accepts an int (frames), float (seconds),
130 or str (e.g. ``"0.1s"``, ``"00:00:00.100"``). Can be 0, but some video files
131 may then fail to extract the very last frame.
132 image_extension: Type of image to save (must be one of 'jpg', 'png', or 'webp').
133 encoder_param: Quality/compression efficiency, based on type of image:
134 'jpg' / 'webp': Quality 0-100, higher is better quality. 100 is lossless for webp.
135 'png': Compression from 1-9, where 9 achieves best filesize but is slower to encode.
136 image_name_template: Template to use for output filanames. Can use template variables
137 $VIDEO_NAME, $SCENE_NUMBER, $IMAGE_NUMBER, $TIMECODE, $FRAME_NUMBER, $TIMESTAMP_MS.
138 *NOTE*: Should not include the image extension (set `image_extension` instead).
139 scale: Optional factor by which to rescale saved images. A scaling factor of 1 would
140 not result in rescaling. A value < 1 results in a smaller saved image, while a
141 value > 1 results in an image larger than the original. This value is ignored if
142 either the height or width values are specified.
143 height: Optional value for the height of the saved images. Specifying both the height
144 and width will resize images to an exact size, regardless of aspect ratio.
145 Specifying only height will rescale the image to that number of pixels in height
146 while preserving the aspect ratio.
147 width: Optional value for the width of the saved images. Specifying both the width
148 and height will resize images to an exact size, regardless of aspect ratio.
149 Specifying only width will rescale the image to that number of pixels wide
150 while preserving the aspect ratio.
151 interpolation: Type of interpolation to use when resizing images.
152 """
153 self._num_images = num_images
154 self._frame_margin = frame_margin
155 self._image_extension = image_extension
156 self._image_name_template = image_name_template
157 self._scale = scale
158 self._height = height
159 self._width = width
160 self._interpolation = interpolation
161 self._imwrite_param: list[int] = imwrite_param if imwrite_param is not None else []
162
163 def run(
164 self,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected