Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

Activating Plex hardware acceleration

dak180

Member
Joined
Nov 22, 2017
Messages
85
I updated the Plex pkg and noticed this note:
Code:
@@@ INTEL GPU OFFLOAD NOTES @@@

If you have a supported Intel GPU, you can leverage hardware
accellerated encoding/decoding in Plex Media Server on FreeBSD 12.0+.

The requirements are as follows:

* Install multimedia/drm-kmod: e.g., pkg install drm-fbsd12.0-kmod

* Enable loading of kernel module on boot: sysrc kld_list+="drm"
** If Plex will run in a jail, you must load the module outside the jail!

* Load the kernel module now: kldload drm

* Install the supporting Intel VA support library for your GPU
** multimedia/libva-intel-driver: [LEGACY] Intel GMA 4500 or newer
** multimedia/libva-intel-media-driver: Intel HD 5000 (Gen8) or newer
*** This must be installed beside Plex. e.g., in the jail with Plex

* Add plex user to the video group: pw groupmod -n video -m plex

* For jails, make a devfs ruleset to expose /dev/dri/* devices.

e.g., /dev/devfs.rules on the host:

[plex_drm=10]
add include $devfsrules_hide_all
add include $devfsrules_unhide_basic
add include $devfsrules_unhide_login
add include $devfsrules_jail
add path 'dri*' unhide
add path 'dri/*' unhide
add path 'drm*' unhide
add path 'drm/*' unhide

* Enable the devfs ruleset for your jail. e.g., devfs_ruleset=10 in your
/etc/jail.conf or for iocage, iocage set devfs_ruleset="10"

Please refer to documentation for all other FreeBSD jail management
utilities.

@@@ INTEL GPU OFFLOAD NOTES @@@

I thought this would be nice to setup so that once we are on FreeBSD 12 everything would just start working.

So I started investigating; the drm kernel module is in the base system but not loaded, so I set it up to load.
I also had no issue installing the Intel VA support libraries in the Plex jail and adding the plex user to the video group.

However I have not been able to figure out how to create a custom devfs ruleset and get iocage to actually use it. I either get a message that the ruleset does not exist (if I try put the rulleset in /etc/devfs.rules) or the ruleset does not actually contain the rules I set if I try to script it directly (which leads to a dhcp failure).

https://github.com/freenas/iocage/pull/22 implies that there is some way to tell iocage directly about custom devfs rulesets but I have not been able to find documentation anywhere.

So does anyone know how to get this working without switching to one of iocage's other built-in rulesets that unhide everything?
 

rknaub

Member
Joined
Jan 31, 2017
Messages
54
I am interested in getting this working as well. Right now I do not have a compatible GPU, but I will soon begin looking into an upgrade so that I can make use of hardware acceleration. I hope someone can figure this out and write some sort of guide maybe, I am not capable of doing this alone!
 

dak180

Member
Joined
Nov 22, 2017
Messages
85
I am interested in getting this working as well. Right now I do not have a compatible GPU, but I will soon begin looking into an upgrade so that I can make use of hardware acceleration. I hope someone can figure this out and write some sort of guide maybe, I am not capable of doing this alone!
I think I have the issue I ran into figured out and I will document everything I did once I have some time.
Do not get too excited yet, at this point it is all only prep work; the base freenas system (and jails) will need to be updated to freebsd 12 before anything will work. I do not recall which future release that is scheduled for.
 

gt2416

Member
Joined
Feb 4, 2018
Messages
192

dak180

Member
Joined
Nov 22, 2017
Messages
85
Note: At this time (FreeNAS 11.2) these settings will not actually do anything (plex requires FreeBSD 12 in the base system and jail for hardware acceleration), also this only covers intel gpus.

Keep in mind for when this will work; this requires hardware support, you need to have at a minimum: an intel cpu with an igpu, a motherboard that supports an igpu and additionally this may require specific settings in the bios and/or FreeNAS configured for UEFI booting.

  1. Load the drm kernel module: create tunable: Type: loader, Variable: drm_load, Value: YES.
  2. Load the i915kms kernel module: create tunable: Type: loader, Variable: i915kms_load, Value: YES.
  3. Install the support libs in the plex jail: pkg install multimedia/libva-intel-driver multimedia/libva-intel-media-driver
  4. Add plex to the video group: pw groupmod -n video -m plex
  5. Setup a custom devfs rule set for the plex jail:

Save the following script somewhere on the base system:
Code:
#!/bin/sh

cat >>/etc/devfs.rules << 'EOF'

[devfsrules_bpfjail=101]
add path 'bpf*' unhide

[plex_drm=109]
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

EOF


service devfs restart


Set this to run as a postinit task. We do this rather than editing /etc/devfs.rules directly because it is regenerated on boot.

Finally you will need to edit the plex jail properties to set the devfs_ruleset to 109.

With this everything should be ready for FreeBSD 12 and hardware acceleration should start working once FreeNAS is updated and you update the plex jail.
 
Last edited:

jonmayer

Neophyte
Joined
Jan 20, 2017
Messages
9
FreeNAS is currently on 11.2-U5, has anyone been able to get Intel hardware acceleration working in Plex?

My jail can't install these packages. Is there a repository that needs to be added?
pkg install multimedia/libva-intel-driver multimedia/libva-intel-media-driver
I haven't tried much past the package install for obvious reasons. I'm just curious if anyone has figured this all out.
 

dak180

Member
Joined
Nov 22, 2017
Messages
85
FreeNAS is currently on 11.2-U5, has anyone been able to get Intel hardware acceleration working in Plex?
With this everything should be ready for FreeBSD 12 and hardware acceleration should start working once FreeNAS is updated and you update the plex jail.
According to NAS-101640 it will come with FreeNAS 12, so not soon.

My jail can't install these packages. Is there a repository that needs to be added?
You may need to be on the latest repo:
Code:
#!/bin/bash
mkdir -p /usr/local/etc/pkg/repos
tee "/usr/local/etc/pkg/repos/FreeBSD.conf" << EOF

FreeBSD: {
  url: "pkg+http://pkg.FreeBSD.org/\${ABI}/latest"
}

EOF

(quick script to get you on the latest repo)
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,366

Bizarro252

Member
Joined
Jul 1, 2019
Messages
35
Thanks, I guess I was confused because it states we need to wait for 12, but also offered instructions on getting some packages installed that someone was having issues yet.

Sounds like 12 it is, but this link which was referenced isnt giving me any info either: NAS-101640
 

hertzsae

Member
Joined
Sep 23, 2014
Messages
77
Once 12 goes into beta you'll likely see some discussions pick up.
 

Bizarro252

Member
Joined
Jul 1, 2019
Messages
35
OK will keep an eye out and give it a shot at that time, thanks!
 

ThreeDee

Senior Member
Joined
Jun 13, 2013
Messages
319
so ....theoretically .. could I add a video card to my FreeNAS box and use hardware acceleration when FreeNAS updates to FreeBSD 12 then in Plex?
 

Chuck Remes

Member
Joined
Jul 12, 2016
Messages
166
so ....theoretically .. could I add a video card to my FreeNAS box and use hardware acceleration when FreeNAS updates to FreeBSD 12 then in Plex?
Yes. Depending on your motherboard you may already have a built-in GPU that can provide hardware acceleration.
 

dak180

Member
Joined
Nov 22, 2017
Messages
85
so ....theoretically .. could I add a video card to my FreeNAS box and use hardware acceleration when FreeNAS updates to FreeBSD 12 then in Plex?
Maybe; right now only intel GPUs are supported, though who knows what might happen between now and then.
 

ThreeDee

Senior Member
Joined
Jun 13, 2013
Messages
319
I run older hardware .. but going to get ready for FreeNAS 12 with a Xeon E3-1245 that I'll pick up off of Ebay that supports Intel Quick Sync.. my current E3-1230 does not. I'll keep an eye on this thread
 

jonmayer

Neophyte
Joined
Jan 20, 2017
Messages
9
I have this running on FreeNAS 11.3 (should might work on 11.2 [untested]) using Plex Version 1.18.0.1944 currently. I was stuck at not being able to pass /dev/dri and /dev/drm into iocage for Plex to see. Once I did that though, it was working. I have a E3-1245 v3, so older integrated video.

What module I loaded:
Code:
kldload /boot/modules/i915kms.ko

In /etc/rc.conf I added to kld_list so it survives a reboot
Code:
kld_list="hwpmc t3_tom t4_tom /boot/modules/i915kms.ko"


I added this to /etc/devfs.rules. I used ruleset 5 because no matter what I tried I couldn't get the jail to load any other ruleset, but it worked.
Code:
[devfsrules_bpfjail=101]
add path 'bpf*' unhide

[plex_drm=5]
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


Once again, older hardware so I installed this [in plex iocage jail]
Code:
pkg install multimedia/libva-intel-driver


And added plex to the video group [in plex iocage jail]
Code:
pw groupmod -n video -m plex


Edit: After playing with this on something other than mobile, the quality of the hardware encoder in these older CPUs is not great. I'll probably be turning off hardware encoding for any screen larger than 7 inches. I'm not upgrading anytime soon, but would love to see how well this works on a modern Intel processor.
 
Last edited:

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,366
I have this running on FreeNAS 11.3
Have you in fact verified that it is working? What is the output of freebsd-version from a root shell (not in a jail)?
(should work on 11.2)
No it will not. As posted above and as stated in the Plex installation notes on screen when you install Plex this feature is only available on FreeBSD 12. FreeNAS 11.2 is based on FreeBSD 11.2.
 

jonmayer

Neophyte
Joined
Jan 20, 2017
Messages
9
Have you in fact verified that it is working? What is the output of freebsd-version from a root shell (not in a jail)?
I have verified it's working. I wouldn't post here if that wasn't the case.

plex_hw.png


Output of freebsd-version is 11.3-RELEASE. If I had 11.2 installed I'd try it there, maybe someone here can. That's why I let everyone know what steps I took. I've edited my original to say that it might work in 11.2 from should work. Please feel free to try yourself. I'm pretty sure the plan is that it will work out of the box in 12. I consider what I have done to be a work around.
 

TheRoss

Newbie
Joined
Oct 15, 2019
Messages
3
I have verified it's working. I wouldn't post here if that wasn't the case.

View attachment 33333

Output of freebsd-version is 11.3-RELEASE. If I had 11.2 installed I'd try it there, maybe someone here can. That's why I let everyone know what steps I took. I've edited my original to say that it might work in 11.2 from should work. Please feel free to try yourself. I'm pretty sure the plan is that it will work out of the box in 12. I consider what I have done to be a work around.
You, Sir, are a saint :)
Is there any possibility you could give a FreeBSD-Noob an Info of how to
"pass /dev/dri and /dev/drm into iocage " ?

Also, could you explain what the
[plex_drm=5] means in the /etc/devfs.rules ? Is plex_drm the iocage name? is the 5 the jail-ID?

Last but not least, I only see /dev/drm. I don't have /dev/dri in there. I'm running FreeNAS FreeNAS-11.2-U6 and I have an intel i3-7100 CPU/GPU. Is this normal, or is /dev/dri mandatory for the acceleration?
( installed the proper driver package multimedia/libva-intel-media-driver -> hopefully the right one for my 7th gen cpu. Also loaded kldload /boot/modules/i915kms.ko)

What might I be missing?


Thank you very much for your experience sharing!!
 
Top