(video, directory, force, orange_file, white_file, gray_file, multiple,
                    find_viewport, viewport_time, full_resolution, timeline_file, trim_end)
Extract the video frames
Extract the video frames
Extract the video frames
def video_to_frames(video, directory, force, orange_file, white_file, gray_file, multiple,
                    find_viewport, viewport_time, full_resolution, timeline_file, trim_end):
    """ Extract the video frames"""
    global client_viewport
    first_frame = os.path.join(directory, 'ms_000000')
    if (not os.path.isfile(first_frame + '.png')
            and not os.path.isfile(first_frame + '.jpg')) or force:
        if os.path.isfile(video):
            video = os.path.realpath(video)
            logging.info(
                "Processing frames from video " +
                video +
                " to " +
                directory)
            if os.path.isdir(directory):
                shutil.rmtree(directory, True)
            if not os.path.isdir(directory):
                os.mkdir(directory, 0o755)
            if os.path.isdir(directory):
                directory = os.path.realpath(directory)
                viewport = find_video_viewport(
                    video, directory, find_viewport, viewport_time)
                gc.collect()
                if extract_frames(video, directory, full_resolution, viewport):
                    client_viewport = None
                    if find_viewport and options.notification:
                        client_viewport = find_image_viewport(
                            os.path.join(directory, 'video-000000.png'))
                    if multiple and orange_file is not None:
                        directories = split_videos(directory, orange_file)
                    else:
                        directories = [directory]
                    for dir in directories:
                        trim_video_end(dir, trim_end)
                        if orange_file is not None:
                            remove_frames_before_orange(dir, orange_file)
                            remove_orange_frames(dir, orange_file)
                        find_first_frame(dir, white_file)
                        blank_first_frame(dir)
                        find_render_start(dir, orange_file, gray_file)
                        find_last_frame(dir, white_file)
                        adjust_frame_times(dir)
                        if timeline_file is not None and not multiple:
                            synchronize_to_timeline(dir, timeline_file)
                        eliminate_duplicate_frames(dir)
                        eliminate_similar_frames(dir)
                        # See if we are limiting the number of frames to keep
                        # (before processing them to save processing time)
                        if options.maxframes > 0:
                            cap_frame_count(dir, options.maxframes)
                        crop_viewport(dir)
                        gc.collect()
                else:
                    logging.critical("Error extracting the video frames from %s", video)
            else:
                logging.critical("Error creating output directory: %s", directory)
        else:
            logging.critical("Input video file %s does not exist", video)
    else:
        logging.info("Extracted video already exists in %s", directory)
def video_to_frames ( video , directory , force , orange_file , white_file , gray_file , multiple , find_viewport , viewport_time , full_resolution , timeline_file , trim_end ) : global client_viewport first_frame = os . path . join ( directory , 'ms_000000' ) if ( not os . path . isfile ( first_frame + '.png' ) and not os . path . isfile ( first_frame + '.jpg' ) ) or force : if os . path . isfile ( video ) : video = os . path . realpath ( video ) logging . info ( "Processing frames from video " + video + " to " + directory ) if os . path . isdir ( directory ) : shutil . rmtree ( directory , True ) if not os . path . isdir ( directory ) : os . mkdir ( directory , 0o755 ) if os . path . isdir ( directory ) : directory = os . path . realpath ( directory ) viewport = find_video_viewport ( video , directory , find_viewport , viewport_time ) gc . collect ( ) if extract_frames ( video , directory , full_resolution , viewport ) : client_viewport = None if find_viewport and options . notification : client_viewport = find_image_viewport ( os . path . join ( directory , 'video-000000.png' ) ) if multiple and orange_file is not None : directories = split_videos ( directory , orange_file ) else : directories = [ directory ] for dir in directories : trim_video_end ( dir , trim_end ) if orange_file is not None : remove_frames_before_orange ( dir , orange_file ) remove_orange_frames ( dir , orange_file ) find_first_frame ( dir , white_file ) blank_first_frame ( dir ) find_render_start ( dir , orange_file , gray_file ) find_last_frame ( dir , white_file ) adjust_frame_times ( dir ) if timeline_file is not None and not multiple : synchronize_to_timeline ( dir , timeline_file ) eliminate_duplicate_frames ( dir ) eliminate_similar_frames ( dir ) # See if we are limiting the number of frames to keep # (before processing them to save processing time) if options . maxframes > 0 : cap_frame_count ( dir , options . maxframes ) crop_viewport ( dir ) gc . collect ( ) else : logging . critical ( "Error extracting the video frames from %s" , video ) else : logging . critical ( "Error creating output directory: %s" , directory ) else : logging . critical ( "Input video file %s does not exist" , video ) else : logging . info ( "Extracted video already exists in %s" , directory )