mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-08-24 10:14:13 -05:00
frontend: Scale simple output recording audio bitrate by channel count
The recording audio bitrate was hardcoded to 192 kbps regardless of channel layout. For a 5.1 mix this yields ~32 kbps per channel which is very low quality. Scale proportionally from the stereo reference (192 kbps) using the active channel count, snapping to the closest bitrate supported by the selected encoder (AAC or Opus). Stereo recordings are unchanged (192 * 2 / 2 = 192 kbps).
This commit is contained in:
committed by
Ryan Foster
parent
dfad5c86f6
commit
f40cf8dd72
@@ -392,14 +392,25 @@ void SimpleOutput::Update()
|
||||
void SimpleOutput::UpdateRecordingAudioSettings()
|
||||
{
|
||||
OBSDataAutoRelease settings = obs_data_create();
|
||||
obs_data_set_int(settings, "bitrate", 192);
|
||||
obs_data_set_string(settings, "rate_control", "CBR");
|
||||
|
||||
const char *audioEncoder = config_get_string(main->Config(), "SimpleOutput", "RecAudioEncoder");
|
||||
int tracks = config_get_int(main->Config(), "SimpleOutput", "RecTracks");
|
||||
const char *recFormat = config_get_string(main->Config(), "SimpleOutput", "RecFormat2");
|
||||
const char *quality = config_get_string(main->Config(), "SimpleOutput", "RecQuality");
|
||||
bool flv = strcmp(recFormat, "flv") == 0;
|
||||
|
||||
constexpr int kDefaultStereoBitrateKbps{192};
|
||||
constexpr int kStereoChannelCount{2};
|
||||
|
||||
int channels = (int)audio_output_get_channels(obs_get_audio());
|
||||
int channelScaledBitrate{kDefaultStereoBitrateKbps * channels / kStereoChannelCount};
|
||||
|
||||
int bitrate = strcmp(audioEncoder, "opus") == 0 ? FindClosestAvailableSimpleOpusBitrate(channelScaledBitrate)
|
||||
: FindClosestAvailableSimpleAACBitrate(channelScaledBitrate);
|
||||
|
||||
obs_data_set_int(settings, "bitrate", bitrate);
|
||||
|
||||
if (flv || strcmp(quality, "Stream") == 0) {
|
||||
obs_encoder_update(audioRecording, settings);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user