Ejemplo n.º 1
0
def build(fastflix: FastFlix):
    settings: x264Settings = fastflix.current_video.video_settings.video_encoder_settings

    beginning, ending = generate_all(fastflix, "libx264")

    beginning += f'{f"-tune:v {settings.tune}" if settings.tune else ""} {generate_color_details(fastflix)} '

    if settings.profile and settings.profile != "default":
        beginning += f"-profile:v {settings.profile} "

    pass_log_file = fastflix.current_video.work_path / f"pass_log_file_{secrets.token_hex(10)}"

    if settings.bitrate:
        command_1 = (
            f"{beginning} -pass 1 "
            f'-passlogfile "{pass_log_file}" -b:v {settings.bitrate} -preset:v {settings.preset} {settings.extra if settings.extra_both_passes else ""} -an -sn -dn -f mp4 {null}'
        )
        command_2 = (
            f'{beginning} -pass 2 -passlogfile "{pass_log_file}" '
            f"-b:v {settings.bitrate} -preset:v {settings.preset} {settings.extra} "
        ) + ending
        return [
            Command(command=command_1, name="First pass bitrate", exe="ffmpeg"),
            Command(command=command_2, name="Second pass bitrate", exe="ffmpeg"),
        ]

    elif settings.crf:
        command = f"{beginning} -crf:v {settings.crf} " f"-preset:v {settings.preset} {settings.extra} {ending}"
        return [Command(command=command, name="Single pass CRF", exe="ffmpeg")]

    else:
        return []
Ejemplo n.º 2
0
def build(fastflix: FastFlix):
    settings: AOMAV1Settings = fastflix.current_video.video_settings.video_encoder_settings
    beginning, ending = generate_all(fastflix, "libaom-av1")

    beginning += ("-strict experimental "
                  f"-cpu-used {settings.cpu_used} "
                  f"-tile-rows {settings.tile_rows} "
                  f"-tile-columns {settings.tile_columns} "
                  f"-usage {settings.usage} "
                  f"{generate_color_details(fastflix)} ")

    if settings.row_mt.lower() == "enabled":
        beginning += f"-row-mt 1 "

    beginning = re.sub("[ ]+", " ", beginning)

    if settings.bitrate:
        pass_log_file = fastflix.current_video.work_path / f"pass_log_file_{secrets.token_hex(10)}.log"
        command_1 = f'{beginning} -passlogfile "{pass_log_file}" -b:v {settings.bitrate} -pass 1 -an -f matroska {null}'
        command_2 = f'{beginning} -passlogfile "{pass_log_file}" -b:v {settings.bitrate} -pass 2' + ending
        return [
            Command(command_1, ["ffmpeg", "output"],
                    False,
                    name="First Pass bitrate"),
            Command(command_2, ["ffmpeg", "output"],
                    False,
                    name="Second Pass bitrate"),
        ]
    elif settings.crf:
        command_1 = f"{beginning} -b:v 0 -crf {settings.crf}" + ending
        return [
            Command(command_1, ["ffmpeg", "output"],
                    False,
                    name="Single Pass CRF")
        ]
Ejemplo n.º 3
0
def build(fastflix: FastFlix):
    settings: FFmpegNVENCSettings = fastflix.current_video.video_settings.video_encoder_settings

    beginning, ending = generate_all(fastflix, "hevc_nvenc")

    beginning += f'{f"-tune:v {settings.tune}" if settings.tune else ""} {generate_color_details(fastflix)} -spatial_aq:v {settings.spatial_aq} -tier:v {settings.tier} -rc-lookahead:v {settings.rc_lookahead} -gpu {settings.gpu} -b_ref_mode {settings.b_ref_mode} '

    if settings.profile:
        beginning += f"-profile:v {settings.profile} "

    if settings.rc:
        beginning += f"-rc:v {settings.rc} "

    if settings.level:
        beginning += f"-level:v {settings.level} "

    pass_log_file = fastflix.current_video.work_path / f"pass_log_file_{secrets.token_hex(10)}"

    command_1 = (
        f"{beginning} -pass 1 "
        f'-passlogfile "{pass_log_file}" -b:v {settings.bitrate} -preset:v {settings.preset} -2pass 1 '
        f'{settings.extra if settings.extra_both_passes else ""} -an -sn -dn -f mp4 {null}'
    )
    command_2 = (
        f'{beginning} -pass 2 -passlogfile "{pass_log_file}" -2pass 1 '
        f"-b:v {settings.bitrate} -preset:v {settings.preset} {settings.extra} "
    ) + ending
    return [
        Command(command=command_1, name="First pass bitrate", exe="ffmpeg"),
        Command(command=command_2, name="Second pass bitrate", exe="ffmpeg"),
    ]
Ejemplo n.º 4
0
def build(fastflix: FastFlix):
    settings: AOMAV1Settings = fastflix.current_video.video_settings.video_encoder_settings
    beginning, ending = generate_all(fastflix, "libaom-av1")

    beginning += ("-strict experimental "
                  f"-cpu-used {settings.cpu_used} "
                  f"-tile-rows {settings.tile_rows} "
                  f"-tile-columns {settings.tile_columns} "
                  f"-usage {settings.usage} "
                  f"{generate_color_details(fastflix)} ")

    if settings.row_mt.lower() == "enabled":
        beginning += f"-row-mt 1 "

    if settings.bitrate:
        pass_log_file = fastflix.current_video.work_path / f"pass_log_file_{secrets.token_hex(10)}"
        command_1 = f'{beginning} -passlogfile "{pass_log_file}" -b:v {settings.bitrate} -pass 1 {settings.extra if settings.extra_both_passes else ""} -an -f matroska {null}'
        command_2 = (
            f'{beginning} -passlogfile "{pass_log_file}" -b:v {settings.bitrate} -pass 2 {settings.extra} {ending}'
        )
        return [
            Command(command=command_1, name="First Pass bitrate"),
            Command(command=command_2, name="Second Pass bitrate"),
        ]
    elif settings.crf:
        command_1 = f"{beginning} -b:v 0 -crf {settings.crf} {settings.extra} {ending}"
        return [Command(command=command_1, name="Single Pass CRF")]
Ejemplo n.º 5
0
def build(fastflix: FastFlix):
    settings: rav1eSettings = fastflix.current_video.video_settings.video_encoder_settings
    beginning, ending = generate_all(fastflix, "librav1e")

    beginning += ("-strict experimental "
                  f"-speed {settings.speed} "
                  f"-tile-columns {settings.tile_columns} "
                  f"-tile-rows {settings.tile_rows} "
                  f"-tiles {settings.tiles} "
                  f"{generate_color_details(fastflix)} ")

    # if not fastflix.current_video.video_settings.remove_hdr:

    # Currently unsupported https://github.com/xiph/rav1e/issues/2554
    #         rav1e_options = []
    # if side_data.master_display:
    #     rav1e_options.append(
    #         "mastering-display="
    #         f"G{side_data.master_display.green}"
    #         f"B{side_data.master_display.blue}"
    #         f"R{side_data.master_display.red}"
    #         f"WP{side_data.master_display.white}"
    #         f"L{side_data.master_display.luminance}"
    #     )
    #
    # if side_data.cll:
    #     rav1e_options.append(f"content-light={side_data.cll}")
    # if rav1e_options:
    #     opts = ":".join(rav1e_options)
    #     beginning += f'-rav1e-params "{opts}"'

    beginning = re.sub("[ ]+", " ", beginning)

    if not settings.single_pass:
        pass_log_file = fastflix.current_video.work_path / f"pass_log_file_{secrets.token_hex(10)}"
        beginning += f'-passlogfile "{pass_log_file}" '

    pass_type = "bitrate" if settings.bitrate else "QP"

    if not settings.bitrate:
        command_1 = f"{beginning} -qp {settings.qp} {settings.extra} {ending}"
        return [Command(command=command_1, name=f"{pass_type}", exe="ffmpeg")]

    if settings.single_pass:
        command_1 = f"{beginning} -b:v {settings.bitrate} {settings.extra} {ending}"
        return [Command(command=command_1, name=f"{pass_type}", exe="ffmpeg")]
    else:
        command_1 = f"{beginning} -b:v {settings.bitrate} -pass 1 {settings.extra if settings.extra_both_passes else ''} -an -f matroska {null}"
        command_2 = f"{beginning} -b:v {settings.bitrate} -pass 2 {settings.extra} {ending}"
        return [
            Command(command=command_1,
                    name=f"First pass {pass_type}",
                    exe="ffmpeg"),
            Command(command=command_2,
                    name=f"Second pass {pass_type} ",
                    exe="ffmpeg"),
        ]
Ejemplo n.º 6
0
def build(fastflix: FastFlix):
    settings: VP9Settings = fastflix.current_video.video_settings.video_encoder_settings
    beginning, ending = generate_all(fastflix, "libvpx-vp9")

    beginning += f'{"-row-mt 1" if settings.row_mt else ""} ' f"{generate_color_details(fastflix)} "

    if not settings.single_pass:
        pass_log_file = fastflix.current_video.work_path / f"pass_log_file_{secrets.token_hex(10)}"
        beginning += f'-passlogfile "{pass_log_file}" '

    # TODO color_range 1
    # if not fastflix.current_video.video_settings.remove_hdr and settings.pix_fmt in ("yuv420p10le", "yuv420p12le"):
    #     if fastflix.current_video.color_space.startswith("bt2020"):
    #         beginning += "-color_primaries bt2020 -color_trc smpte2084 -colorspace bt2020nc -color_range 1"

    details = f"-quality:v {settings.quality} -profile:v {settings.profile} -tile-columns:v {settings.tile_columns} -tile-rows:v {settings.tile_rows} "

    if settings.bitrate:
        if settings.quality == "realtime":
            return [
                Command(
                    command=
                    f"{beginning} -speed:v {settings.speed} -b:v {settings.bitrate} {details} {settings.extra} {ending} ",
                    name="Single pass realtime bitrate",
                    exe="ffmpeg",
                )
            ]
        command_1 = f"{beginning} -speed:v {'4' if settings.fast_first_pass else settings.speed} -b:v {settings.bitrate} {details} -pass 1 {settings.extra if settings.extra_both_passes else ''} -an -f webm {null}"
        command_2 = (
            f"{beginning} -speed:v {settings.speed} -b:v {settings.bitrate} {details} -pass 2 {settings.extra} {ending}"
        )

    elif settings.crf:
        command_1 = f"{beginning} -b:v 0 -crf:v {settings.crf} {details} -pass 1 {settings.extra if settings.extra_both_passes else ''} -an -f webm {null}"
        command_2 = (
            f"{beginning} -b:v 0 -crf:v {settings.crf} {details} "
            f'{"-pass 2" if not settings.single_pass else ""} {settings.extra} {ending}'
        )

    else:
        return []

    if settings.crf and settings.single_pass:
        return [
            Command(command=command_2, name="Single pass CRF", exe="ffmpeg")
        ]
    pass_type = "bitrate" if settings.bitrate else "CRF"

    return [
        Command(command=command_1,
                name=f"First pass {pass_type}",
                exe="ffmpeg"),
        Command(command=command_2,
                name=f"Second pass {pass_type} ",
                exe="ffmpeg"),
    ]
Ejemplo n.º 7
0
def build(fastflix: FastFlix):
    settings: SVTAV1Settings = fastflix.current_video.video_settings.video_encoder_settings
    beginning, ending = generate_all(fastflix, "libsvtav1")

    beginning += (f"-strict experimental "
                  f"-preset {settings.speed} "
                  f"-tile_columns {settings.tile_columns} "
                  f"-tile_rows {settings.tile_rows} "
                  f"-tier {settings.tier} "
                  f"{generate_color_details(fastflix)} ")

    beginning = re.sub("[ ]+", " ", beginning)

    if not settings.single_pass:
        pass_log_file = fastflix.current_video.work_path / f"pass_log_file_{secrets.token_hex(10)}.log"
        beginning += f'-passlogfile "{pass_log_file}" '

    pass_type = "bitrate" if settings.bitrate else "QP"

    if settings.single_pass:
        if settings.bitrate:
            command_1 = f"{beginning} -b:v {settings.bitrate} -rc 1" + ending

        elif settings.qp is not None:
            command_1 = f"{beginning} -qp {settings.qp} -rc 0" + ending
        else:
            return []
        return [
            Command(command_1, ["ffmpeg", "output"],
                    False,
                    name=f"{pass_type}",
                    exe="ffmpeg")
        ]
    else:
        if settings.bitrate:
            command_1 = f"{beginning} -b:v {settings.bitrate} -rc 1 -pass 1 -an -f matroska {null}"
            command_2 = f"{beginning} -b:v {settings.bitrate} -rc 1 -pass 2" + ending

        elif settings.qp is not None:
            command_1 = f"{beginning} -qp {settings.qp} -rc 0 -pass 1 -an -f matroska {null}"
            command_2 = f"{beginning} -qp {settings.qp} -rc 0 -pass 2" + ending
        else:
            return []
        return [
            Command(command_1, ["ffmpeg", "output"],
                    False,
                    name=f"First pass {pass_type}",
                    exe="ffmpeg"),
            Command(command_2, ["ffmpeg", "output"],
                    False,
                    name=f"Second pass {pass_type} ",
                    exe="ffmpeg"),
        ]
Ejemplo n.º 8
0
def build(fastflix: FastFlix):

    beginning, ending = generate_all(fastflix, "copy", disable_filters=True)

    return [
        Command(
            command=
            f"{beginning} {fastflix.current_video.video_settings.video_encoder_settings.extra} {ending}",
            name="No Video Encoding",
            exe="ffmpeg",
        )
    ]
Ejemplo n.º 9
0
def build(fastflix: FastFlix):

    beginning, ending = generate_all(fastflix, "copy", disable_filters=True)

    return [
        Command(
            re.sub("[ ]+", " ", f"{beginning} {ending}"),
            ["ffmpeg", "output"],
            False,
            name="No Video Encoding",
            exe="ffmpeg",
        )
    ]
Ejemplo n.º 10
0
def build(fastflix: FastFlix):
    settings: WebPSettings = fastflix.current_video.video_settings.video_encoder_settings

    beginning, ending = generate_all(fastflix,
                                     "libwebp",
                                     audio=False,
                                     subs=False)

    return [
        Command(
            command=
            f"{beginning}  -lossless {settings.lossless} -compression_level {settings.compression} "
            f"-qscale {settings.qscale} -preset {settings.preset} {settings.extra} {ending}",
            name="WebP",
            exe="ffmpeg",
        ),
    ]
Ejemplo n.º 11
0
def build(fastflix: FastFlix):
    settings: x264Settings = fastflix.current_video.video_settings.video_encoder_settings

    beginning, ending = generate_all(fastflix, "libx264")

    beginning += f'{f"-tune {settings.tune}" if settings.tune else ""} ' f"{generate_color_details(fastflix)} "

    if settings.profile and settings.profile != "default":
        beginning += f"-profile {settings.profile} "

    pass_log_file = fastflix.current_video.work_path / f"pass_log_file_{secrets.token_hex(10)}.log"

    if settings.bitrate:
        command_1 = (
            f"{beginning} -pass 1 "
            f'-passlogfile "{pass_log_file}" -b:v {settings.bitrate} -preset {settings.preset} -an -sn -dn -f mp4 {null}'
        )
        command_2 = (
            f'{beginning} -pass 2 -passlogfile "{pass_log_file}" ' f"-b:v {settings.bitrate} -preset {settings.preset}"
        ) + ending
        return [
            Command(
                re.sub("[ ]+", " ", command_1), ["ffmpeg", "output"], False, name="First pass bitrate", exe="ffmpeg"
            ),
            Command(
                re.sub("[ ]+", " ", command_2), ["ffmpeg", "output"], False, name="Second pass bitrate", exe="ffmpeg"
            ),
        ]

    elif settings.crf:
        command = (f"{beginning} -crf {settings.crf} " f"-preset {settings.preset} ") + ending
        return [
            Command(re.sub("[ ]+", " ", command), ["ffmpeg", "output"], False, name="Single pass CRF", exe="ffmpeg")
        ]

    else:
        return []
Ejemplo n.º 12
0
def build(fastflix: FastFlix):
    settings: HEVCVideoToolboxSettings = fastflix.current_video.video_settings.video_encoder_settings
    beginning, ending = generate_all(fastflix, "hevc_videotoolbox")

    beginning += generate_color_details(fastflix)

    def clean_bool(item):
        return "true" if item else "false"

    details = (f"-profile:v {settings.profile} "
               f"-allow_sw {clean_bool(settings.allow_sw)} "
               f"-require_sw {clean_bool(settings.require_sw)} "
               f"-realtime {clean_bool(settings.realtime)} "
               f"-frames_before {clean_bool(settings.frames_before)} "
               f"-frames_after {clean_bool(settings.frames_after)} ")

    if settings.bitrate:
        pass_log_file = fastflix.current_video.work_path / f"pass_log_file_{secrets.token_hex(10)}"
        beginning += f" "

        command_1 = f"{beginning} -b:v {settings.bitrate} {details} -pass 1 -passlogfile \"{pass_log_file}\" {settings.extra if settings.extra_both_passes else ''} -an -f mp4 {null}"
        command_2 = f'{beginning} -b:v {settings.bitrate} {details} -pass 2 -passlogfile "{pass_log_file}" {settings.extra} {ending}'
        return [
            Command(command=command_1,
                    name=f"First pass bitrate",
                    exe="ffmpeg"),
            Command(command=command_2,
                    name=f"Second pass bitrate",
                    exe="ffmpeg"),
        ]
    command_1 = f"{beginning} -q:v {settings.q} {details} {settings.extra} {ending}"

    return [
        Command(command=command_1,
                name=f"Single pass constant quality",
                exe="ffmpeg"),
    ]
Ejemplo n.º 13
0
def build(fastflix: FastFlix):
    settings: x265Settings = fastflix.current_video.video_settings.video_encoder_settings

    beginning, ending = generate_all(fastflix, "libx265")

    if settings.tune and settings.tune != "default":
        beginning += f"-tune:v {settings.tune} "

    if settings.profile and settings.profile != "default":
        beginning += f"-profile:v {settings.profile} "

    x265_params = settings.x265_params.copy() or []

    x265_params.append(f"aq-mode={settings.aq_mode}")
    x265_params.append(
        f"repeat-headers={'1' if settings.repeat_headers else '0'}")
    x265_params.append(
        f"{'' if settings.intra_smoothing else 'no-'}strong-intra-smoothing=1")
    x265_params.append(f"bframes={settings.bframes}")
    x265_params.append(f"b-adapt={settings.b_adapt}")
    x265_params.append(f"frame-threads={settings.frame_threads}")

    if not fastflix.current_video.video_settings.remove_hdr:

        if fastflix.current_video.video_settings.color_primaries:
            x265_params.append(
                f"colorprim={fastflix.current_video.video_settings.color_primaries}"
            )
        elif fastflix.current_video.color_primaries:
            if fastflix.current_video.color_primaries in x265_valid_color_primaries:
                x265_params.append(
                    f"colorprim={fastflix.current_video.color_primaries}")
            elif fastflix.current_video.color_primaries in color_primaries_mapping:
                x265_params.append(
                    f"colorprim={color_primaries_mapping[fastflix.current_video.color_primaries]}"
                )

        if fastflix.current_video.video_settings.color_transfer:
            x265_params.append(
                f"transfer={fastflix.current_video.video_settings.color_transfer}"
            )
        elif fastflix.current_video.color_transfer:
            if fastflix.current_video.color_transfer in x265_valid_color_transfers:
                x265_params.append(
                    f"transfer={fastflix.current_video.color_transfer}")
            elif fastflix.current_video.color_transfer in color_transfer_mapping:
                x265_params.append(
                    f"transfer={color_transfer_mapping[fastflix.current_video.color_transfer]}"
                )

        if fastflix.current_video.video_settings.color_space:
            x265_params.append(
                f"colormatrix={fastflix.current_video.video_settings.color_space}"
            )
        elif fastflix.current_video.color_space:
            if fastflix.current_video.color_space in x265_valid_color_matrix:
                x265_params.append(
                    f"colormatrix={fastflix.current_video.color_space}")
            elif fastflix.current_video.color_space in color_matrix_mapping:
                x265_params.append(
                    f"colormatrix={color_matrix_mapping[fastflix.current_video.color_space]}"
                )

        if settings.pix_fmt in ("yuv420p10le", "yuv420p12le"):
            x265_params.append(
                f"hdr10_opt={'1' if settings.hdr10_opt else '0'}")

            if fastflix.current_video.master_display:
                settings.hdr10 = True
                x265_params.append(
                    "master-display="
                    f"G{fastflix.current_video.master_display.green}"
                    f"B{fastflix.current_video.master_display.blue}"
                    f"R{fastflix.current_video.master_display.red}"
                    f"WP{fastflix.current_video.master_display.white}"
                    f"L{fastflix.current_video.master_display.luminance}")

            if fastflix.current_video.cll:
                settings.hdr10 = True
                x265_params.append(f"max-cll={fastflix.current_video.cll}")

            x265_params.append(f"hdr10={'1' if settings.hdr10 else '0'}")

        current_chroma_loc = fastflix.current_video.current_video_stream.get(
            "chroma_location")
        if current_chroma_loc in chromaloc_mapping:
            x265_params.append(
                f"chromaloc={chromaloc_mapping[current_chroma_loc]}")

    if settings.hdr10plus_metadata:
        x265_params.append(f"dhdr10-info='{settings.hdr10plus_metadata}'")

    if settings.intra_encoding:
        x265_params.append("keyint=1")

    if settings.intra_refresh:
        x265_params.append("intra-refresh=1")

    if settings.lossless:
        x265_params.append("lossless=1")

    if fastflix.current_video.video_settings.maxrate:
        x265_params.append(
            f"vbv-maxrate={fastflix.current_video.video_settings.maxrate}")
        x265_params.append(
            f"vbv-bufsize={fastflix.current_video.video_settings.bufsize}")

    if fastflix.current_video.cll:
        pass

    pass_log_file = fastflix.current_video.work_path / f"pass_log_file_{secrets.token_hex(10)}"

    def get_x265_params(params=()):
        if not isinstance(params, (list, tuple)):
            params = [params]
        all_params = x265_params + list(params)
        return '-x265-params "{}" '.format(
            ":".join(all_params)) if all_params else ""

    if settings.bitrate:
        command_1 = (
            f'{beginning} {get_x265_params(["pass=1", "no-slow-firstpass=1"])} '
            f'-passlogfile "{pass_log_file}" -b:v {settings.bitrate} -preset:v {settings.preset} {settings.extra if settings.extra_both_passes else ""} '
            f" -an -sn -dn -f mp4 {null}")
        command_2 = (
            f'{beginning} {get_x265_params(["pass=2"])} -passlogfile "{pass_log_file}" '
            f"-b:v {settings.bitrate} -preset:v {settings.preset} {settings.extra} {ending}"
        )
        return [
            Command(command=command_1, name="First pass bitrate",
                    exe="ffmpeg"),
            Command(command=command_2,
                    name="Second pass bitrate",
                    exe="ffmpeg"),
        ]

    elif settings.crf:
        command = (f"{beginning} {get_x265_params()}  -crf:v {settings.crf} "
                   f"-preset:v {settings.preset} {settings.extra} {ending}")
        return [Command(command=command, name="Single pass CRF", exe="ffmpeg")]

    else:
        return []
Ejemplo n.º 14
0
def build(fastflix: FastFlix):
    settings: SVTAV1Settings = fastflix.current_video.video_settings.video_encoder_settings
    beginning, ending = generate_all(fastflix, "libsvtav1")

    beginning += (
        f"-strict experimental "
        f"-preset {settings.speed} "
        f"-tile_columns {settings.tile_columns} "
        f"-tile_rows {settings.tile_rows} "
        f"-tier {settings.tier} "
        f"-sc_detection {'true' if settings.scene_detection else 'false'} "
        f"{generate_color_details(fastflix)} ")

    svtav1_params = settings.svtav1_params.copy()

    if not fastflix.current_video.video_settings.remove_hdr:

        if (fastflix.current_video.video_settings.color_primaries == "bt2020"
                or fastflix.current_video.color_primaries == "bt2020"):
            svtav1_params.append(f"color-primaries=9")

        if (fastflix.current_video.video_settings.color_transfer == "smpte2084"
                or fastflix.current_video.color_transfer == "smpte2084"):
            svtav1_params.append(f"transfer-characteristics=16")

        if (fastflix.current_video.video_settings.color_space and "bt2020"
                in fastflix.current_video.video_settings.color_space) or (
                    fastflix.current_video.color_space
                    and "bt2020" in fastflix.current_video.color_space):
            svtav1_params.append(f"matrix-coefficients=9")

        enable_hdr = False
        if settings.pix_fmt in ("yuv420p10le", "yuv420p12le"):

            def convert_me(two_numbers, conversion_rate=50_000) -> str:
                num_one, num_two = map(int, two_numbers.strip("()").split(","))
                return f"{num_one / conversion_rate:0.4f},{num_two / conversion_rate:0.4f}"

            if fastflix.current_video.master_display:
                svtav1_params.append(
                    "mastering-display="
                    f"G({convert_me(fastflix.current_video.master_display.green)})"
                    f"B({convert_me(fastflix.current_video.master_display.blue)})"
                    f"R({convert_me(fastflix.current_video.master_display.red)})"
                    f"WP({convert_me(fastflix.current_video.master_display.white)})"
                    f"L({convert_me(fastflix.current_video.master_display.luminance, 10_000)})"
                )
                enable_hdr = True

            if fastflix.current_video.cll:
                svtav1_params.append(
                    f"content-light={fastflix.current_video.cll}")
                enable_hdr = True

            if enable_hdr:
                svtav1_params.append("enable-hdr=1")

    if svtav1_params:
        beginning += f" -svtav1-params \"{':'.join(svtav1_params)}\" "

    if not settings.single_pass:
        pass_log_file = fastflix.current_video.work_path / f"pass_log_file_{secrets.token_hex(10)}"
        beginning += f'-passlogfile "{pass_log_file}" '

    pass_type = "bitrate" if settings.bitrate else "QP"

    if settings.single_pass:
        if settings.bitrate:
            command_1 = f"{beginning} -b:v {settings.bitrate} {settings.extra} {ending}"

        elif settings.qp is not None:
            command_1 = f"{beginning} -{settings.qp_mode} {settings.qp} {settings.extra} {ending}"
        else:
            return []
        return [Command(command=command_1, name=f"{pass_type}", exe="ffmpeg")]
    else:
        if settings.bitrate:
            command_1 = f"{beginning} -b:v {settings.bitrate} -pass 1 {settings.extra if settings.extra_both_passes else ''} -an -f matroska {null}"
            command_2 = f"{beginning} -b:v {settings.bitrate} -pass 2 {settings.extra} {ending}"

        elif settings.qp is not None:
            command_1 = f"{beginning} -qp {settings.qp} -pass 1 {settings.extra if settings.extra_both_passes else ''} -an -f matroska {null}"
            command_2 = f"{beginning} -qp {settings.qp} -pass 2 {settings.extra} {ending}"
        else:
            return []
        return [
            Command(command=command_1,
                    name=f"First pass {pass_type}",
                    exe="ffmpeg"),
            Command(command=command_2,
                    name=f"Second pass {pass_type} ",
                    exe="ffmpeg"),
        ]