[FFmpeg-devel] [PATCH 3/3] lavc/encode: pick a sane default for bits_per_raw_sample if it's not set

Anton Khirnov anton at khirnov.net
Thu Jan 20 23:18:03 EET 2022


Quoting Martijn van Beurden (2022-01-20 19:58:54)
> Op do 20 jan. 2022 om 17:05 schreef Anton Khirnov <anton at khirnov.net>:
> 
> > Fixes #9563.
> > ---
> >  libavcodec/encode.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/libavcodec/encode.c b/libavcodec/encode.c
> > index b6f81d1458..44ab81af3f 100644
> > --- a/libavcodec/encode.c
> > +++ b/libavcodec/encode.c
> > @@ -535,6 +535,9 @@ static int encode_preinit_audio(AVCodecContext *avctx)
> >          return AVERROR(EINVAL);
> >      }
> >
> > +    if (!avctx->bits_per_raw_sample)
> > +        avctx->bits_per_raw_sample = 8 *
> > av_get_bytes_per_sample(avctx->sample_fmt);
> > +
> >      return 0;
> >  }
> >
> 
> This creates a new regression: now 24-bit WAV files are converted to 32-bit
> WavPack files. I think I found the cause of the problem though: the issue
> is that wavpack uses sample format s32p and 24-bit wav files use s32.
> Therefore, a aresample filter is auto-inserted to convert s32p to s32,
> which causes ost->filter->graph->is_meta to be false.

You can work around this by using the -bits_per_raw_sample option.
Handling this in a more automagic manner would be complicated - we could
propagate bits_per_raw_sample through lavfi or add it to AVFrame.

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list