rafael2k / darkice

DarkIce is a live audio streamer. It records audio from an audio interface (e.g. sound card), encodes it and sends it to a streaming server. This is the official development repository of Darkice.
http://www.darkice.org
200 stars 47 forks source link

Capture 2 usb analog inputs #151

Open kurtwerbrouck opened 4 years ago

kurtwerbrouck commented 4 years ago

Hi

I am trying to capture 2 usb analog audio inputs via darkice and send them to icecast. I have made 1 darkice config with [icecast2-0] setting, then i made a duplicate of that file and adjusted the mount name in the [icecast2-0] session. When running each config file seperate, it seems to be working, if i run the both config files at the same time, i got and hardware error. Is there an example that i can base my config on?

Kurt

DanielEckl commented 4 years ago

If you really only changed the mountpoint between the config files, then this would mean your input is the same in both files. In case your input is some sound server like jack or pulseaudio, this might be fine, but if it's the alsa hardware directly, then you will have two darkice processes wanting to connect to the same hardware and only the first wins.

kurtwerbrouck commented 4 years ago

One has hwplug:1.0, the other has hwplug:2.0. If the mountpoint has a different name and the port remains 8000, then this should be running? I will try again this weekend. As project we want to capture 4 analog stereo signal and transform them into 4 webradio stream coming from icecast.

DanielEckl commented 4 years ago

For hwplug the separation of device and subdevice is comma, not dot. Please check if you just mistyped here in the comment or also in the config file. This aside, these two input definitions should not cause hw blocking and this should work.

If that doesn't lead to a solution, you might also show us your complete config (redact any passwords and maybe hostnames) and your complete darkice command line and output

kurtwerbrouck commented 4 years ago

config nr 1

[general] duration = 0 # duration in s, 0 forever bufferSecs = 1 # buffer, in seconds reconnect = yes # reconnect if disconnected [input] device = plughw:1,0 # Soundcard device for the audio input sampleRate = 44100 # sample rate 11025, 22050 or 44100 bitsPerSample = 16 # bits channel = 1 # 2 = stereo

[icecast2-0] bitrateMode = cbr # constant bit rate ('cbr' constant, 'abr' average)

quality = 1.0 # 1.0 is best quality (use only with vbr)

format = mp3 # format. Choose 'vorbis' for OGG Vorbis bitrate = 320 # bitrate server = localhost # or IP port = 8000 # port for IceCast2 access password = hackme # source password for the IceCast2 server mountPoint = rapi.mp3 # mount point on the IceCast2 server .mp3 or .ogg name = Raspberry Pi

Config 2

[general] duration = 0 # duration in s, 0 forever bufferSecs = 1 # buffer, in seconds reconnect = yes # reconnect if disconnected

[input] device = plughw:2,0 # Soundcard device for the audio input sampleRate = 44100 # sample rate 11025, 22050 or 44100 bitsPerSample = 16 # bits channel = 1 # 2 = stereo

[icecast2-0] bitrateMode = cbr # constant bit rate ('cbr' constant, 'abr' average)

quality = 1.0 # 1.0 is best quality (use only with vbr)

format = mp3 # format. Choose 'vorbis' for OGG Vorbis bitrate = 320 # bitrate server = localhost # or IP port = 8000 # port for IceCast2 access password = hackme # source password for the IceCast2 server mountPoint = rapi2.mp3 # mount point on the IceCast2 server .mp3 or .ogg name = Raspberry Pi2

i test this first with the next 2 commands

/usr/bin/darkice -v9 -c /home/pi/darkice.cfg & /usr/bin/darkice -v9 -c /home/pi/darkice2.cfg &

replay from second command Using config file: /home/pi/darkice2.cfg 06-Jan-2020 22:06:38 Using ALSA DSP input device: plughw:2,0 06-Jan-2020 22:06:38 encoding 06-Jan-2020 22:06:38 scheduler high priority 99 06-Jan-2020 22:06:38 Could not set POSIX real-time scheduling, this may cause recording skips. Try to run darkice as the super-user. DarkIce: AlsaDspSource.cpp:195: can't set hardware parameters [0]

it was a type error into this forum, not in the config files

kurtwerbrouck commented 4 years ago

could it be that the raspberry pi4 usb bus cant handle 2 usb cards?

DanielEckl commented 4 years ago

"can't set hardware parameters" is a weird error message here. If it would be reproducible all the time I'd say your sound card has some min/max limitations in channels and/or sample rate and you exceeded it. But I understood you that way that each command works when started alone.

I'd lower the sample rate anyway and switch mono/stereo mode forth and back just for try and error.

And you could try to rule out darkice as the culprit. Use two "arecord" processes and try to record from both devices at the same time. If that fails, too, then it's alsa and/or the raspi or your soundcards.

kurtwerbrouck commented 4 years ago

Today i tried it an a rpi3+b , this was succesfull. Got both darkice captures running. I used darksnow to make both config filed. Still have to check the sound quality. I will try again on a rpi4 with the same configs.

kurtwerbrouck commented 4 years ago

we are back, i tried the exact same configs on a rpi4, both capture working perfect alone, but running bith capture on the same time , it doesnt work. seems that the issue is only present on a raspberry 4. does the rpi4 handle the usb bus in a different way?

kurtwerbrouck commented 4 years ago

I compiled darkice 1.4 with lame and alsa support. I can run two darkice config on the same time on a odroid c2- a rpi4 refuses to do so..

kurtwerbrouck commented 4 years ago

on the odroid -c2 the audio is distorted.... so also not a solution.

kurtwerbrouck commented 4 years ago

hello

Today i was succesfull of running 3 darkice capture towards icecast. I also installed qjackctl and run before each startup of darkice session an alsa_out -d hw:x (x = card number) command.

Why it works, i have no idee.

When starting the 4 darkice capture, it send me an error after 10 sec:

DarkIce: AlsaDspSource.cpp:265: Input/output error [0]