Jellyfin 自定义配置

使用 jellyfin 做媒体服务的小伙伴,可参考此片文章配置应用。

解决问题

  1. 硬解码支持(官方应用中未映射驱动)

  2. 投屏与发现服务(官方应用使用桥接网络,无法使用服务)

  3. 持久化目录(官方应用卸载后目录将被删除)

  4. 新增配置选项(丰富自定义配置)

修改教程

修改参数

version: '3'
services:
  jellyfin:
    container_name: ${CONTAINER_NAME}
    restart: always
    networks:
      - 1panel-network
    ports:
        - "${PANEL_APP_PORT_HTTP}:8096"
    volumes:
        - "./data/config:/config"
        - "${CACHE_FOLDER_PATH}:/cache"
        - "${MEDIA_FOLDER_PATH}:/media/media"
    image: "jellyfin/jellyfin:10.8.13"
    labels:  
      createdBy: "Apps"
networks:  
  1panel-network:  
    external: true
  1. 网络模式
    networks:
      - 1panel-network
    # 修改为
    network_mode: ${NETWORK_MODE}

${NETWORK_MODE} 取值:

  • host 主机模式 【推荐】
  • bridge 桥接模式 与 1panel-network 一致
  • none 无网络
  • 其他模式可在 容器 >> 网络 中查看网络名称

网络模式建议选择 host 主机模式,与宿主机共用IP,同时支持投屏与发现服务。

主机模式下,如果您使用其他应用,例如(Emby) 与当前应用的 8096 端口占用,请参考文末的第三方应用仓库。

  1. 持久化目录
    修改 volumes
    volumes:
      - ${JELLYFIN_ROOT_PATH}/config:/config
      - ${JELLYFIN_ROOT_PATH}/config/config/network.xml:/config/config/network.xml
      - ${JELLYFIN_ROOT_PATH}/cache:/cache
      - ${JELLYFIN_ROOT_PATH}/media:/media

${JELLYFIN_ROOT_PATH} 取值一般为 /home/jellyfin

配置文件将存储在 /home/jellyfin/config

缓存目录将存储在 /home/jellyfin/cache
/home/jellyfin/media 为媒体库目录,可选项,媒体存放建议将媒体目录软链接到此目录,避免了数据移动造成的数据丢失,也能避免涟漪问题。

${JELLYFIN_ROOT_PATH}/config/config/network.xml:/config/config/network.xml
请注意,这一条映射是为了文末的 通过1Panel 应用商店完成端口与配置的修改 如果不需要请删除此行。

  1. 宿主机驱动
    请查看宿主机 /dev/dri 目录下是否存在驱动文件。例如:
card0
renderD128

等类似驱动文件,具体参考 Jellyfin 官网。一般情况下存在 renderD128 说明可支持显卡硬解。
添加驱动映射

    devices:
      - ${JELLYFIN_DRIVE_PATH}:/dev/dri

${JELLYFIN_DRIVE_PATH} 取值:
一般情况下为 /dev/dri 如果您有其他驱动,可做适当修改。

至此就完成 主要的功能区域修改。

通过1Panel 应用商店完成端口与配置的修改

由于1Panel应用商店安装应用前会执行 init.sh 的特性,因此通过脚本完成Jellyfin的网络配置
docker-compose.yml 同级目录下创建
config/network.xml
scripts/init.sh

network.xml Jellyfin网络配置

<?xml version="1.0" encoding="utf-8"?>
<NetworkConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                      xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <RequireHttps>false</RequireHttps>
    <CertificatePath/>
    <CertificatePassword/>
    <BaseUrl/>
    <PublicHttpsPort>{PANEL_APP_PORT_HTTPS}</PublicHttpsPort>
    <HttpServerPortNumber>{PANEL_APP_PORT_HTTP}</HttpServerPortNumber>
    <HttpsPortNumber>{PANEL_APP_PORT_HTTPS}</HttpsPortNumber>
    <EnableHttps>false</EnableHttps>
    <PublicPort>{PANEL_APP_PORT_HTTP}</PublicPort>
    <UPnPCreateHttpPortMap>false</UPnPCreateHttpPortMap>
    <UDPPortRange/>
    <EnableIPV6>{JELLYFIN_IPV6_ENABLE}</EnableIPV6>
    <EnableIPV4>true</EnableIPV4>
    <EnableSSDPTracing>false</EnableSSDPTracing>
    <SSDPTracingFilter/>
    <UDPSendCount>2</UDPSendCount>
    <UDPSendDelay>100</UDPSendDelay>
    <IgnoreVirtualInterfaces>true</IgnoreVirtualInterfaces>
    <VirtualInterfaceNames>vEthernet*</VirtualInterfaceNames>
    <GatewayMonitorPeriod>60</GatewayMonitorPeriod>
    <TrustAllIP6Interfaces>false</TrustAllIP6Interfaces>
    <HDHomerunPortRange/>
    <PublishedServerUriBySubnet/>
    <AutoDiscoveryTracing>false</AutoDiscoveryTracing>
    <AutoDiscovery>true</AutoDiscovery>
    <RemoteIPFilter/>
    <IsRemoteIPFilterBlacklist>false</IsRemoteIPFilterBlacklist>
    <EnableUPnP>true</EnableUPnP>
    <EnableRemoteAccess>true</EnableRemoteAccess>
    <LocalNetworkSubnets/>
    <LocalNetworkAddresses/>
    <KnownProxies/>
    <EnablePublishedServerUriByRequest>false</EnablePublishedServerUriByRequest>
</NetworkConfiguration>

init.sh 初始化脚本

#!/bin/bash

if [[ -f ./.env ]]; then
  source .env

  mkdir -p "$JELLYFIN_ROOT_PATH"
  mkdir -p "$JELLYFIN_ROOT_PATH/config"
  mkdir -p "$JELLYFIN_ROOT_PATH/config/config"
  mkdir -p "$JELLYFIN_ROOT_PATH/cache"
  mkdir -p "$JELLYFIN_ROOT_PATH/media"

  if [ ! -f "$JELLYFIN_ROOT_PATH/config/config/network.xml" ]; then
    cp -f ./config/network.xml "$JELLYFIN_ROOT_PATH/config/config/network.xml"
    sed -i "s/{PANEL_APP_PORT_HTTP}/$PANEL_APP_PORT_HTTP/g" "$JELLYFIN_ROOT_PATH/config/config/network.xml"
    sed -i "s/{PANEL_APP_PORT_HTTPS}/$PANEL_APP_PORT_HTTPS/g" "$JELLYFIN_ROOT_PATH/config/config/network.xml"
    sed -i "s/{JELLYFIN_IPV6_ENABLE}/$JELLYFIN_IPV6_ENABLE/g" "$JELLYFIN_ROOT_PATH/config/config/network.xml"
  else
    echo "network.xml already exists."
    sed -i "s/<PublicPort>[0-9]\{1,5\}<\/PublicPort>/<PublicPort>$PANEL_APP_PORT_HTTP<\/PublicPort>/g" "$JELLYFIN_ROOT_PATH/config/config/network.xml"
    sed -i "s/<HttpServerPortNumber>[0-9]\{1,5\}<\/HttpServerPortNumber>/<HttpServerPortNumber>$PANEL_APP_PORT_HTTP<\/HttpServerPortNumber>/g" "$JELLYFIN_ROOT_PATH/config/config/network.xml"
    sed -i "s/<PublicHttpsPort>[0-9]\{1,5\}<\/PublicHttpsPort>/<PublicHttpsPort>$PANEL_APP_PORT_HTTPS<\/PublicHttpsPort>/g" "$JELLYFIN_ROOT_PATH/config/config/network.xml"
    sed -i "s/<HttpsPortNumber>[0-9]\{1,5\}<\/HttpsPortNumber>/<HttpsPortNumber>$PANEL_APP_PORT_HTTPS<\/HttpsPortNumber>/g" "$JELLYFIN_ROOT_PATH/config/config/network.xml"
    sed -i "s/<EnableIPV6>[a-z]\{4,5\}<\/EnableIPV6>/<EnableIPV6>$JELLYFIN_IPV6_ENABLE<\/EnableIPV6>/g" "$JELLYFIN_ROOT_PATH/config/config/network.xml"
  fi

  echo "Check Finish."

else
  echo ".env not found."
fi

data.yml

additionalProperties:
  formFields:
    - default: "host"
      edit: true
      envKey: NETWORK_MODE
      labelEn: Drive path
      labelZh: 网络模式
      required: true
      type: select
      values:
        - label: 主机模式
          value: "host"
        - label: 桥接模式
          value: "bridge"
        - label: 无网络
          value: "none"
        - label: 1panel-network
          value: "1panel-network"
    - default: "/home/jellyfin"
      edit: true
      envKey: JELLYFIN_ROOT_PATH
      labelEn: Data persistence root path
      labelZh: 数据持久化 根路径
      required: true
      type: text
    - default: 8096
      edit: true
      envKey: PANEL_APP_PORT_HTTP
      labelEn: WebUI Port
      labelZh: 网页端口
      required: true
      rule: paramPort
      type: number
    - default: 8920
      edit: true
      envKey: PANEL_APP_PORT_HTTPS
      labelEn: WebUI SSL Port
      labelZh: 网页SSL端口
      required: true
      rule: paramPort
      type: number
    - default: "/dev/dri"
      edit: true
      envKey: JELLYFIN_DRIVE_PATH
      labelEn: Drive path
      labelZh: 驱动存放路径
      required: true
      type: text
    - default: "false"
      edit: true
      envKey: JELLYFIN_IPV6_ENABLE
      labelEn: Enable IPv6
      labelZh: 启用IPv6
      required: true
      type: select
      values:
        - label: 启用
          value: "true"
        - label: 禁用
          value: "false"

至此就完成了Jellyfin的改装。

使用第三方应用商店完成安装

如果您觉得修改麻烦,可参考第三方应用商店仓库:
1Panel 第三方应用商店
进行安装:


无需编辑coompose,完成安装。

安装第三方应用商店

由于仓库在GitHub 无法连接GitHub的用户将无法使用。

  1. 创建计划任务
  2. 添加更新脚本

    脚本内容
#!/bin/bash

# 定义脚本URL
script_url="https://github.com/QYG2297248353/appstore-1panel/releases/download/install/install.sh"

# 执行脚本
echo "Downloading and executing script from $script_url..."
bash <(curl -sL "$script_url")

# 输出执行结果
echo "Script execution completed."

脚本代理

由于1Panel脚本运行机制的问题,脚本运行并没有宿主机的环境变量:http_proxyhttp_proxy 如果代理在路由级(openwrt等软路由代理)可忽略。

设置脚本代理,在 # 定义脚本URL 行之前添加

# 定义代理服务器地址和端口
proxy_server="server address"
proxy_port="server port"
# 设置网络代理
export http_proxy="http://$proxy_server:$proxy_port"
export https_proxy="http://$proxy_server:$proxy_port"

修改 server addressserver port 参数值,即可。

写在最后

感谢1Panel

手动点赞。

【修复】中文乱码

常见问题:

  1. 仓库封面乱码,中文显示方框
  2. 字幕乱码,无法正常加载字幕

常用解决方案

  1. 安装字体包
    缺点:版本升级,重装会失效。
apt update
apt install fonts-noto-cjk-extra
  1. 使用第三方应用【完美解决】
    通过映射字体库,替换Docker容器系统字体库解决,字体来源 Google Font 官网。
    字体源:
    Noto Sans
    Noto Sans Mono
    Noto Serif
        volumes:
            - ${JELLYFIN_ROOT_PATH}/config/font:/config/font
            - ${JELLYFIN_ROOT_PATH}/config/dejavu:/usr/share/fonts/truetype/dejavu

如需要可自行参照以下仓库配置:
仓库地址:Jellyfin 应用配置