Skip to content

Commit

Permalink
Merge pull request #38 from spz2k9/main
Browse files Browse the repository at this point in the history
Add hardware encoding to Installation guide.
  • Loading branch information
Thefrank committed Jan 31, 2023
2 parents 122ee85 + 1970650 commit 5f5a6da
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 0 deletions.
100 changes: 100 additions & 0 deletions Installation_TrueNAS_GUI.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,106 @@ This is similar to installing Jellyfin but with fewer steps:

- Start the jellyfin server

## Hardware encoding (Intel)

### Packages and script to add inside the Jail

- Back on the jails list find your newly created jail for jellyfin and click "Shell" :
- Execute Theses commands :

```
pkg install libva-utils
pkg install libva-intel-media-driver
```

- Add lffmpeg script to add missing vaapi command

Create the lffmpeg script file (available here : [url](script/lffmpeg))

```
cd /usr/local/bin
ee lffmpeg
```

Paste the file content :

```
#!/bin/sh
ffmpeg -hwaccel vaapi "$@"
```

Close the editor with [ESC] and enter

- Make lffmpeg script executable

`chmod +x lffmpeg`

### Script to add on the TrueNas Core Host

- Loading kernel module + adding jail config to pass /dev/dri and /dev/drm
- Open a ssh shell on the TrueNas host
Create a script file in the root folder (available here : [url](script/enable_gpu_jails.sh)) :

`ee /root/enable_gpu_jails.sh`

Paste the file content :

```
#!/bin/sh
echo '[devfsrules_bpfjail=101]
add path 'bpf*' unhide
[plex_drm=10]
add include $devfsrules_hide_all
add include $devfsrules_unhide_basic
add include $devfsrules_unhide_login
add include $devfsrules_jail
add include $devfsrules_bpfjail
add path 'dri*' unhide
add path 'dri/*' unhide
add path 'drm*' unhide
add path 'drm/*' unhide' >> /etc/devfs.rules
service devfs restart
kldload /boot/modules/i915kms.ko
```

Close the editor with [ESC] and enter

- Make script executable
`chmod +x /root/enable_gpu_jails.sh`

- Run the script
`/root/enable_gpu_jails.sh`

### Required editing to the Jail and Test

- Stop the Jellyfin jail
- open the Edit for the jail
- Navigate to the 'Jail Properties' tab
- Look for the devfs_ruleset (should be the first option on the left)
- Change the rulset number to 10
- Save and start the jail
- Open a shell
- type 'vainfo' and look for entrypoints like : 'VAProfileH264Main : VAEntrypointEncSlice' (there can be multiple)
- close the shell
- Connect to the Jellyfin UI
- Verify that playback does work before enabling hardware encoding
- Once software playback is working go to Server --> Playback from the Dashboard
- Change the 'Hardware acceleration:' option from 'None' to 'VAAPI'
- Find the "ffmpeg path" option (arround the middle of the page)
- Change the value from 'ffmpeg' to '/usr/local/bin/lffmpeg'
- Save
- Hardware encoding should now be working
- If everthing now works
- Return to the TrueNas Core UI and navigate to Tasks --> Init/Shutdown Scripts
- Click [ADD]
- Change Type to 'Script'
- Navigate to '/root/enable_gpu_jails.sh'
- Change When to 'PostInit'
- Click [Submit]

## Troubleshooting and other things to note
- /Confusing HTTP/S messages/ (or other problems with jellyfin not being able to use the internet)
- Make sure you have VNET turned on for your jail.
Expand Down
19 changes: 19 additions & 0 deletions scripts/enable_gpu_jails.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

echo '[devfsrules_bpfjail=101]
add path 'bpf*' unhide
[plex_drm=10]
add include $devfsrules_hide_all
add include $devfsrules_unhide_basic
add include $devfsrules_unhide_login
add include $devfsrules_jail
add include $devfsrules_bpfjail
add path 'dri*' unhide
add path 'dri/*' unhide
add path 'drm*' unhide
add path 'drm/*' unhide' >> /etc/devfs.rules

service devfs restart

kldload /boot/modules/i915kms.ko
3 changes: 3 additions & 0 deletions scripts/lffmpeg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

ffmpeg -hwaccel vaapi "$@"

0 comments on commit 5f5a6da

Please sign in to comment.