Skip to content

Commit

Permalink
initial av1_nvenc support
Browse files Browse the repository at this point in the history
  • Loading branch information
GBeauregard committed Nov 11, 2023
1 parent 4e30748 commit 34bca2a
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/pyffstream/encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,35 @@ def get_hevc_nvenc_flags(fv: EncodeSession) -> list[str]:
return flags


# TODO: enable SEI when nvidia fixes their driver (495 series)
# TODO: make workaround and encode options dependent on ffmpeg version
def get_av1_nvenc_flags(fv: EncodeSession) -> list[str]:
# fmt: off
flags = [
"-c:v", "av1_nvenc",
*common_keyint_flags(fv),
"-highbitdepth:v", *(("0",) if fv.ev.eightbit else ("1",)),
"-threads:v", "3",
"-forced-idr:v", "1",
*(("-no-scenecut:v", "1") if not fv.ev.vgop else ()),
"-spatial-aq:v", "1",
"-temporal-aq:v", "1",

"-preset:v", "p7",
"-tune:v", "hq",
"-rc:v", "cbr" if fv.ev.rc_mode == "cbr" else "vbr",
"-multipass:v", "fullres",
"-bf:v", "3",
"-b_ref_mode:v", "each",
"-rc-lookahead:v", "32",
*min_version(("-s12m_tc:v", "0"), ("libavcodec", "59.1.101")),
*min_version(("-extra_sei:v", "0"), ("libavcodec", "59.1.101")),
*common_bitrate_flags(fv),
]
# fmt: on
return flags


# TODO: enable SEI when nvidia fixes their driver (495 series)
# TODO: make workaround and encode options dependent on ffmpeg version
def get_h264_nvenc_flags(fv: EncodeSession) -> list[str]:
Expand Down Expand Up @@ -690,6 +719,13 @@ class Params:
tenbit=True,
type=EncType.NVIDIA,
),
"av1_nvenc": VEncoder(
name="av1_nvenc",
flag_function=get_av1_nvenc_flags,
codec="av1",
tenbit=True,
type=EncType.NVIDIA,
),
"libaom-av1": VEncoder(
name="libaom-av1",
flag_function=get_libaom_av1_flags,
Expand Down

0 comments on commit 34bca2a

Please sign in to comment.