Skip to content

Add multitrack video dynamic bitrate support #12097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

lexano-ivs
Copy link
Contributor

@lexano-ivs lexano-ivs commented Apr 29, 2025

Description

Dynamic bitrate (or DBR to keep it short), is a beta feature enabled via Settings -> Advanced -> Network -> "Dynamically change bitrate to manage congestion (Beta)" in the OBS GUI. This feature automatically modulates the video bitrate based on network bandwidth to avoid dropping frames. Support for DBR with multitrack video had been disabled in OBS while it was being tested in the TEB (Twitch Enhanced Broadcasting) beta program. This PR adds support for multitrack video dynamic bitrate.

Note that this PR depends on 2 previous PRs, due to a shared common function HandleIncompatibleSettings() that requires changes in all 3 PRs:

The dependent PRs were merged as of 2025.04.30 and this PR has been rebased against master.

Motivation and Context

Multitrack video sends several video streams in parallel hence uses more overall bandwidth than sending a single stream. In some cases the streamers' available uplink bandwidth is not adequate for multitrack video, so modulating the bitrate on each stream is needed.

How Has This Been Tested?

Testing of multitrack DBR has been occurring for several months in the TEB beta program. In addition, it has been locally tested with NVIDIA GPUs, AMD GPUs (9070XT and 7800XT), and Intel Arc A770.

NVIDIA GPUs work well with multitrack DBR.

AMD GPUs also showed issues with DBR, however this PR introduces changes that forces IDRs on the appropriate frame without needing to flush or reinitialize the AMF pipeline to solve the issues.

The Intel Arc A770 test revealed an issue:

15:12:49.701: [qsv encoder: 'multitrack video video encoder 1'] Failed to reconfigure
15:12:50.009: [qsv encoder: 'multitrack video video encoder 0'] Failed to reconfigure

The failure to reconfigure resulted in all streams ceasing to transmit data and an eventual hang of OBS which needed to be terminated with Task Manager. The multitrack DBR feature checks if the encoder supports reconfiguration (it looks for OBS_ENCODER_CAP_DYN_BITRATE. It is possible that Intel Arc GPUs do not support reconfiguration but have the bit set. This requires further investigation and testing.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

Copy link
Member

@RytoEX RytoEX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be rebased now that #12003 and #12004 are merged. Remove the changes to all locale files except en-US.ini, as the others will be written/overwritten when we pull in translations.

palana and others added 5 commits April 30, 2025 13:47
Also reconfigure all grouped encoders on the same frame.
The bitrate interpolation points are sent in JSON configuration and
need to be forwarded to `create_video_encoders()`. Also remove the
`HandleIncompatibleSettings()` handler because there are no longer any
incompatible settings.
The `amf_xxx_update()` functions for AVC, HEVC, and AV1 are
unconditionally invoking Flush() and ReInit() even though this is not
required in all situations. Changing the bitrate at least in CBR mode
does not require the flush operation and can result in unaligned IDR
frames across members of an encoder group. Do not flush the pipeline
for CBR bitrate changes; instead, force an IDR to occur with the
bitrate change.
Remove the locale strings that are no longer needed now that
`HandleIncompatibleSettings()` is removed.
@lexano-ivs lexano-ivs force-pushed the lexano/multitrack-dbr branch from 3a9ce08 to f27d84a Compare April 30, 2025 18:11
@lexano-ivs
Copy link
Contributor Author

This can be rebased now that #12003 and #12004 are merged. Remove the changes to all locale files except en-US.ini, as the others will be written/overwritten when we pull in translations.

Thanks for the tip re: locale files. Changes have been made and rebased to master.

@WizardCM WizardCM added the New Feature New feature or plugin label May 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Feature New feature or plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants