我是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
--------------------
问题1:中间有空格的数字是什么意思SAMPLE_BITS: [8 32]
?这是否意味着样本位可以是 8、16 或 32?
问题2:如何解决“EROR input-alsa/alsa_open_module Sample format not available: Invalid argument”
当我尝试启动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 个不同的配置文件并运行ices2的8个实例,但如何选择正确的通道?
编辑:我还可以说这适用于录制 8 通道 wav 文件:
arecord -D hw:1,0 -f S32_LE -r 48000 -c 8 testr16.wav
好的,已经开始工作了,主要有以下几个关键领域:
~/.asoundrc
-- 用于
dsnoop
拆分-- 来自一个硬件设备的所有流都需要使用相同的 ipc_key。
--设备是
plug:{name from .asoundrc}
--获取正确的通道。我将其设置为 8 个通道,尽管 alsa 现在提供单通道 pcm,但这会导致流式传输时发出刺耳的噪音!
/etc/icecast2/icecast.xml
增加<sources>8</sources>
这是决赛
~/.asoundrc
。请注意,由于所有 dsnoop 通道都来自同一硬件设备,因此它们需要具有相同的ipc_key。否则,一旦您从一个通道开始录制,其余通道就会报告为“设备正忙”。不要忘记重新启动 ALSA:
sudo /etc/init.d/alsa-utils restart
然后我制作了8个独立的ices2配置文件,
这是配置文件。改变的三件事是设备、挂载和 pid:
设备:
plug:ch1
挂载plug:ch8
: PID 文件:
ch1.ogg
到ch8.ogg
r16.1.pid
r16.8.pid
这里有一些很好的信息:
https://alsa.opensrc.org/Asoundrc https://bootlin.com/blog/audio-multi-channel-routing-and-mixing-using-alsalib/