From 9d7f47413c68d936d2a8ae00736ec9e55851a950 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Fri, 7 Apr 2023 00:49:56 -0700 Subject: [PATCH] FFmpeg: Fix buffer size rounding for audio encoding --- src/feature/ffmpeg/ffmpeg-encoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/feature/ffmpeg/ffmpeg-encoder.c b/src/feature/ffmpeg/ffmpeg-encoder.c index f1a26ec32..88f4f78c2 100644 --- a/src/feature/ffmpeg/ffmpeg-encoder.c +++ b/src/feature/ffmpeg/ffmpeg-encoder.c @@ -881,7 +881,7 @@ void FFmpegEncoderSetInputSampleRate(struct FFmpegEncoder* encoder, int sampleRa } void _ffmpegOpenResampleContext(struct FFmpegEncoder* encoder) { - encoder->audioBufferSize = av_rescale_q(encoder->audioFrame->nb_samples, (AVRational) { 4, encoder->sampleRate }, (AVRational) { 1, encoder->isampleRate }); + encoder->audioBufferSize = av_rescale_q(encoder->audioFrame->nb_samples, (AVRational) { 1, encoder->sampleRate }, (AVRational) { 1, encoder->isampleRate }) * 4; encoder->audioBuffer = av_malloc(encoder->audioBufferSize); #ifdef USE_LIBAVRESAMPLE encoder->resampleContext = avresample_alloc_context();