iizukanao / picam

Audio/video recorder for Raspberry Pi with language agnostic API
GNU Lesser General Public License v2.1
494 stars 78 forks source link

4 channel microphone #113

Open iizukanao opened 6 years ago

iizukanao commented 6 years ago

picam should support 4 channel microphone. requested by @leomen3 Previous discussion: https://github.com/iizukanao/picam-streamer/issues/9

iizukanao commented 6 years ago

@leomen3 I have created a test version which accepts -c 4. Can you give it a try? https://github.com/iizukanao/picam/releases/tag/v1.4.7-dev-4ch

TomUser1 commented 6 years ago

Thanks For Your Attention iizukanao, Results: $./picam --alsadev hw:1,0 -c 4 configuring devices error: cannot set sample format (Invalid argument).

4 channel microphone (http://wiki.seeedstudio.com/ReSpeaker_4_Mic_Array_for_Raspberry_Pi/) by default works on S32_LE simple format, but picam support only S16_LE. Also picam have no parameter for change audio simple format. Сould you add support of this format? Or maybe do you know how to change default format from S32_LE to S16_LE for mic.

Thanks.

spicemint commented 6 years ago

I'm using pi3 with ps3 eyetoy usb camera, has 4 chan mic. I get some more output:

pi@raspberrypi:~/picam-1.4.7-4ch-binary $ ./picam --alsadev hw:1,0 -c 4 created state dir: ./state created hooks dir: ./hooks created directory: ./rec created directory: ./rec/tmp created directory: ./rec/archive configuring devices error: failed to set sample rate for microphone to 48000 (got 16000)

Damel91 commented 6 years ago

Thanks For Your Attention iizukanao, Results: $./picam --alsadev hw:1,0 -c 4 configuring devices error: cannot set sample format (Invalid argument).

4 channel microphone (http://wiki.seeedstudio.com/ReSpeaker_4_Mic_Array_for_Raspberry_Pi/) by default works on S32_LE simple format, but picam support only S16_LE. Also picam have no parameter for change audio simple format. Сould you add support of this format? Or maybe do you know how to change default format from S32_LE to S16_LE for mic.

Thanks.

I have adafruit microphones too, but I'm using them stereo, now the thing is that the standard adafruit asoundrc configuration is not compatible with streaming because it uses S32_LE format by default, so you need to use alsa plug-in in order to have a linear conversion, in this way the alsa module will adapt automatically to the need of the stream. Anyway, this is my asoundrc configuration file

NOTE: Take care of two things, first, the mono configuration will result into audio non synched, two, this issue doesn't mean anything with picam sofware itself:

pcm_slave.sl2 { pcm "plughw:1,0" format S32_LE rate 48000 }

pcm.!default { type rate slave sl2 }

ctl:!default { type rate slave sl2 }

Now your device will be "default", also think about that the virtual soundcard module for the i2s microphones create an overhead, so this is the reason because I'm not using something that can me let adjust the volume, I suggest to you to use picam command instead.

rajeshkrarora1 commented 6 years ago

after configuring .asoundrc, before you can change the volume you need to use the device once (this is an alsa thing), so run "arecord -D dmic_sv -c2 -r 44100 -f S32_LE -t wav -V mono -v file.wav", And cancel with ^C once it starts recording Now you can run alsamixer - press F6 and select the I2S simple sound card ,

It will complain there are no playback controls (because its for recording only). Press F5 to change the volume.

On Fri, Nov 2, 2018 at 2:01 PM Dave4675 notifications@github.com wrote:

Thanks For Your Attention iizukanao, Results: $./picam --alsadev hw:1,0 -c 4 configuring devices error: cannot set sample format (Invalid argument).

4 channel microphone ( http://wiki.seeedstudio.com/ReSpeaker_4_Mic_Array_for_Raspberry_Pi/) by default works on S32_LE simple format, but picam support only S16_LE. Also picam have no parameter for change audio simple format. Сould you add support of this format? Or maybe do you know how to change default format from S32_LE to S16_LE for mic.

Thanks.

I have adafruit microphones too, but I'm using them stereo, now the thing is that the standard adafruit asoundrc configuration is not compatible with streaming because it uses S32_LE format by default, so you need to use alsa plug-in in order to have a linear conversion, in this way the alsa module will adapt automatically to the need of the stream. Anyway, this is my asoundrc configuration file

NOTE: Take care of two things, first, the mono configuration will result into audio non synched, two, this issue doesn't mean anything with picam sofware itself:

pcm_slave.sl2 { pcm "plughw:1,0" format S32_LE rate 48000 }

pcm.!default { type rate slave sl2 }

ctl:!default { type rate slave sl2 }

Now your device will be "default", also think about that the virtual soundcard module for the i2s microphones create an overhead, so this is the reason because I'm not using something that can me let adjust the volume, I suggest to you to use picam command instead.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/iizukanao/picam/issues/113#issuecomment-435306759, or mute the thread https://github.com/notifications/unsubscribe-auth/Ako7-sm0VBQboXiaCh83E-hDs1BksSBXks5urALFgaJpZM4W1Vnt .

iizukanao commented 6 years ago

I will buy ReSpeaker 4-Mic Array and look into this issue.

rajeshkrarora1 commented 6 years ago

sorry i am on wrong thread, because, the .asoundrc configuration and about using soft volume control i have mentioned is in case of adafruit i2s mems mic SPH0645 and not in case of SAEEED'S 4-mic array

On Mon, Nov 5, 2018 at 10:57 AM Nao Iizuka notifications@github.com wrote:

I will buy ReSpeaker 4-Mic Array and look into this issue.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/iizukanao/picam/issues/113#issuecomment-435759139, or mute the thread https://github.com/notifications/unsubscribe-auth/Ako7-m6FctHcvxzqLBm0vBT8FmwvjCqDks5ur8wsgaJpZM4W1Vnt .

maeffew commented 5 years ago

Has anyone had any further success with using the respecter mic here?

mrceresa commented 4 years ago

Hi: I'm also interested in knowing the current status of this. Thanks!

inseltraeumer commented 4 years ago

Picam works with the 4 channel microphone mentioned above (the one by seeed) for me with the following commands after following the setup guide on https://wiki.seeedstudio.com/ReSpeaker_4_Mic_Array_for_Raspberry_Pi/.

Note that you''ll have to define the $parameters (and I also pass my Youtube streaming key to the script as its first parameter). It doesn't work with more than two audio channels, though.

Besides, I'm getting a microphone buffer overrun error after 3-5 hours of streaming when using two channels. I would really appreciate some help with that one. I guess it's because of the audio bitrate being too high, but that buffer overflow error doesn't make much sense to me. Can the buffer size somehow be increased? Ideally, Picam should lower the audio bitrate as needed by itself. Thanks!

FFREPORT=file="ffreport-$(date).log":level=32 /home/pi/ffmpeg/ffmpeg \
  -re \
  -i tcp:127.0.0.1:8181?listen \
  -filter:a aresample=async=1000 \
  -c:a aac \
  -c:v copy \
  -f flv rtmp://a.rtmp.youtube.com/live2/$1 &

./picam \
  --alsadev plughw:1,0 \
   -c $audio_channels \
   -r $audio_framerate \
   -a $audio_bitrate \
  --time \
  --timeformat "$timeformat" \
  --hflip \
  --vflip \
   -w $vwidth \
   -h $vheight \
  --ex $exposure \
  --tcpout tcp://127.0.0.1:8181

touch hooks/start_record
harryjubb commented 4 years ago

@inseltraeumer Thank you for your reply, also using the ReSpeaker 4 Mic Array and have had success setting -c 1.

The key part for us was also setting --alsadev plughw:1,0 rather than --alsadev hw:1,0.

~Have not yet tried a long stream so haven't seen any buffer overrun issues, but will reply again if we can reproduce this.~

Have managed to reproduce the buffer overrun quite quickly! Presumably related to #34? Any thoughts or advice on this would be appreciated.

Running with:

./picam --alsadev $ALSA_DEVICE -c $AUDIO_CHANNELS --tcpout tcp://ffmpeg:8181

Where

ALSA_DEVICE=plughw:1,0
AUDIO_CHANNELS=1

With ffmpeg running in a Dockerised service.

inseltraeumer commented 3 years ago

@inseltraeumer Thank you for your reply, also using the ReSpeaker 4 Mic Array and have had success setting -c 1.

The key part for us was also setting --alsadev plughw:1,0 rather than --alsadev hw:1,0.

~Have not yet tried a long stream so haven't seen any buffer overrun issues, but will reply again if we can reproduce this.~

Have managed to reproduce the buffer overrun quite quickly! Presumably related to #34? Any thoughts or advice on this would be appreciated.

Running with:

./picam --alsadev $ALSA_DEVICE -c $AUDIO_CHANNELS --tcpout tcp://ffmpeg:8181

Where


ALSA_DEVICE=plughw:1,0

AUDIO_CHANNELS=1

With ffmpeg running in a Dockerised service.

I managed to circumvent this by doing something like:

while true; do
  if ! pgrep ffmpeg > /dev/null ; then
    # kill picam and ffmpeg processes
    sleep 13
    # start processes again
  fi
  sleep 2
done
hanskenb commented 3 years ago

Dear All,

i'm getting the following: "cannot open audio capture device 'plughw:1,0': No such file or directory".

arecord -l results in


card 2: seeed4micvoicec [seeed-4mic-voicecard], device 0: bcm2835-i2s-ac10x-codec0 ac10x-codec.1-003b-0 [bcm2835-i2s-ac10x-codec0 ac10x-codec.1-003b-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Any idea?

Edit of course i needed to set: plughw:2,0. :-|