Skip to content

Commit

Permalink
Add new nvenc options to legacy ffmpeg path
Browse files Browse the repository at this point in the history
  • Loading branch information
ns6089 committed Oct 29, 2023
1 parent fd7fb3a commit 90ad87c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,8 @@ namespace config {
video.nv.two_pass == nvenc::nvenc_two_pass::full_resolution ? NV_ENC_TWO_PASS_FULL_RESOLUTION :
NV_ENC_MULTI_PASS_DISABLED;
video.nv_legacy.h264_coder = video.nv.h264_cavlc ? NV_ENC_H264_ENTROPY_CODING_MODE_CAVLC : NV_ENC_H264_ENTROPY_CODING_MODE_CABAC;
video.nv_legacy.aq = video.nv.adaptive_quantization;
video.nv_legacy.vbv_percentage_increase = video.nv.vbv_percentage_increase;
#endif

int_f(vars, "qsv_preset", video.qsv.qsv_preset, qsv::preset_from_view);
Expand Down
2 changes: 2 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ namespace config {
int preset;
int multipass;
int h264_coder;
int aq;
int vbv_percentage_increase;
} nv_legacy;

struct {
Expand Down
9 changes: 9 additions & 0 deletions src/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ namespace video {
{ "tune"s, NV_ENC_TUNING_INFO_ULTRA_LOW_LATENCY },
{ "rc"s, NV_ENC_PARAMS_RC_CBR },
{ "multipass"s, &config::video.nv_legacy.multipass },
{ "aq"s, &config::video.nv_legacy.aq },
},
// SDR-specific options
{},
Expand All @@ -649,6 +650,7 @@ namespace video {
{ "tune"s, NV_ENC_TUNING_INFO_ULTRA_LOW_LATENCY },
{ "rc"s, NV_ENC_PARAMS_RC_CBR },
{ "multipass"s, &config::video.nv_legacy.multipass },
{ "aq"s, &config::video.nv_legacy.aq },
},
// SDR-specific options
{
Expand All @@ -671,6 +673,7 @@ namespace video {
{ "rc"s, NV_ENC_PARAMS_RC_CBR },
{ "coder"s, &config::video.nv_legacy.h264_coder },
{ "multipass"s, &config::video.nv_legacy.multipass },
{ "aq"s, &config::video.nv_legacy.aq },
},
// SDR-specific options
{
Expand Down Expand Up @@ -1578,6 +1581,12 @@ namespace video {
}
else {
ctx->rc_buffer_size = bitrate / config.framerate;

#ifndef __APPLE__
if (encoder.name == "nvenc" && config::video.nv_legacy.vbv_percentage_increase > 0) {
ctx->rc_buffer_size += ctx->rc_buffer_size * config::video.nv_legacy.vbv_percentage_increase / 100;
}
#endif
}
}
}
Expand Down

0 comments on commit 90ad87c

Please sign in to comment.