diff --git a/src/transcode.c b/src/transcode.c index 580795b8..1a92120e 100644 --- a/src/transcode.c +++ b/src/transcode.c @@ -1608,10 +1608,12 @@ transcode_frame_new(void *data, size_t size, int nsamples, struct media_quality // We don't align because the frame won't be given directly to the encoder // anyway, it will first go through the filter (which might align it...?) - ret = avcodec_fill_audio_frame(f, 2, f->format, data, size, 1); + ret = avcodec_fill_audio_frame(f, quality->channels, f->format, data, size, 1); if (ret < 0) { - DPRINTF(E_LOG, L_XCODE, "Error filling frame with rawbuf, size %zu, samples %d (%d/%d/2): %s\n", size, nsamples, quality->sample_rate, quality->bits_per_sample, err2str(ret)); + DPRINTF(E_LOG, L_XCODE, "Error filling frame with rawbuf, size %zu, samples %d (%d/%d/%d): %s\n", + size, nsamples, quality->sample_rate, quality->bits_per_sample, quality->channels, err2str(ret)); + av_frame_free(&f); return NULL; }