diff --git a/docs/configuration.md b/docs/configuration.md index bd0e3038..a952abed 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -49,9 +49,10 @@ Default values: full image (`width` = 1, `height` = 1, `offset_x` = 0, `offset_y Specifies the portion of the video to encode: all values are in 0, 1 range. Left eye image ranges from x 0 to x 0.5 and y 0 to 1, Rigth eye is x from 0.5 to 1 and y 0 to 1. ### `group` (very advanced) -Default value: First unused group identifier, if omitted on all encoders, they are executed concurrently. +Default value: One value for each encoder type (nvenc, vaapi, x264). Identifier (number) of the encoder group. Encoders with the same identifier are executed sequentially, in the order they are defined in the configuration. Encoders with different identifiers are executed concurrently. +Default setting will have all encoders of a given type execute sequentially, and different types in parallel. ### Examples 1. Simple encoder diff --git a/server/encoder/encoder_settings.cpp b/server/encoder/encoder_settings.cpp index dd25735e..1e46cb2d 100644 --- a/server/encoder/encoder_settings.cpp +++ b/server/encoder/encoder_settings.cpp @@ -292,7 +292,17 @@ std::vector get_encoder_settings(wivrn_vk_bundle & bundle, uin height += height % 2; std::vector res; + std::unordered_map groups; int next_group = 0; + for (const auto & encoder: config.encoders) + { + if (encoder.group) + { + groups[encoder.name] = *encoder.group; + next_group = std::max(next_group, *encoder.group + 1); + } + } + for (const auto & encoder: config.encoders) { wivrn::encoder_settings settings{}; @@ -306,11 +316,18 @@ std::vector get_encoder_settings(wivrn_vk_bundle & bundle, uin make_even(settings.width, width - settings.offset_x); make_even(settings.height, height - settings.offset_y); settings.codec = *encoder.codec; - settings.group = encoder.group.value_or(next_group); + if (encoder.group) + settings.group = *encoder.group; + else + { + auto [it, inserted] = groups.emplace(encoder.name, next_group); + settings.group = it->second; + if (inserted) + ++next_group; + } settings.options = encoder.options; settings.device = encoder.device; - next_group = std::max(next_group, settings.group + 1); res.push_back(settings); } split_bitrate(res, bitrate);