找回密码
 立即注册
查看: 256|回复: 3

[技术讨论] armbian 配置为 Airplay 和 DLNA 音频服务器

[复制链接]

14

主题

74

回帖

625

积分

高级会员

积分
625
金钱
537
HASS币
0
发表于 2025-5-19 13:33:23 | 显示全部楼层 |阅读模式
本帖最后由 羽先生 于 2025-5-19 13:43 编辑

我用的是 debian 12 发行版:

Airplay

编译安装 nqptp

git clone https://github.com/mikebrady/nqptp.git
cd nqptp
autoreconf -fi
./configure --with-systemd-startup
make
sudo make install

编译安装 alac

git clone https://github.com/mikebrady/alac.git
cd alac
autoreconf -fi
./configure
make
sudo make install
sudo ldconfig

编译安装 shairport-sync

sudo apt install --no-install-recommends build-essential git autoconf automake libtool libpopt-dev libconfig-dev libasound2-dev avahi-daemon libavahi-client-dev libssl-dev libsoxr-dev libplist-dev libsodium-dev libavutil-dev libavcodec-dev libavformat-dev uuid-dev libgcrypt-dev libmosquitto-dev xxd

git clone https://github.com/mikebrady/shairport-sync.git
cd shairport-sync
autoreconf -fi
./configure --sysconfdir=/etc --with-alsa --with-soxr --with-apple-alac --with-metadata --with-mqtt-client --with-avahi --with-ssl=openssl --with-systemd --with-airplay-2
make
sudo make install

启用服务

修改 /etc/shairport-sync.conf 来配置服务器

sudo systemctl daemon-reload
sudo systemctl enable nqptp
sudo systemctl start nqptp
sudo systemctl enable shairport-sync
sudo systemctl start shairport-sync

DLNA

编译安装 gmrender-resurrect

sudo apt install --no-install-recommends build-essential autoconf automake libtool pkg-config  libupnp-dev libgstreamer1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-alsa git
git clone https://github.com/hzeller/gmrender-resurrect.git

目前主线有 bug ,无法将渲染器名设置为中文,我们引入这个 pr 解决这个问题:

cd gmrender-resurrect
git fetch origin pull/284/head:pr-284
git checkout pr-284

继续编译:

./autogen.sh
./configure
make
sudo make install

配置服务

编写 /usr/lib/systemd/system/gmrender-resurrect.service 内容如下:

[Unit]
Description=gmrender-resurrect service
After=network-online.target sound.target
Requires=network-online.target sound.target

[Service]
EnvironmentFile=/etc/default/gmrender
ExecStart=/usr/local/bin/gmediarender -f "$UPNP_DEVICE_NAME" -u "$UPNP_UUID" \
    --gstout-audiosink=alsasink --gstout-audiodevice "$AUDIO_DEVICE" \
    --logfile=/tmp/gmediarenderer.log --gstout-initial-volume-db=-10
Restart=always

[Install]
WantedBy=multi-user.target

执行如下命令生成配置文件

sudo tee /etc/default/gmrender <<EOF
UPNP_UUID=$(ip link show | awk '/ether/ {print "salt-" $2}' | head -1 | md5sum | awk '{print $1}')
UPNP_DEVICE_NAME="MyMediaRenderer"
AUDIO_DEVICE="sysdefault"
EOF

启用服务

sudo systemctl daemon-reload
sudo systemctl enable gmrender-resurrect.service
sudo systemctl start gmrender-resurrect.service

评分

参与人数 1金钱 +12 收起 理由
隔壁的王叔叔 + 12

查看全部评分

回复

使用道具 举报

6

主题

95

回帖

828

积分

高级会员

积分
828
金钱
727
HASS币
0
发表于 3 小时前 | 显示全部楼层
很实用的帖子,另请问AirPlay/DLNA服务是否会独占音频输出设备?(即:Airplay播放时,启动Dlna,可以正常播放吗?)
回复

使用道具 举报

42

主题

496

回帖

3156

积分

论坛元老

积分
3156
金钱
2618
HASS币
10
发表于 3 小时前 | 显示全部楼层
wh1tequartz 发表于 2025-6-3 11:26
很实用的帖子,另请问AirPlay/DLNA服务是否会独占音频输出设备?(即:Airplay播放时,启动Dlna,可以正常 ...

我手里三台垃圾盒子和一台树莓派3B都是同时安装了这两个服务,只有树莓派可以两个同时用,其他垃圾盒子不行,airplay播放后就无法dlna了,原因未知,我也搞不定。
回复

使用道具 举报

14

主题

74

回帖

625

积分

高级会员

积分
625
金钱
537
HASS币
0
 楼主| 发表于 1 小时前 | 显示全部楼层
wh1tequartz 发表于 2025-6-3 11:26
很实用的帖子,另请问AirPlay/DLNA服务是否会独占音频输出设备?(即:Airplay播放时,启动Dlna,可以正常 ...

我最近在搞的,用PA而不是alsa,就能做到各个服务都能使用音频输出设备(同时出声)
我又加入了蓝牙,可以做到手机蓝牙连接到盒子之后自动切换播放手机声音(此时 dlna 和 airplay 就没声了)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian ( 晋ICP备17001384号-1 )

GMT+8, 2025-6-3 15:13 , Processed in 0.124280 second(s), 24 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表