[FFmpeg-user] Why doesn't FFplay try to guess the channel layout of wav-files?

Reino Wijnsma rwijnsma at xs4all.nl
Sat May 8 02:53:19 EEST 2021


Hello ffmpeg-user and devs,

FFmpeg binary used:

ffmpeg version N-102342-g5541cff-Reino Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 10.3.0 (GCC)
  configuration: --arch=x86 --target-os=mingw32 --prefix=/cygdrive/[...]/cross_compilers/mingw-w64-i686/i686-w64-mingw32 --cross-prefix=/cygdrive/[...]/cross_compilers/mingw-w64-i686/bin/i686-w64-mingw32- --extra-cflags='-march=pentium3 -mtune=athlon-xp -O2 -mfpmath=sse -msse' --pkg-config=pkg-config --pkg-config-flags=--static --extra-version=Reino --enable-gpl --enable-gray --enable-version3 --disable-debug --disable-doc --disable-htmlpages --disable-manpages --disable-mediafoundation --disable-podpages --disable-txtpages --disable-w32threads --enable-avisynth --enable-frei0r --enable-filter=frei0r --enable-gmp --enable-libaom --enable-libass --enable-libfdk-aac --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libmp3lame --enable-libopenmpt --enable-libopus --enable-libsoxr --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2
--enable-libxvid --enable-libzimg --enable-mbedtls
  libavutil      57.  0.100 / 57.  0.100
  libavcodec     59.  0.100 / 59.  0.100
  libavformat    59.  0.100 / 59.  0.100
  libavdevice    59.  0.100 / 59.  0.100
  libavfilter     8.  0.101 /  8.  0.101
  libswscale      6.  0.100 /  6.  0.100
  libswresample   4.  0.100 /  4.  0.100
  libpostproc    56.  0.100 / 56.  0.100

Input file:

ffmpeg -v 40 -i "D:\input.wav" -f null NUL
[...]
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, wav, from 'D:\input.wav':
  Duration: 00:00:25.50, bitrate: 1411 kb/s
  Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_s16le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
[graph_0_in_0_0 @ 0510f980] tb:1/44100 samplefmt:s16 samplerate:44100 chlayout:0x3
[...]

FFmpeg sets "-channel_layout stereo" in the background, hence "[graph_0_in_0_0 @ 0510f980] ... chlayout:-0x3-".
FFplay for some reason doesn't guess the channel layout:

ffplay -v 40 -nodisp -autoexit "D:\input.wav"
[...]
Input #0, wav, from 'D:\input.wav':
  Duration: 00:00:25.50, bitrate: 1411 kb/s
  Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2 channels, s16, 1411 kb/s
[ffplay_abuffer @ 05b1e0c0] tb:1/44100 samplefmt:s16 samplerate:44100 chlayout:-(null)-
[...]

It plays the wav-file nontheless. Problems start to occur however when audiofilters are applied, like when changing the tempo and pitch for instance.
No problem for FFmpeg:

ffmpeg -v 40 [-channel_layout stereo] -i "D:\input.wav" -af "asetrate=22050" -f null NUL
[...]
[graph_0_in_0_0 @ 05117c80] tb:1/44100 samplefmt:s16 samplerate:44100 chlayout:0x3
Output #0, null, to 'NUL':
  Metadata:
    encoder         : Lavf59.0.100
  Stream #0:0: Audio: pcm_s16le, 22050 Hz, stereo, s16, 705 kb/s
[...]

But FFplay returns:

ffplay -v 40 -nodisp -autoexit -af "asetrate=22050" "D:\input.wav"
[...]
[ffplay_abuffer @ 05ad1200] tb:1/44100 samplefmt:s16 samplerate:44100 chlayout:(null)
[Parsed_asetrate_0 @ 05b43300] auto-inserting filter 'auto_resampler_0' between the filter 'ffplay_abuffer' and the filter 'Parsed_asetrate_0'
[auto_resampler_0 @ 05a2d040] Cannot select channel layout for the link between filters auto_resampler_0 and Parsed_asetrate_0.
[auto_resampler_0 @ 05a2d040] Unknown channel layouts not supported, try specifying a channel layout using 'aformat=channel_layouts=something'.

It appears that "-channel_layout" isn't a valid option for FFplay, so would...

ffplay -v 40 -nodisp -autoexit -af "aformat=cl=stereo,asetrate=22050" "D:\input.wav"

...be the only way to set the channel layout (to satisfy asetrate at least)?
Isn't there a "-channel_layout" like option for FFplay to properly set the channel layout? But more importantly, why doesn't FFplay try to guess the channel layout of wav-files like FFmpeg does?

---

Small side question:

-af "loudnorm,aformat=cl=stereo,aresample=44100"
-af "loudnorm,aresample=44100:ocl=stereo"

Is there a difference between the two, or is the end result the same quality-wise?

-- 
Reino



More information about the ffmpeg-user mailing list