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 authored and cgutman committed Jan 21, 2024
1 parent 6ded2a9 commit fe88663
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 @@ -953,6 +953,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 @@ -638,6 +638,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 @@ -658,6 +659,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 @@ -681,6 +683,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 @@ -1698,6 +1701,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 fe88663

Please sign in to comment.