From 265fe9a2ca606f8b9ae4a110390f26c139c01ad7 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Mon, 6 Aug 2018 15:54:37 +0200 Subject: [PATCH] src/io/source_avcodec.c: give up reading file if number of channel changes during stream (closes #137) --- src/io/source_avcodec.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c index 6d8efa79..7082bc2e 100644 --- a/src/io/source_avcodec.c +++ b/src/io/source_avcodec.c @@ -425,6 +425,13 @@ void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s, uint_t * read_sam goto beach; } + if (avFrame->channels != (sint_t)s->input_channels) { + AUBIO_WRN ("source_avcodec: trying to read from %d channel(s)," + "but configured for %d; is '%s' corrupt?\n", avFrame->channels, + s->input_channels, s->path); + goto beach; + } + #ifdef HAVE_AVRESAMPLE in_linesize = 0; av_samples_get_buffer_size(&in_linesize, avCodecCtx->channels, -- 2.11.0