Icecast Darkice issues

Creating a bug report/issue

I have searched the existing open and closed issues

Required Information

  • _DIETPI_VERSION_CORE=9
  • G_DIETPI_VERSION_SUB=1
  • G_DIETPI_VERSION_RC=1
  • G_GITBRANCH=‘master’
  • G_GITOWNER=‘MichaIng’
  • G_LIVE_PATCH_STATUS[0]=‘not applicable’
  • Distro version | bookworm 0

  • Kernel version | Linux 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux

  • Architecture | arm64

  • SBC model | RPi Zero 2 W

  • Power supply used | Official Raspberry Pi Micro USB

  • SD card used | 16GB SanDisk Ultra

Additional Information

  • Software title | Icecast - Darkice
  • Fresh install of Dietpi

Steps to reproduce

  • Plug in USB Microphone into Raspberry Pi Zero 2 (card 0: GoMic [Samson GoMic], device 0: USB Audio [USB Audio])
  • Installed Icecast/Darkice
  • As per the Dietpi Docs instructions, edited darkice.cfg with the command:
    sed -i "/^device[[:blank:]]/c\device = hw:$(arecord -l | mawk -F'[ :]' '/card/{print $2;exit}'),0" /etc/darkice.cfg
  • Check the server url http://<IP>:8000

Expected behaviour

Access to playback for the audio provided by Darkice (of the USB Mic)

Actual behaviour

systemctl status darkice
× darkice.service - DarkIce (DietPi)
     Loaded: loaded (/etc/systemd/system/darkice.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Wed 2024-03-06 19:01:59 GMT; 17s ago
   Duration: 204ms
    Process: 1091 ExecStart=/usr/bin/darkice (code=exited, status=255/EXCEPTION)
   Main PID: 1091 (code=exited, status=255/EXCEPTION)
        CPU: 64ms

Mar 06 19:01:59 ZERO2CAM01 darkice[1091]: DarkIce 1.3 live audio streamer, http://code.google.com/p/darkice/
Mar 06 19:01:59 ZERO2CAM01 darkice[1091]: Copyright (c) 2000-2007, Tyrell Hungary, http://tyrell.hu/
Mar 06 19:01:59 ZERO2CAM01 darkice[1091]: Copyright (c) 2008-2013, Akos Maroy and Rafael Diniz
Mar 06 19:01:59 ZERO2CAM01 darkice[1091]: This is free software, and you are welcome to redistribute it
Mar 06 19:01:59 ZERO2CAM01 darkice[1091]: under the terms of The GNU General Public License version 3 or
Mar 06 19:01:59 ZERO2CAM01 darkice[1091]: any later version.
Mar 06 19:01:59 ZERO2CAM01 darkice[1091]: Using config file: /etc/darkice.cfg
Mar 06 19:01:59 ZERO2CAM01 darkice[1091]: DarkIce: DarkIce.cpp:155: no section [general] in config [0]
Mar 06 19:01:59 ZERO2CAM01 systemd[1]: darkice.service: Main process exited, code=exited, status=255/EXCEPTION
Mar 06 19:01:59 ZERO2CAM01 systemd[1]: darkice.service: Failed with result 'exit-code'.

Any help would be much appreciated.

Looks like configuration issues

Hi Joulinar, thanks for having a look. I’m confused regarding the config, as apart from [icecast2-0] changes which I copied from another guide, the [general] section is left as it was at installation:

[general]
duration      = 0
bufferSecs    = 5
reconnect     = yes

[input]
device = hw:0,0
sampleRate    = 22050
bitsPerSample = 16
channel       = 1

[icecast2-0]
bitrateMode   = abr
format        = mp3
quality       = 192
server        = localhost
port          = 8000
password      = dietpi
mountPoint    = stream.mp3
name          = DietPi
description   = DarkIce on DietPi
url           = http://localhost
genre         = none
public        = no
#localDumpFile = /mnt/dietpi_userdata/darkice_recording.ogg

Do you see anything that might be wrong here? Thanks again for any help.
These are all efforts to make a babymonitor with a usb microphone and a raspi camera. So far it’s proving trickier than I thought!


Edit: Just to be sure, I uninstalled Icecast - Darkice and reinstalled with the default configs. Once again, I edited darkice.cfg with the command:
sed -i "/^device[[:blank:]]/c\device = hw:$(arecord -l | mawk -F'[ :]' '/card/{print $2;exit}'),0" /etc/darkice.cfg

I also edited icecast.xml to change the hostname to the pi’s address.

Aside from these necessary edits, the configs are left as default. I still get the same error message:

systemctl status darkice
× darkice.service - DarkIce (DietPi)
     Loaded: loaded (/etc/systemd/system/darkice.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Thu 2024-03-07 11:04:14 GMT; 1min 30s ago
   Duration: 82ms
    Process: 1917 ExecStart=/usr/bin/darkice (code=exited, status=255/EXCEPTION)
   Main PID: 1917 (code=exited, status=255/EXCEPTION)
        CPU: 55ms

Mar 07 11:04:14 ZERO2CAM01 darkice[1917]: DarkIce 1.3 live audio streamer, http://code.google.com/p/darkice/
Mar 07 11:04:14 ZERO2CAM01 darkice[1917]: Copyright (c) 2000-2007, Tyrell Hungary, http://tyrell.hu/
Mar 07 11:04:14 ZERO2CAM01 darkice[1917]: Copyright (c) 2008-2013, Akos Maroy and Rafael Diniz
Mar 07 11:04:14 ZERO2CAM01 darkice[1917]: This is free software, and you are welcome to redistribute it
Mar 07 11:04:14 ZERO2CAM01 darkice[1917]: under the terms of The GNU General Public License version 3 or
Mar 07 11:04:14 ZERO2CAM01 darkice[1917]: any later version.
Mar 07 11:04:14 ZERO2CAM01 darkice[1917]: Using config file: /etc/darkice.cfg
Mar 07 11:04:14 ZERO2CAM01 darkice[1917]: DarkIce: DarkIce.cpp:155: no section [general] in config [0]
Mar 07 11:04:14 ZERO2CAM01 systemd[1]: darkice.service: Main process exited, code=exited, status=255/EXCEPTION
Mar 07 11:04:14 ZERO2CAM01 systemd[1]: darkice.service: Failed with result 'exit-code'.

Additionally, the Icecast page looks the same as before, blank.
Any help would be appreciated!

The problem is that icecast does not find the [general] block in you cfg file.
can you try

darkice -c /etc/darkice.cfg

Hi Jappe, thanks for your assistance.
Here’s the output - doesn’t seem in any way out of the ordinary to me, except for the channels? I didn’t edit anything regarding channels, so is this more to do with the hardware, rather than config?

darkice -c /etc/darkice.cfg
DarkIce 1.3 live audio streamer, http://code.google.com/p/darkice/
Copyright (c) 2000-2007, Tyrell Hungary, http://tyrell.hu/
Copyright (c) 2008-2013, Akos Maroy and Rafael Diniz
This is free software, and you are welcome to redistribute it 
under the terms of The GNU General Public License version 3 or
any later version.

Using config file: /etc/darkice.cfg
Using ALSA DSP input device: hw:0,0
Using POSIX real-time scheduling, priority 4
DarkIce: AlsaDspSource.cpp:173: can't set channels [1]

It’s interesting that it can read the cfg file when you start it manually, but when started from the service it can not read it (I assume it’s not readable bc it says it can’t find the [general] block, which is clearly there.)
Did you start it as the user root?

The error DarkIce: AlsaDspSource.cpp:173: can't set channels [1] indicates that something is off with the config for the input. [1] should be correct, since the mic is mono. But maybe the sample rate is not correct.
Can you show cat /etc/darkice.cfg.

Hey Jappe
This is a fresh install from yesterday; I am running as user root.
I tried both 22050 and 44100 for the sample rate; Darkice still has the same error.

Here’s the current /etc/darkice.cfg

[general]
duration      = 0
bufferSecs    = 3
reconnect     = yes

[input]
device = hw:0,0
sampleRate    = 44100
bitsPerSample = 16
channel       = 1

[icecast2-0]
bitrateMode   = vbr
format        = vorbis
quality       = 0.8
server        = localhost
port          = 8000
password      = dietpi
mountPoint    = DietPi
name          = DietPi
description   = DarkIce on DietPi
url           = http://localhost
genre         = none
public        = no
#localDumpFile = /mnt/dietpi_userdata/darkice_recording.ogg

Edit: I don’t know if this is of any consequence: the Raspberry Pi is also running MotionEye, using a Raspberry Pi Camera. The camera obviously doesn’t provide any audio, so I don’t think it’s interfering.
Ultimately, I’d like to make a baby monitor that uses MotionEye for visual input, and DarkIce for audio input. I thought this would be easy… hubris! Thanks again Jappe.

We had a look why config is not accepted. At least for the config file, the issue is within the service configuration

[Service]
User=nobody
Group=dietpi
ExecStart=/usr/bin/darkice

User nobody is not able to read /etc/darkice.cfg as this one has r/w permission on user root only

-rw------- 1 root root 518 Mar  7 21:17 /etc/darkice.cfg

As a workaround, you could adjust permissions on /etc/darkice.cfg

chown root:dietpi /etc/darkice.cfg
chmod 640 /etc/darkice.cfg
systemctl restart darkice.service

But the service might need more tweaks to be able to access audio device. We will check.

2 Likes

Hey Joulinar. Thanks for investigating this! I made the changes to the permissions, but I’m still getting a blank Icecast page. Do any of these status reports mean anything?

root@ZERO2CAM01:~# arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: GoMic [Samson GoMic], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
root@ZERO2CAM01:~# dietpi-services
icecast2.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install is-enabled icecast2
root@ZERO2CAM01:~# systemctl status darkice
× darkice.service - DarkIce (DietPi)
     Loaded: loaded (/etc/systemd/system/darkice.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Sat 2024-03-09 17:04:30 GMT; 2min 44s ago
   Duration: 69ms
    Process: 3131 ExecStart=/usr/bin/darkice (code=exited, status=255/EXCEPTION)
   Main PID: 3131 (code=exited, status=255/EXCEPTION)
        CPU: 55ms

Mar 09 17:04:30 ZERO2CAM01 darkice[3131]: under the terms of The GNU General Public License version 3 or
Mar 09 17:04:30 ZERO2CAM01 darkice[3131]: any later version.
Mar 09 17:04:30 ZERO2CAM01 darkice[3131]: Using config file: /etc/darkice.cfg
Mar 09 17:04:30 ZERO2CAM01 darkice[3131]: Using ALSA DSP input device: hw:0,0
Mar 09 17:04:30 ZERO2CAM01 darkice[3131]: Could not set POSIX real-time scheduling, this may cause recording skips.
Mar 09 17:04:30 ZERO2CAM01 darkice[3131]: Try to run darkice as the super-user.
Mar 09 17:04:30 ZERO2CAM01 darkice[3131]: ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for 0
Mar 09 17:04:30 ZERO2CAM01 darkice[3131]: DarkIce: DarkIce.cpp:1273: can't open connector [0]
Mar 09 17:04:30 ZERO2CAM01 systemd[1]: darkice.service: Main process exited, code=exited, status=255/EXCEPTION
Mar 09 17:04:30 ZERO2CAM01 systemd[1]: darkice.service: Failed with result 'exit-code'.
root@ZERO2CAM01:~# 

As said, there are more challenges with the service. Because user nobody is not able to access the audio interface. There you still have

To work around, you could try to run the service as root user.

1 Like

Hey Joulinar.
I edited /etc/systemd/system/darkice.service.d/dietpi-services_edit.conf so that #User=root

[Unit]
#Description=DarkIce (DietPi)
#Requires=icecast2.service
#After=icecast2.service

[Service]
#User=root
#Group=dietpi
#ExecStart=/usr/bin/darkice

[Install]
#WantedBy=multi-user.target

Unfortunately, errors are still being thrown up:

systemctl status darkice
× darkice.service - DarkIce (DietPi)
     Loaded: loaded (/etc/systemd/system/darkice.service; enabled; preset: enabled)
    Drop-In: /etc/systemd/system/darkice.service.d
             └─dietpi-services_edit.conf
     Active: failed (Result: exit-code) since Sat 2024-03-09 17:10:10 GMT; 1 day 6h ago
   Duration: 433ms
   Main PID: 417 (code=exited, status=255/EXCEPTION)
        CPU: 100ms

Mar 09 17:10:10 ZERO2CAM01 darkice[417]: Using config file: /etc/darkice.cfg
Mar 09 17:10:10 ZERO2CAM01 darkice[417]: Using ALSA DSP input device: hw:0,0
Mar 09 17:10:10 ZERO2CAM01 darkice[417]: Could not set POSIX real-time scheduling, this may cause recording skips.
Mar 09 17:10:10 ZERO2CAM01 darkice[417]: Try to run darkice as the super-user.
Mar 09 17:10:10 ZERO2CAM01 darkice[417]: ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for 0
Mar 09 17:10:10 ZERO2CAM01 darkice[417]: DarkIce: DarkIce.cpp:1273: can't open connector [0]
Mar 09 17:10:10 ZERO2CAM01 systemd[1]: darkice.service: Main process exited, code=exited, status=255/EXCEPTION
Mar 09 17:10:10 ZERO2CAM01 systemd[1]: darkice.service: Failed with result 'exit-code'.
Mar 10 23:07:50 ZERO2CAM01 systemd[1]: [🡕] /etc/systemd/system/darkice.service:7: Special user nobody configured, this is not safe!
Mar 10 23:11:15 ZERO2CAM01 systemd[1]: [🡕] /etc/systemd/system/darkice.service:7: Special user nobody configured, this is not safe!

Everything starting with # is commented out and ignored, you would need to remove it.
But maybe you can test the latest beta release, the issue should be solved there.

Hey Jappe
I completely failed to notice it was all #commented out - how silly of me, apologies.
I switched to the beta channel, updated to 9.2.0 - purged icecast/darkice, reinstalled.
I’m getting what I think is a new error:

root@ZERO2CAM01:~# arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: GoMic [Samson GoMic], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
root@ZERO2CAM01:~# sed -i "/^device[[:blank:]]/c\device = hw:$(arecord -l | mawk -F'[ :]' '/card/{print $2;exit}'),0" /etc/darkice.cfg
root@ZERO2CAM01:~# systemctl restart darkice
root@ZERO2CAM01:~# systemctl status darkice
× darkice.service - DarkIce (DietPi)
     Loaded: loaded (/etc/systemd/system/darkice.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Mon 2024-03-11 10:42:40 GMT; 6s ago
   Duration: 139ms
    Process: 1947 ExecStart=/usr/bin/darkice (code=exited, status=255/EXCEPTION)
   Main PID: 1947 (code=exited, status=255/EXCEPTION)
        CPU: 71ms

Mar 11 10:42:40 ZERO2CAM01 darkice[1947]: Copyright (c) 2008-2013, Akos Maroy and Rafael Diniz
Mar 11 10:42:40 ZERO2CAM01 darkice[1947]: This is free software, and you are welcome to redistribute it
Mar 11 10:42:40 ZERO2CAM01 darkice[1947]: under the terms of The GNU General Public License version 3 or
Mar 11 10:42:40 ZERO2CAM01 darkice[1947]: any later version.
Mar 11 10:42:40 ZERO2CAM01 darkice[1947]: Using config file: /etc/darkice.cfg
Mar 11 10:42:40 ZERO2CAM01 darkice[1947]: Using ALSA DSP input device: hw:0,0
Mar 11 10:42:40 ZERO2CAM01 darkice[1947]: Using POSIX real-time scheduling, priority 4
Mar 11 10:42:40 ZERO2CAM01 darkice[1947]: DarkIce: AlsaDspSource.cpp:173: can't set channels [1]
Mar 11 10:42:40 ZERO2CAM01 systemd[1]: darkice.service: Main process exited, code=exited, status=255/EXCEPTION
Mar 11 10:42:40 ZERO2CAM01 systemd[1]: darkice.service: Failed with result 'exit-code'.

I tried this solution, by changing the bitrate, but I get the same error as above.

I then changed the number of channels, and I don’t get the error. I will investigate further now.

Success! Updating in the beta channel and then changing the channels within /etc/darkice.cfg has resulted in a populated Icecast page.

In the future, is there any way to add fetching the number of channels required using the command sed -i "/^device[[:blank:]]/c\device = hw:$(arecord -l | mawk -F'[ :]' '/card/{print $2;exit}'),0" /etc/darkice.cfg

Thanks so much for all your help! I now just need to see if I can help MichaIng with getting Mjpg-Streamer running haha.

1 Like

something we are thinking about already

2 Likes