Opened 16 months ago

Last modified 7 weeks ago

#10132 reopened defect

ffmpeg ignores -ac option

Reported by: bolvan Owned by:
Priority: normal Component: undetermined
Version: 5.1.2 Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

It works fine with ffmpeg 4.3.1 on the same system

ffmpeg -f alsa -ac 1 -i cam test.wav
ffmpeg version 5.1.2 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 11.2.0 (OpenWrt GCC 11.2.0 r19803-9a599fee93)
  configuration: --enable-cross-compile --cross-prefix=x86_64-openwrt-linux-musl- --arch=x86_64 --cpu= --target-os=linux --prefix=/usr --pkg-config=pkg-config --enable-shared --enable-static --enable-pthreads --enable-zlib --enable-libdrm --disable-doc --disable-debug --disable-lzma --enable-vaapi --disable-vdpau --disable-outdevs --enable-lto --enable-x86asm --enable-openssl --enable-nonfree --enable-hardcoded-tables --enable-libmp3lame --enable-libx265 --enable-gpl --enable-libx264
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
[alsa @ 0x7ffff7ffe100] cannot set channel count to 2 (Invalid argument)
cam: I/O error

Change History (4)

comment:1 by bolvan, 16 months ago

I found workaround for this problem. Use "-channels 1"

comment:2 by Elon Musk, 16 months ago

Resolution: invalid
Status: newclosed

-ac is output option.

see "ffmpeg -h demuxer=alsa"

comment:3 by Cigaes, 15 months ago

Resolution: invalid
Status: closedreopened

The self-documentation says that -ac can be input:

    { "ac",             OPT_AUDIO | HAS_ARG  | OPT_INT | OPT_SPEC |
                        OPT_INPUT | OPT_OUTPUT,                                    { .off = OFFSET(audio_channels) },

The documentations adds its can be relevant for capture devices:

@item -ac[:@var{stream_specifier}] @var{channels} (@emph{input/output,per-stream})
Set the number of audio channels. For output streams it is set by
default to the number of input audio channels. For input streams
this option only makes sense for audio grabbing devices and raw demuxers
and is mapped to the corresponding demuxer options.

If it is no longer mapped to the demuxer options, then we need to check if it is intentional and either fix the code or the documentation.

comment:4 by fred0815, 7 weeks ago

I have the same problem with a USB-Webcam on my Raspberry Pi, which has only one channel as Microphone.
But "-channels 1" does also not work for me.
Any ideas ?

ffmpeg version 5.1.4-0+rpt2+deb12u1 Copyright (c) 2000-2023 the FFmpeg developers

built with gcc 12 (Raspbian 12.2.0-14+rpi1)

Edit: I works by setting the Option first:
/usr/bin/ffmpeg -channels 1 -ac 1 -f alsa -ar 22050 -r 96000 -i hw:U0x46d0x819,0 -acodec mp3 -strict experimental -loglevel info -f video4linux2 -s 640x480 -i /dev/video1 -vframes 1800 -vb 1000000 -vcodec mpeg4 -y out.mp4

Last edited 7 weeks ago by fred0815 (previous) (diff)
Note: See TracTickets for help on using tickets.