[FFmpeg-devel] [PATCH]lavf/rawenc: Do not allow encoding 0 audio channels

Carl Eugen Hoyos ceffmpeg at gmail.com
Mon Jul 1 01:19:58 EEST 2019


Am Mo., 1. Juli 2019 um 00:12 Uhr schrieb James Almer <jamrial at gmail.com>:
>
> On 6/30/2019 7:01 PM, Carl Eugen Hoyos wrote:
> > Hi!
> >
> > Attached patch fixes ticket #7979 for me, please comment.
> >
> > Thank you, Carl Eugen
> >
> >
> > 0001-lavf-rawenc-Do-not-allow-encoding-0-audio-channels.patch
> >
> > From 976b294c10be32667852729c3652dbec466ac091 Mon Sep 17 00:00:00 2001
> > From: Carl Eugen Hoyos <ceffmpeg at gmail.com>
> > Date: Mon, 1 Jul 2019 00:00:38 +0200
> > Subject: [PATCH] lavf/rawenc: Do not allow encoding 0 audio channels.
> >
> > Fixes ticket #7979.
> > ---
> >  libavformat/rawenc.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c
> > index 993d232b70..0d00e5a0c5 100644
> > --- a/libavformat/rawenc.c
> > +++ b/libavformat/rawenc.c
> > @@ -39,6 +39,10 @@ static int force_one_stream(AVFormatContext *s)
> >                 s->oformat->name);
> >          return AVERROR(EINVAL);
> >      }
> > +    if (s->streams[0]->codecpar->channels == 0) {
> > +        av_log(s, AV_LOG_ERROR, "Encoding 0 channels is impossible\n");
>
> This looks like something that should be checked in init_muxer() from
> mux.c instead, same way it's checking sample_rate <= 0 for audio, and
> dimensions for video. That way it will apply to all muxers.

Unfortunately, the crash cannot be fixed in init_muxer() - at least not
where the sample_rate check is.

I am not saying my suggestion is the only solution, but it is what I
successfully tested.

Carl Eugen


More information about the ffmpeg-devel mailing list