Example #1
0
def encode_file(args: Args):
    """
    Encodes a single video file on the local machine.

    :param args: The args for this encode
    :return: None
    """

    outputs_filenames(args)

    done_path = args.temp / 'done.json'
    resuming = args.resume and done_path.exists()

    # set up temp dir and logging
    setup(args.temp, args.resume)
    set_log(args.logging, args.temp)

    # find split locations
    split_locations = split_routine(args, resuming)

    # Applying extra splits
    if args.extra_split:
        split_locations = extra_splits(args, split_locations)

    # create a chunk queue
    chunk_queue = load_or_gen_chunk_queue(args, resuming, split_locations)

    # things that need to be done only the first time
    if not resuming:

        extract_audio(args.input, args.temp, args.audio_params)

        if args.reuse_first_pass:
            segment_first_pass(args.temp, split_locations)

    # do encoding loop
    args.workers = determine_resources(args.encoder, args.workers)
    startup(args, chunk_queue)
    encoding_loop(args, chunk_queue)

    # concat
    concat_routine(args)

    if args.vmaf or args.vmaf_plots:
        plot_vmaf(args.input, args.output_file, args, args.vmaf_path,
                  args.vmaf_res)

    # Delete temp folders
    if not args.keep:
        shutil.rmtree(args.temp)
Example #2
0
def encode_file(project: Project):
    """
    Encodes a single video file on the local machine.

    :param project: The project for this encode
    :return: None
    """

    setup(project)
    set_log(project.logging, project.temp)

    # find split locations
    split_locations = split_routine(project, project.resume)

    # create a chunk queue
    chunk_queue = load_or_gen_chunk_queue(project, project.resume,
                                          split_locations)

    # things that need to be done only the first time
    if not project.resume:

        extract_audio(project.input, project.temp, project.audio_params)

        if project.reuse_first_pass:
            segment_first_pass(project.temp, split_locations)

    # do encoding loop
    project.workers = determine_resources(project.encoder, project.workers)
    startup(project, chunk_queue)
    encoding_loop(project, chunk_queue)

    # concat
    concat_routine(project)

    if project.vmaf or project.vmaf_plots:
        plot_vmaf(project.input, project.output_file, project,
                  project.vmaf_path, project.vmaf_res)

    # Delete temp folders
    if not project.keep:
        shutil.rmtree(project.temp)