## Prerequisites:
* A running jellyfin server on the master

## Step 1: Configuring Jellyfin and preparing the server

### Transcode temp folder
#### Sharing the the local trancode folder
Make the new trancode folder
```
mkdir /var/lib/jellyfin/transcoding-temp
```
NFS is the recomend way of sharing this folder, but SMB/CIFS shoud also work
```
apt -y install nfs-kernel-server
echo '/var/lib/jellyfin/transcoding-temp <Network IP>/24(rw,sync,no_subtree_check)' >> /etc/exports 
systemctl restart nfs-kernel-server
```
Set the following setting in jellyfin "Transcode path" in the Playback settings to "/var/lib/jellyfin/transcoding-temp"

#### Useing a existing remote share trancode folder
Make sure the folder is mounted at"/var/lib/jellyfin/transcoding-temp"  
Set the following setting in jellyfin "Transcode path" in the Playback settings to "/var/lib/jellyfin/transcoding-temp"

### Jellyfin user
Generating sshkey pair without password
```
sudo -u jellyfin mkdir -p /var/lib/jellyfin/.ssh
sudo -u jellyfin ssh-keygen -t rsa -f /var/lib/jellyfin/.ssh/id_rsa
```
Set the jellyfin user to login as bash in /etc/passwd

## Step 2: Install slave/render servers

### Getting  info
Run `cat /etc/passwd | grep jellyfin:` to get user info, i will refer to it as `<JelUser>`  
Run `cat /etc/group | grep jellyfin:`, to get group info, i will refer to it as `<JelGroup>`  
Run `cat /var/lib/jellyfin/.ssh/id_rsa.pub` To get ssh-key for sending commands , i will refer to it as `<MasterPubKey>`  
Get the ip of the master, i will refer to it as `<MasterIP>`  

### Installing on the remote slave
Use the info you collected en follow "Slave-install.md" 
```
sudo -u jellyfin ssh -i /var/lib/jellyfin/.ssh/id_rsa jellyfin@<SlaveIP>
```
When connected to the master exit the session with the slave server  
Repeat these steps for all slave server

### Adding local system as slave
```
echo 'ssh-rsa <MasterPubKey>' | sudo -u jellyfin tee /var/lib/jellyfin/.ssh/authorized_keys
sudo -u jellyfin ssh -i /var/lib/jellyfin/.ssh/id_rsa jellyfin@localhost
```

## Step 3: Installing rffmpeg
```
mkdir /etc/rffmpeg /opt/rffmpeg
wget https://raw.githubusercontent.com/joshuaboniface/rffmpeg/master/rffmpeg.yml.sample -O /etc/rffmpeg/rffmpeg.yml
wget https://raw.githubusercontent.com/joshuaboniface/rffmpeg/master/rffmpeg.py -O /opt/rffmpeg/rffmpeg.py
ln -s /usr/local/bin/rffmpeg.py /opt/rffmpeg/ffmpeg
ln -s /usr/local/bin/rffmpeg.py /opt/rffmpeg/ffprobe
```
## Step 3: Configuring rffmpeg
Add to the host section of /etc/rffmpeg/rffmpeg.yml
Example of the section in the config file
```
remote:
    # A YAML list of remote hosts to connect to
    hosts:
        - 192.168.1.2
        - 192.168.1.3
```
if you also want the local system to render add localhost or 127.0.0.1


## Step 4: Set jellyfin to use rffmpeg
Set the following setting in jellyfin "FFmpeg path" in the Playback settings to "/opt/rffmpeg/ffmpeg"

## Done
