feat: add min_fps_target setting (#1043)
This commit is contained in:
@@ -331,6 +331,7 @@ namespace config {
|
||||
0, // hevc_mode
|
||||
0, // av1_mode
|
||||
|
||||
1, // min_fps_factor
|
||||
2, // min_threads
|
||||
{
|
||||
"superfast"s, // preset
|
||||
@@ -1030,6 +1031,7 @@ namespace config {
|
||||
string_f(vars, "encoder", video.encoder);
|
||||
string_f(vars, "adapter_name", video.adapter_name);
|
||||
string_f(vars, "output_name", video.output_name);
|
||||
int_between_f(vars, "min_fps_factor", video.min_fps_factor, { 1, 3 });
|
||||
|
||||
path_f(vars, "pkey", nvhttp.pkey);
|
||||
path_f(vars, "cert", nvhttp.cert);
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace config {
|
||||
int hevc_mode;
|
||||
int av1_mode;
|
||||
|
||||
int min_fps_factor; // Minimum fps target, determines minimum frame time
|
||||
int min_threads; // Minimum number of threads/slices for CPU encoding
|
||||
struct {
|
||||
std::string sw_preset;
|
||||
|
||||
@@ -1771,6 +1771,10 @@ namespace video {
|
||||
return;
|
||||
}
|
||||
|
||||
// set minimum frame time, avoiding violation of client-requested target framerate
|
||||
auto minimum_frame_time = std::chrono::milliseconds(1000 / std::min(config.framerate, (config::video.min_fps_factor * 10)));
|
||||
BOOST_LOG(debug) << "Minimum frame time set to "sv << minimum_frame_time.count() << "ms, based on min fps factor of "sv << config::video.min_fps_factor << "."sv;
|
||||
|
||||
auto shutdown_event = mail->event<bool>(mail::shutdown);
|
||||
auto packets = mail::man->queue<packet_t>(mail::video_packets);
|
||||
auto idr_events = mail->event<bool>(mail::idr);
|
||||
@@ -1811,9 +1815,9 @@ namespace video {
|
||||
|
||||
std::optional<std::chrono::steady_clock::time_point> frame_timestamp;
|
||||
|
||||
// Encode at a minimum of 10 FPS to avoid image quality issues with static content
|
||||
// Encode at a minimum FPS to avoid image quality issues with static content
|
||||
if (!requested_idr_frame || images->peek()) {
|
||||
if (auto img = images->pop(100ms)) {
|
||||
if (auto img = images->pop(minimum_frame_time)) {
|
||||
frame_timestamp = img->frame_timestamp;
|
||||
if (session->convert(*img)) {
|
||||
BOOST_LOG(error) << "Could not convert image"sv;
|
||||
|
||||
Reference in New Issue
Block a user