Subsonic
Subsonic 曾是一个音乐服务器,允许您将音乐存储在一台机器上,并通过 Web 界面或各种其他应用程序从其他机器、手机上播放。它已不再维护。但是,存在一个维护的分支 (airsonic-advanced-gitAUR)。
安装
旧的、未维护的 subsonicAUR 版本仍然可用。此外,从版本 6 开始,该软件不是开源的。因此,建议用户安装开源分支 airsonic-advanced-gitAUR。
配置
执行任何配置后,请记住重启 subsonic.service
。
安装转码器
默认情况下,Subsonic 使用 FFmpeg 将视频和歌曲即时转码为适当的格式和比特率。安装后,您可以更改这些默认设置,例如,Subsonic 将使用 FLAC 和 LAME 而不是 FFmpeg 来转码 FLAC 文件。因此,您应该安装 ffmpeg,并且您可能还需要安装 flac 和 lame。
出于安全原因,Subsonic 不会搜索系统中的任何转码器。相反,用户必须在 /var/lib/subsonic/transcode
文件夹中创建指向转码器的符号链接。像这样创建符号链接
$ cd /var/lib/subsonic/transcode # for transcoder in ffmpeg flac lame; do ln -s "$(which $transcoder)"; done
HTTPS 设置
使用 Subsonic
要启用 HTTPS 浏览和流式传输,请编辑 /var/lib/subsonic/subsonic.sh
并将端口从 0 更改为 8443
/var/lib/subsonic/subsonic.sh
SUBSONIC_HTTPS_PORT=8443
使用 nginx
如果您已经运行了多个 Web 服务,则在所有地方使用单个 SSL 配置可能会更容易。以下 nginx 配置在 https://example.com/subsonic
下运行 Subsonic
server { listen 443 default ssl; server_name example.com; ssl_certificate cert.pem ssl_certificate_key key.pem location /subsonic { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_set_header Host $http_host; proxy_max_temp_file_size 0; proxy_pass http://127.0.0.1:4040; proxy_redirect http:// https://; } }
要在不同的路径下运行 Subsonic,您必须设置以下选项
/var/lib/subsonic/subsonic.sh
SUBSONIC_CONTEXT_PATH=/subsonic SUBSONIC_HOST=127.0.0.1 SUBSONIC_PORT=4040 SUBSONIC_HTTPS_PORT=0
使用 lighttpd
以下配置使 lighttpd 接受 HTTPS 连接并将它们代理到 localhost。这种方法的一个优点是 Subsonic 不需要知道 SSL 设置,并且可以保留默认设置。此配置还旨在与 lighttpd 在单个 IP 地址上托管多个站点的情况良好配合。
/etc/lighttpd.conf
# Documentation at: https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs # Check for errors: lighttpd -t -f /path/to/config server.modules += ("mod_proxy", "mod_redirect") server.username = "http" server.groupname = "http" server.pid-file = "/var/run/lighttpd.pid" server.errorlog = "/var/log/lighttpd/error.log" server.document-root = "/srv/http/" index-file.names = ("index.html") mimetype.assign = ( ".avi" => "video/x-msvideo", ".css" => "text/css", ".html" => "text/html", ".jpg" => "image/jpeg", ".log" => "text/plain", ".markdown" => "text/plain", ".md" => "text/plain", # markdown ".mkv" => "video/x-matroska", ".mp4" => "video/mp4", ".nfo" => "text/plain", ".png" => "image/png", ".rc" => "text/plain", ".rst" => "text/plain", # reStructuredText ".svg" => "image/svg+xml", ".txt" => "text/plain", ".xml" => "application/xml", "" => "application/octet-stream" ) $SERVER["socket"] == ":80" { $HTTP["host"] == "subsonic.example.com" { url.redirect = ("^/(.*)" => "https://subsonic.example.com/$1") } } $SERVER["socket"] == ":443" { # A default ssl.pemfile is required. It can be overridden in specific host # blocks. It *may* also be possible to override ssl.ca-file, but this has # not been tested. ssl.engine = "enable" ssl.use-sslv3 = "disable" ssl.ca-file = "/etc/lighttpd/ssl/GandiStandardSSLCA2.pem" ssl.pemfile = "/etc/lighttpd/ssl/subsonic.example.com.pem" $HTTP["host"] == "subsonic.example.com" { ssl.pemfile = "/etc/lighttpd/ssl/subsonic.example.com.pem" proxy.server = ( # This proxying is completely transparent to clients. We load # balance requests for this path or extension... "" => ( # ... among the following servers. The string naming each server # is just a label, and it has little functional impact. (It # might affect log file output?) ("host" => "127.0.0.1", "port" => 4040) ) ) } }
故障排除
FLAC 回放
FFmpeg 转码器不能很好地处理 FLAC 文件,客户端通常无法播放生成的流。使用 FLAC 和 LAME 代替 FFmpeg 可能会解决此问题。此解决方法要求已安装 FLAC 和 LAME 转码器,如#安装转码器中所述。
启动 Subsonic 并转到设置 > 转码。确保默认的 FFmpeg 转码器不用于 .flac 文件,然后添加一个新条目。您最终会得到类似这样的内容
名称 | 转换自 | 转换为 | 步骤 1 | 步骤 2 |
---|---|---|---|---|
mp3 默认 | ... NOT flac ... | mp3 | ffmpeg ... | |
mp3 flac | flac | mp3 | flac --silent --decode --stdout %s | lame --silent -h -b %b - |
访问数据库
Subsonic 将所有数据存储在 /var/lib/subsonic/db
中的 HyperSQL 数据库中。您可以使用简单的 Web 界面访问它,方法是访问 https://127.0.0.1:4040/db.view(替换为您的 Subsonic URL)。
您还可以使用 HyperSQL 发行版中的 SQLTool 命令行工具,该工具位于 hsqldb2-javaAUR 中。
db.copy
目录中有一个数据库副本。此命令可以交互式运行,无需其他参数
$ java -jar /usr/share/java/sqltool.jar --inlineRc=url=jdbc:hsqldb:file:db.copy/libresonic,user=sa,password= SqlTool v. 5337. JDBC Connection established to a HSQL Database Engine v. 2.3.3 database ... sql>
它也可以非交互式运行命令。此命令导出 MEDIA_FILE
表中的所有内容
$ java -jar /usr/share/java/sqltool.jar --inlineRc=url=jdbc:hsqldb:file:db.copy/libresonic,user=sa,password= - <<< '\xq MEDIA_FILE' 8074 row(s) fetched from database. Wrote 3252295 characters to file 'MEDIA_FILE.csv'.
此命令将整个数据库导出为 SQL 文件
$ java -jar /usr/share/java/sqltool.jar --inlineRc=url=jdbc:hsqldb:file:db.copy/libresonic,user=sa,password= - <<< "backup database to 'backup.tar' script not compressed;" 1 / 1 subsonic.script...
Subsonic 兼容服务器
Libresonic/Airsonic
Subsonic 后来被 Fork 为 Libresonic。这也是开源的,但删除了付费许可证检查,因此也是免费的,就像免费啤酒一样。但是,Subsonic 和 Libresonic 都不再维护。当前的分支继续使用名称 Airsonic-Advanced。
Madsonic
madsonicAUR 是 Subsonic 的一个(非免费)分支,具有额外的功能。
启动服务器后,请密切注意转码选项,因为您可能必须将命令从“Audioffmpeg”更改为“ffmpeg”。
Gonic
gonicAUR 是一个轻量级的音乐流媒体服务器,它实现了 Subsonic API
navidrome 也是一个现代且优秀的替代音乐服务器,它实现了 Subsonic API。它用 Go 编写,可在包括 Raspberry Pi 在内的各种平台上运行 [1]。
客户端
Feishin
feishinAUR (之前维护为 sonixdAUR)是一个跨平台的桌面 Subsonic API 客户端播放器
Strawberry Music Player
strawberry 具有从 Subsonic API 服务器播放音乐的能力
Sublime Music
sublime-musicAUR 是一个原生的图形化 Subsonic 客户端。
stmps
stmps-gitAUR 是一个用于终端的 Subsonic 客户端。