[FFmpeg-user] How to set sample format for the alsa demuxer?

LANGLOIS Olivier PIS -EXT olivier.pis.langlois at transport.alstom.com
Tue Dec 10 20:44:17 CET 2013


I want to set the input sample format to s32 but I failed to change it from its S16_LE default format.

Am I doing something wrong or did I have stumbled onto a small ffmpeg bug?

lano1106 at hpmini ~/dev/packages/ffmpeg/repos/extra-i686/src/ffmpeg-2.1.1/libavdevice :( $ ffmpeg -f alsa -sample_fmt s32 -i hw:1,1,0 -strict -2 -acodec aac -ar 48000 -b:a 64k out.aac
ffmpeg version 2.1.1 Copyright (c) 2000-2013 the FFmpeg developers
  built on Dec 10 2013 17:24:34 with gcc 4.8.2 (GCC)
  configuration: --prefix=/usr --disable-debug --disable-static --enable-avresample --enable-dxva2 --enable-fontconfig --enable-gnutls --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-pic --enable-postproc --enable-runtime-cpudetect --enable-shared --enable-swresample --enable-vdpau --enable-version3 --enable-x11grab
  libavutil      52. 48.101 / 52. 48.101
  libavcodec     55. 39.101 / 55. 39.101
  libavformat    55. 19.104 / 55. 19.104
  libavdevice    55.  5.100 / 55.  5.100
  libavfilter     3. 90.100 /  3. 90.100
  libavresample   1.  1.  0 /  1.  1.  0
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
[alsa @ 0x8b2afa0] cannot set sample format 0x10000 2 (Invalid argument)
hw:1,1,0: Input/output error

>From ffmpeg header files:
avcodec.h:    AV_CODEC_ID_PCM_S16LE = 0x10000,
alsa-audio.h:#define DEFAULT_CODEC_ID AV_NE(AV_CODEC_ID_PCM_S16BE, AV_CODEC_ID_PCM_S16LE)

Here is what I have done to reproduce the problem. I am sending ALSA speaker-test output through the ALSA loopback driver. If I modify the speaker-test output sample format to S16_LE all is fine.

lano1106 at hpmini ~/ffmpeg $ sudo modprobe snd_aloop
[sudo] password for lano1106:
lano1106 at hpmini ~/ffmpeg $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: 92HD81B1X5 Analog [92HD81B1X5 Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 1: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7

>From a different console, I send speaker-test output:

lano1106 at hpmini ~/ffmpeg $ speaker-test -Dhw:1,0,0 -c2 -r192000 -F S32_LE

speaker-test 1.0.27.2

Playback device is hw:1,0,0
Stream parameters are 192000Hz, S32_LE, 2 channels
Using 16 octaves of pink noise
Rate set to 192000Hz (requested 192000Hz)
Buffer size range from 8 to 262144
Period size range from 8 to 131072


________________________________
CONFIDENTIALITY : This e-mail and any attachments are confidential and may be privileged. If you are not a named recipient, please notify the sender immediately and do not disclose the contents to another person, use it for any purpose or store or copy the information in any medium.


More information about the ffmpeg-user mailing list