def get_frames(self): """ Get total frame count of input file, returning total_frames from project if already exists """ # TODO: Unify get frames with vs pipe cache generation if self.frames > 0: return self.frames if self.chunk_method in ("vs_ffms2", "vs_lsmash"): vs = ( self.input if self.is_vs else create_vs_file(self.temp, self.input, self.chunk_method) ) fr = frame_probe_vspipe(vs) if fr > 0: self.frames = fr return fr total = frame_probe_fast(self.input, self.is_vs) self.frames = total return self.frames
def create_video_queue_vs(project: Project, split_locations: List[int]) -> List[Chunk]: """ Create a list of chunks using vspipe and ffms2 for frame accurate seeking :param project: the Project :param split_locations: a list of frames to split on :param script: source filter script to use with vspipe (ignored with vs input) :return: A list of chunks """ # add first frame and last frame last_frame = project.get_frames() split_locs_fl = [0] + split_locations + [last_frame] # pair up adjacent members of this list ex: [0, 10, 20, 30] -> [(0, 10), (10, 20), (20, 30)] chunk_boundaries = zip(split_locs_fl, split_locs_fl[1:]) source_file = project.input.absolute().as_posix() if project.is_vs: vs_script = project.input else: vs_script = create_vs_file(project.temp, source_file, project.chunk_method) chunk_queue = [ create_vs_chunk(project, index, vs_script, *cb) for index, cb in enumerate(chunk_boundaries) ] return chunk_queue