# Jellyfin

#### Introduction

[Jellyfin](https://jellyfin.org/docs/index.html) is the volunteer-built media solution that puts you in control of your media. Stream to any device from your own server, with no strings attached. Your media, your server, your way.

- [Setting up Jellyfin Media Server on Raspberry Pi (itsfoss.com)](https://itsfoss.com/jellyfin-raspberry-pi/)

#### Installation

##### With Docker

```shell
# Pull the image
docker pull jellyfin/jellyfin

# Create the directories
mkdir {config,cache,video}

#Create the account
addgroup --system jellyfin
adduser --system --ingroup jellyfin jellyfin

# Set the permission
chown jellyfin.jellyfin config cache

# Run the container
docker run -d \
 --name jellyfin \
 --user $(id -u jellyfin):$(id -g jellyfin) \
 --net=host \
 --volume $(pwd)/config:/config \
 --volume $(pwd)/cache:/cache \
 --mount type=bind,source=$(pwd)/video,target=/video \
 --restart=unless-stopped \
 jellyfin/jellyfin
```

docker-compose.yaml:

```yaml
services:
  jellyfin:
    image: jellyfin/jellyfin
    container_name: jellyfin
    # Optional - specify the uid and gid you would like Jellyfin to use instead of root
    user: jellyfin:jellyfin
    ports:
      - 8096:8096/tcp
    volumes:
      - ./config:/config
      - ./cache:/cache
      - type: bind
        source: ./video
        target: /video
        read_only: true
      # Optional - extra fonts to be used during transcoding with subtitle burn-in
      - type: bind
        source: ./fonts
        target: /usr/local/share/fonts/custom
        read_only: true
    restart: 'unless-stopped'
    # Optional - alternative address used for autodiscovery
    #environment:
    #  - JELLYFIN_PublishedServerUrl=http://example.com
    # Optional - may be necessary for docker healthcheck to pass if running in host network mode
    extra_hosts:
      - 'host.docker.internal:host-gateway'
```

#### Quick Start

`http://SERVER_IP:8096`

#### Plugins

- [https://github.com/JavScraper/Emby.Plugins.JavScraper](https://github.com/JavScraper/Emby.Plugins.JavScraper)
- [91270/MeiamSubtitles: Emby Server / Jellyfin Server 端字幕插件 ，使用 迅雷影音、 射手网 接口精准匹配视频字幕](https://github.com/91270/MeiamSubtitles)

##### 新增第三方套件庫位址

- 官方說明：https://jellyfin.org/docs/general/server/plugins/index.html
- danieladov's Repo：`https://raw.githubusercontent.com/danieladov/JellyfinPluginManifest/master/manifest.json`
- dkanada's Repo：`https://raw.githubusercontent.com/dkanada/jellyfin-plugin-intros/master/manifest.json`

控制台 &gt; 附加元件 &gt; 儲存庫 &gt; 新增

##### 安裝附加元件

控制台 &gt; 附加元件 &gt; 目錄 &gt; \[選擇要安裝的元件\] &gt; Install

#### 直播頻道

- [https://github.com/iptv-org/iptv](https://github.com/iptv-org/iptv)
- [https://www.youtube.com/watch?v=htCDPwMQwcE](https://www.youtube.com/watch?v=htCDPwMQwcE)

#### 刮削器

- [MetaTube](https://metatube-community.github.io/)
- [tinyMediaManager](https://www.tinymediamanager.org/)

#### Storj DCS Cloud Storage

- [Setting up Storj with Plex Using Rclone](https://docs.storj.io/dcs/how-tos/how-to-use-plex-and-storj-dcs-as-a-private-streaming-service/)

rclone mount

```shell
rclone mount storjdcs-jellyfin:media /root/jellyfin/video --vfs-che-mode full --dir-cache-time 1h  --no-checksum --no-modtime --rc

rclone mount storjdcs-jellyfin:media /root/jellyfin/video \
 --vfs-cache-mode full \
 --allow-other \
 --dir-cache-time 1h \
 --uid=$(id -u jellyfin) \
 --gid=$(id -g jellyfin) \
 --no-checksum --no-modtime --rc
```

Refreshing the Local Sync Location

This recursively refreshes the root directory of the Rclone mount to pick up the newly uploaded files in Storj.

```bash
rclone rc vfs/refresh -v --fast-list recursive=true
```

- 掛載時，程式會在前景模式下執行；如果要卸載，直接 CTRL+C。
- 遠端目錄的權限 owner 只能是 root，所以必須修改 docker 的啟動參數，將這行刪除 `--user $(id -u jellyfin):$(id -g jellyfin) \`。

#### FAQ

> 媒體庫封面無法顯示中文。

Solution: 在主機端安裝中文字形

```shell
# On the docker host
apt install fonts-noto-cjk

# Adjust the launch command
docker run -d \
...
 --volume /usr/share/fonts:/usr/share/fonts \
 --volume /usr/share/fontconfig:/usr/share/fontconfig \
...
 jellyfin/jellyfin
```

清除 Browser cache，並重新登入後再試一次。

如果還是顯示不正常，清除 `config/metadata/library/` 內的所有目錄，重新掃描媒體庫後再試一次。

> ASS 字幕無法顯示中文。

Solution:

1. 下載中文字型檔(網頁字型) `NotoSansCJKtc-Regular.woff2`， `NotoSerifCJKtc-Regular.woff2`。下載位址：[https://github.com/CodePlayer/webfont-noto/releases](https://github.com/CodePlayer/webfont-noto/releases)
2. 在主機端 docker 目錄下新增 font/ 資料夾，並將字型檔上傳到該資料夾。
3. 修改 docker 啟動檔，在中間處加上這一行 `--volume $(pwd)/fonts:/fonts \`，重新啟動 container。
4. 開啟 Jellyfin 管理界面 &gt; 控制台 &gt; 播放 &gt; Fallback font folder path: */fonts* ，Enable fallback fonts: *Checked*
5. Done

> rclone 掛載 StorjDCS 發生錯誤：
> 
> Fatal error: failed to mount FUSE fs: fusermount: exec: "fusermount": executable file not found in $PATH

Solution：

```bash
sudo apt install fuse
```