mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-08-24 10:14:13 -05:00
obs-outputs: Use multitrack DBR capability flag
Use the new `OBS_ENCODER_CAP_MULTITRACK_DYN_BITRATE` flag when streaming with multiple tracks, instead of relying on the single- track `OBS_ENCODER_CAP_DYN_BITRATE` flag. In multitrack cases where multiple codecs are being used (e.g. mixed AVC and HEVC), all encoders must support the multitrack capability flag otherwise the dynamic bitrate (DBR) feature is disabled for the streaming session.
This commit is contained in:
committed by
Ryan Foster
parent
0943ea2cf6
commit
83ed914ecf
@@ -1379,7 +1379,17 @@ static bool init_connect(struct rtmp_stream *stream)
|
||||
da_reserve(stream->dbr_interpolation_table, 2);
|
||||
da_push_back_new(stream->dbr_interpolation_table);
|
||||
struct dbr_interpolation_point *dbr_point = da_push_back_new(stream->dbr_interpolation_table);
|
||||
for (size_t i = 0; i < MAX_OUTPUT_VIDEO_ENCODERS; i++) {
|
||||
|
||||
/* Determine if the stream is multitrack by checking for any encoder beyond index 0 */
|
||||
bool is_multitrack = false;
|
||||
for (size_t j = 1; j < MAX_OUTPUT_VIDEO_ENCODERS; ++j) {
|
||||
if (obs_output_get_video_encoder2(stream->output, j) != NULL) {
|
||||
is_multitrack = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < MAX_OUTPUT_VIDEO_ENCODERS; ++i) {
|
||||
obs_encoder_t *enc = obs_output_get_video_encoder2(stream->output, i);
|
||||
if (!enc)
|
||||
continue;
|
||||
@@ -1387,13 +1397,25 @@ static bool init_connect(struct rtmp_stream *stream)
|
||||
const char *codec = obs_encoder_get_codec(enc);
|
||||
stream->video_codec[i] = to_video_type(codec);
|
||||
|
||||
if ((obs_encoder_get_caps(enc) & OBS_ENCODER_CAP_DYN_BITRATE) == 0) {
|
||||
uint32_t caps = obs_encoder_get_caps(enc);
|
||||
bool has_dbr_cap = (caps & OBS_ENCODER_CAP_DYN_BITRATE) != 0;
|
||||
bool has_multitrack_dbr_cap = (caps & OBS_ENCODER_CAP_MULTITRACK_DYN_BITRATE) != 0;
|
||||
|
||||
// For multitrack, all encoders must support multitrack Dynamic Bitrate (DBR). For single track,
|
||||
// encoder must support standard Dynamic Bitrate.
|
||||
bool dbr_supported = is_multitrack ? has_multitrack_dbr_cap : has_dbr_cap;
|
||||
|
||||
if (!dbr_supported) {
|
||||
dbr_capable = false;
|
||||
info("Dynamic bitrate disabled. "
|
||||
"The encoder '%s' does not support on-the-fly "
|
||||
"bitrate reconfiguration.",
|
||||
obs_encoder_get_name(enc));
|
||||
continue;
|
||||
if (!has_dbr_cap) {
|
||||
info("Dynamic bitrate disabled. "
|
||||
"The encoder '%s' does not support on-the-fly bitrate reconfiguration.",
|
||||
obs_encoder_get_name(enc));
|
||||
} else if (is_multitrack && !has_multitrack_dbr_cap) {
|
||||
info("Dynamic bitrate disabled. "
|
||||
"The encoder '%s' does not support on-the-fly multitrack bitrate reconfiguration.",
|
||||
obs_encoder_get_name(enc));
|
||||
}
|
||||
}
|
||||
|
||||
obs_data_t *settings = obs_encoder_get_settings(enc);
|
||||
|
||||
Reference in New Issue
Block a user