aformat

doc

https://ffmpeg.org/ffmpeg-filters.html#aformat-1, (ffmpeg-utils)2.8. Syntax | Channel Layout

The description in the official documentation:

Set output format constraints for the input audio. The framework will negotiate the most appropriate format to minimize conversions.

It accepts the following parameters:

  • sample_fmts

    A ‘|’-separated list of requested sample formats.

  • sample_rates

    A ‘|’-separated list of requested sample rates.

  • channel_layouts

    A ‘|’-separated list of requested channel layouts.

    See (ffmpeg-utils)2.8. Syntax | Channel Layout for the required syntax.

If a parameter is omitted, all values are allowed.

This filter has a much greater chance of being used “inevitably” due to the limitations of individual filters than in the case where it is desired to use it. Therefore, even if you are a beginner who wants to be careless about this, when you get errors from other filters, then you have to try to use this filter, and you will get stuck with this documentation flaw.

I mean … what is “sample_fmt”!? Even if you have knowledge about digital audio, what you need to know now is “sample_fmt strings accepted by ffmpeg”. This is as follows:

sample_fmt

meaning

u8

unsigned 8 bits

s16

signed 16 bits

s32

signed 32 bits

s64

signed 64 bits

flt

float

dbl

double

u8p

unsigned 8 bits

planar

s16p

signed 16 bits

planar

s32p

signed 32 bits

planar

s64p

signed 64 bits

planar

fltp

float

planar

dblp

double

planar

So, for example:

[me@host: ~]$ ffplay some.wav -af "
> aformat='sample_fmts=u8|u16:channel_layouts=stereo'
> ,asetrate='44100*4/3'"

Again, most of the time you use this as a prerequisite for the filter you want to use. You rarely control the sample format of the final output with this filter. After all, it is implicitly determined by the specifications of the container or the encoder. To control actual the sample format of the final output, for example:

[me@host: ~]$ ffmpeg -y -i wolframtones_02.wav \
> -c:a pcm_f32le wolframtones_02fltp.wav