From ae862c16a6ae7d3813be0b6f5e6bccf1401b6e53 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Mon, 10 Nov 2014 01:10:19 -0800 Subject: [PATCH] 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. --- plugins/obs-ffmpeg/obs-ffmpeg-aac.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-aac.c b/plugins/obs-ffmpeg/obs-ffmpeg-aac.c index 53b467e31..154181700 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-aac.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-aac.c @@ -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);