一、安装FfMpeg

    • 安装依赖Yasm
<span style="font-family: AlibabaPuHuiTi;">// 创建程序目录
[root@rpicentos /]# mkdir /opt/yasm

// 进入程序目录
[root@rpicentos /]# cd /opt/yasm

// 下载yasm
[root@rpicentos yasm]# wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz

// 解压缩yasm
[root@rpicentos yasm]# tar -zxvf yasm-1.3.0.tar.gz

// 进入主目录
[root@rpicentos yasm]# cd yasm-1.3.0

// 执行配置
[root@rpicentos yasm-1.3.0]# ./configure

// 开始编译
[root@rpicentos yasm-1.3.0]# make

// 安装程序
[root@rpicentos yasm-1.3.0]# make install
</span>
    • 安装FfMpeg
<span style="font-family: AlibabaPuHuiTi;">// 创建程序目录
[root@rpicentos /]# mkdir /opt/ffmpeg

// 进入程序目录
[root@rpicentos /]# cd /opt/ffmpeg

// 下载ffmpeg
[root@rpicentos ffmpeg]# wget http://www.ffmpeg.org/releases/ffmpeg-5.1.2.tar.gz

// 解压缩 ffmpeg
[root@rpicentos ffmpeg]# tar -zxvf ffmpeg-5.1.2.tar.gz

// 进入主目录
[root@rpicentos ffmpeg]# cd ffmpeg-5.1.2

// 执行配置
[root@rpicentos ffmpeg-5.1.2]# ./configure

// 开始编译
[root@rpicentos ffmpeg-5.1.2]# make

// 安装程序
[root@rpicentos ffmpeg-5.1.2]# make install
</span>

二、安装Jellyfin

    • 开始安装
<span style="font-family: AlibabaPuHuiTi;">// 安装依赖,避免某些错误
[root@rpicentos /]# yum install libicu

// 创建程序目录
[root@rpicentos /]# mkdir /opt/jellyfin

// 进入程序目录
[root@rpicentos /]# cd /opt/jellyfin

// 下载Jellyfin,由于是树莓派,选择通用Linux中的arm64版本,如果下载慢,可在Windows下载好后通过SFTP传输到程序目录
[root@rpicentos jellyfin]# wget https://repo.jellyfin.org/releases/server/linux/stable/combined/jellyfin_10.8.8_arm64.tar.gz

// 解压缩
[root@rpicentos jellyfin]# tar -xvzf jellyfin_10.8.8_arm64.tar.gz

// 创建快捷方式
[root@rpicentos jellyfin]# ln -s jellyfin_10.8.8 jellyfin

// 创建四个子目录
[root@rpicentos jellyfin]# mkdir data cache config log

// 创建启动脚本
[root@rpicentos jellyfin]# vim jellyfin.sh
#!/bin/bash
# jellyfin主目录
JELLYFINDIR="/opt/jellyfin"
# ffmpeg主目录
FFMPEGDIR="/opt/ffmpeg/ffmpeg-5.1.2"
$JELLYFINDIR/jellyfin/jellyfin \
 -d $JELLYFINDIR/data \
 -C $JELLYFINDIR/cache \
 -c $JELLYFINDIR/config \
 -l $JELLYFINDIR/log \
 --ffmpeg $FFMPEGDIR/ffmpeg
~
~
~

// 给予脚本执行权限
[root@rpicentos jellyfin]# chmod u+x jellyfin.sh

// 执行配置
[root@rpicentos jellyfin]# ./jellyfin.sh

// 进入管理员程序目录
[root@rpicentos jellyfin]# cd /etc/systemd/system

// 创建jellyfin配置文件
[root@rpicentos system]# vim jellyfin.service
[Unit]
Description=Jellyfin
After=network.target

[Service]
Type=simple
User=root
Restart=always
ExecStart=/opt/jellyfin/jellyfin.sh

[Install]
WantedBy=multi-user.target

// 给予权限
[root@rpicentos system]# chmod 644 jellyfin.service

// 重新加载unit配置文件
systemctl daemon-reload

// 配置开机启动
systemctl enable jellyfin.service

// 运行jellyfin
systemctl start jellyfin.service

// 通过树莓派IP:8096(例如:192.168.1.100:8096)
// 查看树莓派IP地址
[root@rpicentos system]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.100  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fa80::bdea:83fc:e0e7:2453  prefixlen 64  scopeid 0x20
        ether dc:b6:34:62:ee:42  txqueuelen 1000  (Ethernet)
        RX packets 1032798  bytes 68059174 (64.9 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 41812  bytes 8853971 (8.4 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
</span>

三、挂载NAS储存

    • 通过SMB挂载
<span style="font-family: AlibabaPuHuiTi;">// 尝试挂载看看是否正常
// 格式:mount -r //<NAS的IP地址>/<需要挂载的目录>/ /media/nas -o username=<Nas的用户>,password=<Nas的密码>
// -r 是以只读的方式挂载,Nas账号建议只给只读权限,增删文件建议通过后台执行,方式Jellyfin出现删除文件的Bug
[root@rpicentos /]# mount -r //192.168.1.110/movie/ /media/nas -o username=abc,password=123

// 进入挂载目录
[root@rpicentos /]# cd /media/nas

// 查看目录的内容,能看到挂载的内容即挂载成功
[root@rpicentos nas]# ls
测试信息.txt

// 加入开机启动,原理是开机执行一遍挂载指令,否则无法开机自动挂载
[root@rpicentos nas]# vim /etc/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local
mount -r //192.168.1.110/movie/ /media/nas -o username=abc,password=123

// 给予执行权限
[root@rpicentos nas]# chmod +x /etc/rc.local
</span>

四、配置Jellyfin

未在下方出现的内容,默认即可
    1. 【初始设置】设置你的媒体库
      • 内容类型:电影
      • 文件夹:/media/nas/movie
      • 媒体库设置
        • 首选下载语言:Chinese
        • 国家/地区:People's Republic of China
      • 优先使用内置的标题而不是文件名:√
      • 媒体资料储存方式:Nfo
      • 将媒体图像保存到媒体所在文件夹:√
    2. 【初始设置】首选元数据语言
      • 语言:Chinese
      • 国家/地区:People's Republic of China
    3. 【控制台】播放
      • 转码
        • 硬件加速:Video Acceleration API (VAAPI)
        • VA-API 设备:<此处选择驱动位置>