Example #1
0
 def compose_2_pass(self, a: Args, c: Chunk, output: str) -> MPCommands:
     return [
         CommandPair(Encoder.compose_ffmpeg_pipe(a), [
             'aomenc', '--passes=2', '--pass=1', *a.video_params,
             f'--fpf={c.fpf}.log', '-o', os.devnull, '-'
         ]),
         CommandPair(Encoder.compose_ffmpeg_pipe(a), [
             'aomenc', '--passes=2', '--pass=2', *a.video_params,
             f'--fpf={c.fpf}.log', '-o', output, '-'
         ])
     ]
Example #2
0
 def compose_2_pass(self, a: Project, c: Chunk, output: str) -> MPCommands:
     return [
         CommandPair(
             Encoder.compose_ffmpeg_pipe(a),
             ['rav1e', '-', '-q', '-y', '--first-pass', f'{c.fpf}.stat', *a.video_params, '--output', os.devnull]
         ),
         CommandPair(
             Encoder.compose_ffmpeg_pipe(a),
             ['rav1e', '-', '-y', '--second-pass', f'{c.fpf}.stat', *a.video_params, '--output', output]
         )
     ]
Example #3
0
 def compose_2_pass(self, a: Args, c: Chunk, output: str) -> MPCommands:
     return [
         CommandPair(Encoder.compose_ffmpeg_pipe(a), [
             'x265', '--log-level', 'error', '--no-progress', '--pass', '1',
             '--y4m', *a.video_params, '--stats', f'{c.fpf}.log', '-', '-o',
             os.devnull
         ]),
         CommandPair(Encoder.compose_ffmpeg_pipe(a), [
             'x265', '--log-level', 'error', '--pass', '2', '--y4m',
             *a.video_params, '--stats', f'{c.fpf}.log', '-', '-o', output
         ])
     ]
Example #4
0
 def compose_2_pass(self, a: Args, c: Chunk, output: str) -> MPCommands:
     return [
         CommandPair(Encoder.compose_ffmpeg_pipe(a), [
             'SvtAv1EncApp', '-i', 'stdin', '--progress', '2',
             '--irefresh-type', '2', *a.video_params, '-output-stat-file',
             f'{c.fpf}.stat', '-b', os.devnull, '-'
         ]),
         CommandPair(Encoder.compose_ffmpeg_pipe(a), [
             'SvtAv1EncApp', '-i', 'stdin', '--progress', '2',
             '--irefresh-type', '2', *a.video_params, '-input-stat-file',
             f'{c.fpf}.stat', '-b', output, '-'
         ])
     ]
Example #5
0
 def compose_1_pass(self, a: Args, c: Chunk, output: str) -> MPCommands:
     return [
         CommandPair(Encoder.compose_ffmpeg_pipe(a), [
             'x264', '--stitchable', '--log-level', 'error', '--demuxer',
             'y4m', *a.video_params, '-', '-o', output
         ])
     ]
Example #6
0
 def compose_1_pass(self, a: Project, c: Chunk, output: str) -> MPCommands:
     return [
         CommandPair(
             SvtVp9.compose_ffmpeg_raw_pipe(a),
             ['SvtVp9EncApp', '-i', 'stdin', '-n', f'{c.frames}', *a.video_params, '-b', output]
         )
     ]
Example #7
0
 def compose_1_pass(self, a: Project, c: Chunk, output: str) -> MPCommands:
     return [
         CommandPair(Encoder.compose_ffmpeg_pipe(a), [
             'x265', '--y4m', '--frames',
             str(c.frames), *a.video_params, '-', '-o', output
         ])
     ]
Example #8
0
def compose_aomsplit_first_pass_command(video_path: Path, stat_file: Path,
                                        ffmpeg_pipe,
                                        video_params) -> CommandPair:
    """
    Generates the command for the first pass of the entire video used for aom keyframe split

    :param video_path: the video path
    :param stat_file: the stat_file output
    :param ffmpeg_pipe: the av1an.ffmpeg_pipe with pix_fmt and -ff option
    :param video_params: the video params for aomenc first pass
    :return: ffmpeg, encode
    """

    f = [
        'ffmpeg', '-y', '-hide_banner', '-loglevel', 'error', '-i',
        video_path.as_posix(), *ffmpeg_pipe
    ]
    # removed -w -h from aomenc since ffmpeg filters can change it and it can be added into video_params
    # TODO(n9Mtq4): if an encoder other than aom is being used, video_params becomes the default so -w -h may be needed again

    # Adjust number of threads
    video_params = re.sub(r'(--threads=.\w)',
                          f'--threads={os.cpu_count() * 3}',
                          ' '.join(video_params))
    e = [
        'aomenc', '--passes=2', '--pass=1', *video_params.split(),
        f'--fpf={stat_file.as_posix()}', '-o', os.devnull, '-'
    ]
    return CommandPair(f, e)
Example #9
0
def per_frame_probe_cmd(chunk: Chunk, q, ffmpeg_pipe, encoder, probing_rate,
                        qp_file) -> CommandPair:
    """
    Generate and return commands for probes at set Q values
    These are specifically not the commands that are generated
    by the user or encoder defaults, since these
    should be faster than the actual encoding commands.
    These should not be moved into encoder classes at this point.
    """
    pipe = [
        'ffmpeg', '-y', '-hide_banner', '-loglevel', 'error', '-i', '-', '-vf',
        f'select=not(mod(n\\,{probing_rate}))', *ffmpeg_pipe
    ]

    probe_name = gen_probes_names(chunk, q).with_suffix('.ivf').as_posix()

    if encoder == 'svt_av1':
        params = [
            'SvtAv1EncApp', '-i', 'stdin', '--preset', '8', '--rc', '0',
            '--use-q-file', '--qpfile', f'{qp_file}'
        ]

        cmd = CommandPair(pipe, [*params, '-b', probe_name, '-'])
    else:
        print('supported only by SVT-AV1')
        exit()

    return cmd
Example #10
0
 def compose_1_pass(self, a: Project, c: Chunk, output: str) -> MPCommands:
     return [
         CommandPair(
             Encoder.compose_ffmpeg_pipe(a),
             ['rav1e', '-', '-y', *a.video_params, '--output', output]
         )
     ]
Example #11
0
 def compose_1_pass(self, a: Args, c: Chunk, output: str) -> MPCommands:
     return [
         CommandPair(Encoder.compose_ffmpeg_pipe(a), [
             'SvtAv1EncApp', '-i', 'stdin', '--progress', '2',
             *a.video_params, '-b', output, '-'
         ])
     ]
Example #12
0
 def compose_1_pass(self, a: Project, c: Chunk, output: str) -> MPCommands:
     return [
         CommandPair(
             Encoder.compose_ffmpeg_pipe(a),
             ['vpxenc', '--passes=1', *a.video_params, '-o', output, '-']
         )
     ]
Example #13
0
 def compose_1_pass(self, a: Project, c: Chunk, output: str) -> MPCommands:
     yuv_file: str = Vvc.get_yuv_file_path(c).as_posix()
     return [
         CommandPair(
             [],
             ['vvc_encoder', '-c', a.vvc_conf, '-i', yuv_file, *a.video_params, '-f', str(c.frames),
              '--InputBitDepth=10', '--OutputBitDepth=10', '-b', output]
         )
     ]
Example #14
0
def probe_cmd(chunk: Chunk, q, ffmpeg_pipe, encoder, vmaf_rate) -> CommandPair:
    """
    Generate and return commands for probes at set Q values
    These are specifically not the commands that are generated
    by the user or encoder defaults, since these
    should be faster than the actual encoding commands.
    These should not be moved into encoder classes at this point.
    """
    pipe = ['ffmpeg', '-y', '-hide_banner', '-loglevel', 'error', '-i', '-', '-vf', f'select=not(mod(n\\,{vmaf_rate}))',
            *ffmpeg_pipe]

    probe_name = gen_probes_names(chunk, q).with_suffix('.ivf').as_posix()

    if encoder == 'aom':
        params = ['aomenc', '--passes=1', '--threads=8',
                  '--end-usage=q', '--cpu-used=6', f'--cq-level={q}']
        cmd = CommandPair(pipe, [*params, '-o', probe_name, '-'])

    elif encoder == 'x265':
        params = ['x265', '--log-level', '0', '--no-progress',
                  '--y4m', '--preset', 'faster', '--crf', f'{q}']
        cmd = CommandPair(pipe, [*params, '-o', probe_name, '-'])

    elif encoder == 'rav1e':
        params = ['rav1e', '-s', '10', '--tiles', '8', '--quantizer', f'{q}']
        cmd = CommandPair(pipe, [*params, '-o', probe_name, '-'])

    elif encoder == 'vpx':
        params = ['vpxenc', '--passes=1', '--pass=1', '--codec=vp9',
                  '--threads=8', '--cpu-used=9', '--end-usage=q',
                  f'--cq-level={q}']
        cmd = CommandPair(pipe, [*params, '-o', probe_name, '-'])

    elif encoder == 'svt_av1':
        params = ['SvtAv1EncApp', '-i', 'stdin',
                  '--preset', '8', '--rc', '0', '--qp', f'{q}']
        cmd = CommandPair(pipe, [*params, '-b', probe_name, '-'])

    elif encoder == 'svt_vp9':
        params = ['SvtVp9EncApp', '-i', 'stdin',
                  '-enc-mode', '8', '-q', f'{q}']
        # TODO: pipe needs to output rawvideo
        cmd = CommandPair(pipe, [*params, '-b', probe_name, '-'])

    elif encoder == 'x264':
        params = ['x264', '--log-level', 'error', '--demuxer', 'y4m',
                  '-', '--no-progress', '--preset', 'slow', '--crf',
                  f'{q}']
        cmd = CommandPair(pipe, [*params, '-o', probe_name, '-'])

    return cmd