我是ices2和icecast2的新手,但确实设法建立了一个流,使我可以在耳塞中听到自己的声音。所以,该系统取得了一些基本的成功。现在,真正的目标:
我们希望使用 Zoom R16 录音机的音频接口功能流式传输 8 种不同的语言。通过arecord --dump-hw-params hw1,0
在 R16 上执行,它返回:
Recording WAVE 'hw1,0' : Unsigned 8 bit, Rate 8000 Hz, Mono
HW Params of device "default":
--------------------
ACCESS: RW_INTERLEAVED
FORMAT: U8 S16_LE S16_BE S24_LE S24_BE S32_LE S32_BE FLOAT_LE FLOAT_BE MU_LAW A_LAW S24_3LE S24_3BE
SUBFORMAT: STD
SAMPLE_BITS: [8 32]
FRAME_BITS: [8 1024]
CHANNELS: [1 32]
RATE: [1 384000]
PERIOD_TIME: (2 4294967295)
PERIOD_SIZE: [1 1398102)
PERIOD_BYTES: [128 1398102)
PERIODS: [3 1024]
BUFFER_TIME: (7 4294967295]
BUFFER_SIZE: [3 4194304]
BUFFER_BYTES: [384 4194304]
TICK_TIME: ALL
--------------------
问题一:之间有空格的数字(例如 )是什么意思SAMPLE_BITS: [8 32]
?这是否意味着样本位可以是 8、16 或 32?
问题2:如何解决“错误输入 alsa/alsa_open_module 示例格式不可用:参数无效”
当我尝试启动ices2时,它就退出了,日志显示:
[2023-12-10 20:48:46] INFO ices-core/main IceS 2.0.3 started...
[2023-12-10 20:48:46] EROR input-alsa/alsa_open_module Sample format not available: Invalid argument
[2023-12-10 20:48:46] EROR input/input_loop Couldn't initialise input module "alsa"
[2023-12-10 20:48:46] INFO ices-core/main Shutdown complete
我用于ices2的配置文件是:
<?xml version="1.0"?>
<ices>
<!-- run in background --> <background>0</background>
<!-- where logs go. --> <logpath>/var/log/ices2</logpath>
<logfile>ices.log</logfile>
<!-- size in kilobytes --> <logsize>2048</logsize>
<!-- 1=error, 2=warn, 3=infoa ,4=debug --> <loglevel>4</loglevel>
<!-- logfile is ignored if this is set to 1 --> <consolelog>0</consolelog>
<!-- optional filename to write process id to --> <pidfile>/var/log/ices2/ices.pid</pidfile>
<stream>
<!-- metadata used for stream listing -->
<metadata>
<name>8 Languages</name>
<genre>Dharma Teaching</genre>
<description>Translation of 2024 International Spring Festival</description>
<url>http://localhost/</url>
</metadata>
<!-- Input module.
This example uses the 'alsa' module. It takes input from the
ALSA audio device (e.g. line-in), and processes it for live
encoding. -->
<input>
<module>alsa</module>
<param name="rate">48000</param>
<param name="channels">8</param>
<param name="device">hw:1,0</param>
<param name="periods">2</param>
<!-- Read metadata (from stdin by default, or -->
<!-- filename defined below (if the latter, only on SIGUSR1) -->
<param name="metadata">1</param>
<param name="metadatafilename">testES</param>
</input>
<!-- Stream instance.
You may have one or more instances here. This allows you to
send the same input data to one or more servers (or to different
mountpoints on the same server). Each of them can have different
parameters. This is primarily useful for a) relaying to multiple
independent servers, and b) encoding/reencoding to multiple
bitrates.
If one instance fails (for example, the associated server goes
down, etc), the others will continue to function correctly.
This example defines a single instance doing live encoding at
low bitrate. -->
<instance>
<!-- Server details.
You define hostname and port for the server here, along
with the source password and mountpoint. -->
<hostname>localhost</hostname>
<port>8000</port>
<password>hackme</password>
<mount>/spanish.ogg</mount>
<yp>1</yp> <!-- allow stream to be advertised on YP, default 0 -->
<!-- Live encoding/reencoding:
channels and samplerate currently MUST match the channels
and samplerate given in the parameters to the alsa input
module above or the remsaple/downmix section below. -->
<encode>
<quality>0</quality>
<samplerate>24000</samplerate>
<channels>8</channels>
</encode>
<!-- stereo->mono downmixing, enabled by setting this to 1 -->
<downmix>0</downmix>
<!-- resampling.
Set to the frequency (in Hz) you wish to resample to, -->
<resample>
<in-rate>48000</in-rate>
<out-rate>24000</out-rate>
</resample>
</instance>
</stream>
</ices>
但总的来说,我想知道的是:
问题3:需要进入配置文件,以便录音机的通道 1 可以作为西班牙语进行流式传输,通道 2 作为法语进行流式传输,通道 3 作为德语进行流式传输,...通道 8。我假设我实际上需要 8 个不同的配置文件并运行8个ices2实例,但如何选择合适的通道?
编辑:我还可以说这适用于录制 8 通道 wav 文件:
arecord -D hw:1,0 -f S32_LE -r 48000 -c 8 testr16.wav
答案1
好的,已经开始工作了,主要包括以下几个关键领域:
- 在 ALSA 级别拆分流
~/.asoundrc
-- 用于dsnoop
拆分
-- 来自一个硬件设备的所有流都需要使用相同的 ipc_key。 - 在ices2配置文件中
--设备是plug:{name from .asoundrc}
--获取正确的通道。我将其设置为 8 个通道,尽管 alsa 现在提供单通道 pcm,但这会导致流式传输时发出刺耳的噪音! - 必须
/etc/icecast2/icecast.xml
增加<sources>8</sources>
这是决赛~/.asoundrc
。请注意,由于所有 dsnoop 通道都来自同一硬件设备,因此它们需要具有相同的ipc_key。否则,一旦您从一个通道开始录制,其余通道将报告为设备正忙。
pcm_slave.r16 { pcm "hw:1,0"; rate 48000; channels 8 }
pcm.ch1 { type dsnoop; ipc_key 3700; slave r16; bindings.0 0; }
pcm.ch2 { type dsnoop; ipc_key 3700; slave r16; bindings.0 1; }
pcm.ch3 { type dsnoop; ipc_key 3700; slave r16; bindings.0 2; }
pcm.ch4 { type dsnoop; ipc_key 3700; slave r16; bindings.0 3; }
pcm.ch5 { type dsnoop; ipc_key 3700; slave r16; bindings.0 4; }
pcm.ch6 { type dsnoop; ipc_key 3700; slave r16; bindings.0 5; }
pcm.ch7 { type dsnoop; ipc_key 3700; slave r16; bindings.0 6; }
pcm.ch8 { type dsnoop; ipc_key 3700; slave r16; bindings.0 7; }
不要忘记重新启动 ALSA:sudo /etc/init.d/alsa-utils restart
然后我制作了8个独立的ices2配置文件,
ices-alsa-r16.1.xml
ices-alsa-r16.2.xml
...
ices-alsa-r16.8.xml
这是配置文件。改变的三件事是设备、挂载和 pid:
设备:plug:ch1
挂载plug:ch8
:ch1.ogg
PID文件ch8.ogg
:r16.1.pid
r16.8.pid
<?xml version="1.0"?>
<ices>
<!-- run in background -->
<background>1</background>
<logpath>/var/log/ices2</logpath>
<logfile>ices.log</logfile>
<logsize>2048</logsize>
<loglevel>4</loglevel>
<consolelog>0</consolelog>
<pidfile>/var/log/ices2/r16.8.pid</pidfile>
<stream>
<metadata>
<name>8 Languages</name>
<genre>Dharma Teaching</genre>
<description>Translation of 2024 International Spring Festival</description>
<url>http://localhost/</url>
</metadata>
<input>
<module>alsa</module>
<param name="rate">48000</param>
<param name="channels">1</param>
<param name="device">plug:ch8</param>
<param name="periods">3</param>
<param name="buffer-time">500</param>
</input>
<instance>
<hostname>localhost</hostname>
<port>8000</port>
<password>hackme</password>
<mount>/ch8.ogg</mount>
<encode>
<quality>0</quality>
<samplerate>24000</samplerate>
<channels>1</channels>
</encode>
<resample>
<in-rate>48000</in-rate>
<out-rate>24000</out-rate>
</resample>
</instance>
</stream>
</ices>
这里有一些很好的信息:
https://alsa.opensrc.org/Asoundrc
https://bootlin.com/blog/audio-multi-channel-routing-and-mixing-using-alsalib/