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:
jp9000
2014-11-10 01:10:19 -08:00
parent 5888085a8e
commit ae862c16a6

View File

@@ -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);