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

Martijn van Beurden mvanb1 at gmail.com
Sun Jan 23 15:15:53 EET 2022


Op do 20 jan. 2022 22:18 schreef Anton Khirnov <anton at khirnov.net>:

> 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.
>

I think this patch shouldn't be applied. Without it 32 bit audio is
transcoded to 24 bit audio, which is not lossless. However, with this patch
24 bit audio is transcoded to 32 bit audio which is lossless, but the
resulting files are understood by few software decoder and probably no
hardware decoders.

Perhaps adding a warning instead of setting a default would be better?

>


More information about the ffmpeg-devel mailing list