Exemplo n.º 1
0
def create_chunk_from_segment(project: Project, index: int,
                              file: Path) -> Chunk:
    """
    Creates a Chunk object from a segment file generated by ffmpeg

    :param project: the Project
    :param index: the index of the chunk
    :param file: the segmented file
    :return: A Chunk
    """
    ffmpeg_gen_cmd = [
        'ffmpeg', '-y', '-hide_banner', '-loglevel', 'error', '-hwaccel',
        'auto', '-i',
        file.as_posix(), *project.pix_format, '-color_range', '0', '-f',
        'yuv4mpegpipe', '-'
    ]
    file_size = file.stat().st_size
    frames = project.get_frames()
    extension = ENCODERS[project.encoder].output_extension

    chunk = Chunk(project.temp, index, ffmpeg_gen_cmd, extension, file_size,
                  frames)

    return chunk