How to use the scenedetect.detectors.get_available function in scenedetect

To help you get started, we’ve selected a few scenedetect examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Breakthrough / PySceneDetect / scenedetect / manager.py View on Github external
def _parse_args(self):
        """ Parses a command-line vector (from argparse) into the appropriate
        class properties.  Called only if args is passed to the constructor.
        """

        args = self.args

        # Load SceneDetector with proper arguments based on passed detector (-d) if not specified.
        self.detector = None
        self.detection_method = args.detection_method.lower()
        scene_detectors = scenedetect.detectors.get_available()
        if not args.threshold:
            args.threshold = 30.0 if self.detection_method == 'content' else 12
        if (self.detection_method == 'content'):
            self.detector = scene_detectors['content'](args.threshold, args.min_scene_len)
        elif (self.detection_method == 'threshold'):
            self.detector = scene_detectors['threshold'](
                args.threshold, args.min_percent/100.0, args.min_scene_len,
                block_size = args.block_size, fade_bias = args.fade_bias/100.0)

        self.downscale_factor = args.downscale_factor
        if self.downscale_factor < 2:
            self.downscale_factor = 1

        self.frame_skip = args.frame_skip
        if self.frame_skip <= 0:
            self.frame_skip = 0
github wlerin / showroom / showroom / archive / trim.py View on Github external
Detect transition from static image into the actual program.
    
    Requires PySceneDetect and OpenCV compiled with FFmpeg support.
    
    :param path: path to file
    :param start_minutes: when to start looking
    :param end_minutes: when to stop looking
    :param threshold: how big a change in frames to detect
    :return: 
    """
    import scenedetect
    # detect_scenes_file is unfortunately not really designed to be used like this
    # it's tightly coupled to the command line arguments passed by scenedetect.cli
    # TODO: Rewrite the necessary PySceneDetect functions so they aren't retarded.
    # or write my own detector that stops after finding a match, see detect_threshold
    scene_detectors = scenedetect.detectors.get_available()
    args = DumbNamespace(threshold=threshold,
                         detection_method='content',
                         downscale_factor=2,
                         start_time=[0, start_minutes, 0],
                         duration=[0, end_minutes, 0],
                         quiet_mode=True,
                         # end custom arguments, begin defaults
                         min_scene_len=15,
                         frame_skip=0)
    scene_manager = scenedetect.manager.SceneManager(args=args, scene_detectors=scene_detectors)

    video_fps, frames_read, frames_processed = scenedetect.detect_scenes_file(path, scene_manager)

    scene_list_sec = [x / float(video_fps) for x in scene_manager.scene_list]

    return scene_list_sec[0]