mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-01-29 08:31:54 -05:00
obs-ffmpeg: If ffaac is used, change cutoff freq
If FFmpeg's experimental aac encoder is used, this changes the cutoff frequency to better values in order to try to help make up for the inherent lack of encoder quality a bit. If FFmpeg is compiled to use another encoder by default, these settings will not be applied.
This commit is contained in:
@@ -121,6 +121,10 @@ static void init_sizes(struct aac_encoder *enc, audio_t *audio)
|
||||
enc->audio_size = get_audio_size(format, aoi->speakers, 1);
|
||||
}
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(x, y) ((x) < (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
static void *aac_create(obs_data_t *settings, obs_encoder_t *encoder)
|
||||
{
|
||||
struct aac_encoder *enc;
|
||||
@@ -156,6 +160,19 @@ static void *aac_create(obs_data_t *settings, obs_encoder_t *encoder)
|
||||
enc->context->sample_fmt = enc->aac->sample_fmts ?
|
||||
enc->aac->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;
|
||||
|
||||
/* if using FFmpeg's AAC encoder, at least set a cutoff value
|
||||
* (recommended by konverter) */
|
||||
if (strcmp(enc->aac->name, "aac") == 0) {
|
||||
int cutoff1 = 4000 + enc->context->bit_rate / 8;
|
||||
int cutoff2 = 12000 + enc->context->bit_rate / 8;
|
||||
int cutoff3 = enc->context->sample_rate / 2;
|
||||
int cutoff;
|
||||
|
||||
cutoff = MIN(cutoff1, cutoff2);
|
||||
cutoff = MIN(cutoff, cutoff3);
|
||||
enc->context->cutoff = cutoff;
|
||||
}
|
||||
|
||||
blog(LOG_INFO, "FFmpeg AAC: bitrate: %d, channels: %d",
|
||||
enc->context->bit_rate / 1000, enc->context->channels);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user