Activating Plex hardware acceleration

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
That's good to know that the Intel drivers aren't needed!
Edit: Confirmed in my 1.18.9 jail, works without.

I've been doing some testing to try to figure out whether they were, and I can't get hardware transcode to work at all now in a Plex 1.19.1 jail. Plex 1.18.9 continues to work. Caveat, if you are using an auto-update crontab, you may want to disable it until we know whether that's my system or an issue with Plex 1.19.1.

Edit: Some more testing with a clone jail. This is either my system, or something is different between installing plex 1.19.1 and upgrading to it.


Code:
iocage stop PMS
iocage clone PMS-Transcode --name plex
iocage start plex
Verify that hw transcode works
pkg upgrade -y && service plexmediaserver restart
hw transcode still works
 
Last edited:

JohnnyGrey

Dabbler
Joined
Jul 1, 2017
Messages
45
That's good to know that the Intel drivers aren't needed!
Edit: Confirmed in my 1.18.9 jail, works without.

I've been doing some testing to try to figure out whether they were, and I can't get hardware transcode to work at all now in a Plex 1.19.1 jail. Plex 1.18.9 continues to work. Caveat, if you are using an auto-update crontab, you may want to disable it until we know whether that's my system or an issue with Plex 1.19.1.

My jail is transcoding fine on version 1.19.1.2645, other than my aforementioned issue with the HEVC 10 non-HDR files.

I came home today to find dri pass-through missing, so I don't know what's going on. (This was right before my recent testing.) I'm currently writing a simple script that I'll have as a cron job once a day at maybe 4 or 5am that checks for dri pass-through, stops the jail and restarts the devfs service if needed, and reloads the jail. After that, it checks for the 110 ruleset.

EDIT: Here's my script. Please don't laugh, as I still consider myself a scripting noob. Most of my scripts I kind of piece together via Google. I was able to confirm the first if/then works by restarting the Plex jail beforehand, removing dri passthrough. I was able to confirm the second if/then works by temporarily removing the "service devfs restart" line, since the same ruleset would be reloaded. It's crude, but it should definitely work as a once a day cron job, as long as it doesn't occur at a time someone is streaming. I'll look into whether I can retrieve whether someone is streaming from the commandline, then add that later.

Code:
if iocage exec plex ls /dev/ | grep -c "dri" > /dev/null
then
        date +"%b %d %T Plex DRI pass-through still exists." >> /var/log/messages
else
        date +"%b %d %T Plex DRI pass-through no longer exists. Shutting Plex down and restarting devfs service." >> /var/log/messages
        iocage stop plex
        service devfs restart
        iocage start plex
        if iocage get all plex | grep -c "ruleset:110" > /dev/null
        then
                date +"%b %d %T Plex devfs_ruleset:110 successfully loaded." >> /var/log/messages
        else
                date +"%b %d %T Plex devfs_ruleset:110 failed to load!" >> /var/log/messages
                echo "Plex devfs_ruleset:110 failed to load!" | mail -s "Plex hw Transcoding Problem" email.address.here@domain.com
        fi
fi

 
Last edited:

zperetz

Dabbler
Joined
Dec 2, 2017
Messages
36
Edit: Some more testing with a clone jail. This is either my system, or something is different between installing plex 1.19.1 and upgrading to it.
It's definitely recommended to upgrade PMS via "pkg remove - pkg install" (it was said again in the thread I linked before).
 

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
Re hw transcode suddenly not working on a test jail:

Ich bin ein Idiot.

Goshdarnit. Sorry for wasting your time. I enabled ruleset 110, I did not make the plex user part of the video group when testing.

I need to automate this so I don’t forget.

Edit: In testing, allow_mount_devfs is not required for hardware transcode.
 
Last edited:

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
Some more performance testing. Some Blurays were encoded with VC-1 instead of H.264. This means even when playing back to a 1080p device, it'll be transcoded to H.264. On a Xeon 1225v6, software transcoding a 1080p VC-1 takes 70 to 75% CPU. Hardware transcode for the same file is 2-3% CPU.
 

JohnnyGrey

Dabbler
Joined
Jul 1, 2017
Messages
45
Here's the latest iteration of my script. It retrieves the stream count, and if it's greater than 0, sleeps for 5 minutes and then retries. If it retries 12 times (1 hour), it exits. If the Stream Count = 0, it continues with the check. If /dev/dri doesn't exist, it kills the jail, restarts devfs, then restarts the jail. Those command outputs also get piped into the log file. The logfile is always created in the directory the script is in, not where it's ran from.

Also available here, if you like pretty colors.

Code:
#!/bin/sh

# Update 4182020: Changed all console outputs to instead write to a logfile. The logfile will
# always be in the scripts directory, regardless of where script is executed from.

# This is a script that checks for the /dev/dri device existing inside the Plex jail.
# If it does not exist, it kills the jail, restarts devfs service, and restarts the jail.
# If there are open streams, the script waits 5 minutes and checks again. After checking 12 times,
# the script will exit. When there are 0 streams open, the script continues with
# the check.

# To email and wipe the logfile, use this as a cron task:
# mail -s "Plex DRI Check Log" EmailAddress@here.com < /path/to/log/plex_dri_check.log; echo "" > /path/to/log/plex_dri_check.log

# Specify Plex jail name, IP, port, auth token, and custom ruleset number:
PlexName="plex"
PlexIP="192.168.1.100"
PlexPort="32400"
Token="replace_this_with_token"
RuleNum="110"

TimeStamp()
{
        date +"%Y-%m-%d %T:"
}

TimeStampPre() {
    while IFS= read -r line; do
        printf '%s %s\n' "$(date +"%Y-%m-%d %T:")" "$line";
    done
}

LogFile="${0%/*}/plex_dri_check.log"
RetryCount=0
StreamCount=$(curl "http://$PlexIP:$PlexPort/status/sessions?X-Plex-Token=$Token" --stderr - \
        | grep 'MediaContainer size=' | grep -o '[0-9]\+')

while [ $StreamCount -gt 0 ]
do
        echo "$(TimeStamp) There are currently $StreamCount open stream(s). Sleeping for 5m, then checking again." >> "$LogFile"
        RetryCount=$((RetryCount+1))
        if [ $RetryCount = "12" ]
        then
                echo "$(TimeStamp) Checked $RetryCount times. Stream(s) still open. Exiting." >> "$LogFile"
                exit 0
        fi
        sleep 300
        StreamCount=$(curl "http://$PlexIP:$PlexPort/status/sessions?X-Plex-Token=$Token" --stderr - \
        | grep 'MediaContainer size=' | grep -o '[0-9]\+')
done

if iocage exec $PlexName ls /dev/ | grep -c "dri" > /dev/null
then
        echo "$(TimeStamp) DRI pass-through still exists. Exiting." >> "$LogFile"
else
        echo "$(TimeStamp) DRI pass-through no longer exists. Killing Plex, restarting devfs, restarting Plex." >> "$LogFile"
        iocage stop $PlexName | TimeStampPre >> "$LogFile"
        sleep 3
        service devfs restart | TimeStampPre >> "$LogFile"
        sleep 3
        iocage start $PlexName | TimeStampPre >> "$LogFile"
        if iocage get all $PlexName | grep -c "ruleset:$RuleNum" > /dev/null
        then
                echo "$(TimeStamp) devfs_ruleset:$RuleNum successfully loaded." >> "$LogFile"
        else
                echo "$(TimeStamp) CRITICAL: devfs_ruleset:$RuleNum failed to load!" >> "$LogFile"
        fi
fi


Example of what logfile looks like with a jail kill, devfs restart, jail start:
Code:
2020-04-18 08:00:01: DRI pass-through still exists. Exiting.
2020-04-18 10:00:01: DRI pass-through still exists. Exiting.
2020-04-18 12:00:01: DRI pass-through still exists. Exiting.
2020-04-18 12:14:13: DRI pass-through no longer exists. Killing Plex, restarting devfs, restarting Plex.
2020-04-18 12:14:13: * Stopping plex
2020-04-18 12:14:13:   + Executing prestop OK
2020-04-18 12:14:15:   + Stopping services OK
2020-04-18 12:14:16:   + Tearing down VNET OK
2020-04-18 12:14:16:   + Removing devfs_ruleset: 7 OK
2020-04-18 12:14:16:   + Removing jail process OK
2020-04-18 12:14:16:   + Executing poststop OK
2020-04-18 12:14:23: * Starting plex
2020-04-18 12:14:23:   + Started OK
2020-04-18 12:14:23:   + Using devfs_ruleset: 110
2020-04-18 12:14:23:   + Configuring VNET OK
2020-04-18 12:14:23:   + Using IP options: vnet
2020-04-18 12:14:26:   + Starting services OK
2020-04-18 12:14:26:   + Executing poststart OK
2020-04-18 12:14:26: devfs_ruleset:110 successfully loaded.
 
Last edited:

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
Suggestion to add the ruleset to TrueNAS Core 12 is up, so we would just need a tunable, and no longer a script. That's a QoL improvement, not a hard requirement to make hardware transcode work.

Needs votes to be considered by ixSystems. If you feel you want this, vote here: https://jira.ixsystems.com/browse/NAS-105834
 

dak180

Patron
Joined
Nov 22, 2017
Messages
308

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912

Philip Robar

Contributor
Joined
Jun 10, 2014
Messages
116
You mention business case: I haven’t yet fully figured out the business case for FreeNAS.
It's not about a business case, FreeNAS originated as an open source project, when iXsystems took it over it made a commitment to the community to keep providing/supporting the free/Free version. Besides, many companies have proven the business case for a free/Free community edition of their software.
 

kdrisc01

Cadet
Joined
Jun 9, 2020
Messages
5
- C246 - caveat board support. For example, X11SCH-F yes, X11SCM-F no. Also requires TrueNAS 12.x and hasn't been tested.

@Yorick First, thank you for all you've done in this thread! Second, how were you able to determine potential support for motherboards with C246? I'm comparing X11SCH-F and X11SCM-F specs but nothing's jumping out to me.
 

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912

rvassar

Guru
Joined
May 2, 2018
Messages
971
Has anyone taken a swing at distilling down the instructions for exposing the Intel hw acceleration to a more generic jail? I'm not so much interested in Plex transcode as I am utilizing the GPU for motion detection in Zoneminder.

The current supported Zoneminder plugin has the option to set:
DecoderHWAccelName
DecoderHWAccelDevice
 

dak180

Patron
Joined
Nov 22, 2017
Messages
308
Has anyone taken a swing at distilling down the instructions for exposing the Intel hw acceleration to a more generic jail? I'm not so much interested in Plex transcode as I am utilizing the GPU for motion detection in Zoneminder.
The instructions in this post plus whatever instructions Zoneminder has should get you there (hard to say for sure though a I do not use Zoneminder and have not seen its instructions); keep in mind that all of the hardware caveats discussed in this thread still apply so you should check that first.
 

joncy92

Explorer
Joined
Dec 5, 2019
Messages
69
Hey,

I've read through this entire thread and can't seem to get /dev/dri to show in the base FreeNAS.

I have a:
Pentium G4500
Dell mainboard Intel C236 Chip (I don't know the model number)
FreeNAS 11.3 and jail 11.3

I've configured the BIOS to boot in UEFI and iGPU is enabled. I've added these tuneables:
drm_load
i915kms_load

and the script is running at postinit
I've got /dev/drm but no joy with dri.

Any help appreciated
Thanks!
 

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
@joncy92 , let’s start with the output of “lspci” and go from there. Use code tags in this board for that output, please, it makes it a lot more readable.
 

joncy92

Explorer
Joined
Dec 5, 2019
Messages
69
@joncy92 , let’s start with the output of “lspci” and go from there. Use code tags in this board for that output, please, it makes it a lot more readable.

Thanks for the response.

lspci output:
Code:
00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Host Bridge/DRAM Registers (rev 07)
00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller (x16) (rev 07)
00:01.2 PCI bridge: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller (x4) (rev 07)
00:14.0 USB controller: Intel Corporation 100 Series/C230 Series Chipset Family USB 3.0 xHCI Controller (rev 31)
00:14.2 Signal processing controller: Intel Corporation 100 Series/C230 Series Chipset Family Thermal Subsystem (rev 31)
00:16.0 Communication controller: Intel Corporation 100 Series/C230 Series Chipset Family MEI Controller #1 (rev 31)
00:16.1 Communication controller: Intel Corporation 100 Series/C230 Series Chipset Family MEI Controller #2 (rev 31)
00:17.0 SATA controller: Intel Corporation Q170/Q150/B150/H170/H110/Z170/CM236 Chipset SATA Controller [AHCI Mode] (rev 31)
00:1c.0 PCI bridge: Intel Corporation 100 Series/C230 Series Chipset Family PCI Express Root Port #5 (rev f1)
00:1d.0 PCI bridge: Intel Corporation 100 Series/C230 Series Chipset Family PCI Express Root Port #9 (rev f1)
00:1d.2 PCI bridge: Intel Corporation 100 Series/C230 Series Chipset Family PCI Express Root Port #11 (rev f1)
00:1f.0 ISA bridge: Intel Corporation C236 Chipset LPC/eSPI Controller (rev 31)
00:1f.2 Memory controller: Intel Corporation 100 Series/C230 Series Chipset Family Power Management Controller (rev 31)
00:1f.4 SMBus: Intel Corporation 100 Series/C230 Series Chipset Family SMBus (rev 31)
03:00.0 RAID bus controller: Broadcom / LSI MegaRAID SAS-3 3108 [Invader] (rev 02)
04:00.0 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme BCM5720 2-port Gigabit Ethernet PCIe
04:00.1 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme BCM5720 2-port Gigabit Ethernet PCIe
05:00.0 PCI bridge: Renesas Technology Corp. SH7758 PCIe Switch [PS]
06:00.0 PCI bridge: Renesas Technology Corp. SH7758 PCIe Switch [PS]
07:00.0 PCI bridge: Renesas Technology Corp. SH7758 PCIe-PCI Bridge [PPB]
08:00.0 VGA compatible controller: Matrox Electronics Systems Ltd. G200eR2 (rev 01)
 

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
Okay. You are not seeing /dev/dri because there is no iGPU being presented to the OS at all. You have a Matrox display controller visible, nothing else.
Take a look at your BIOS settings and see whether you can find something that enables internal graphics on your Pentium chip. Once the BIOS enables that device, the rest might "just work".

Edited to add: The Dell R330 for example does not support the iGPU at all, see https://www.dell.com/community/Powe...egrated-Intel-GPU-on-R330-server/td-p/5082375 . It'll be helpful to know which Dell this is, there should be something silk-screened on the motherboard if you don't have it in the original case. Though, given that Dell chose not to enable iGPU support in the R330 BIOS, it is quite possible they also chose to leave it disabled in the R230 and T130 BIOS images, the other two C236 offerings I can find from Dell.
 
Last edited:

joncy92

Explorer
Joined
Dec 5, 2019
Messages
69
Okay. You are not seeing /dev/dri because there is no iGPU being presented to the OS at all. You have a Matrox display controller visible, nothing else.
Take a look at your BIOS settings and see whether you can find something that enables internal graphics on your Pentium chip. Once the BIOS enables that device, the rest might "just work".

Edited to add: The Dell R330 for example does not support the iGPU at all, see https://www.dell.com/community/Powe...egrated-Intel-GPU-on-R330-server/td-p/5082375 . It'll be helpful to know which Dell this is, there should be something silk-screened on the motherboard if you don't have it in the original case. Though, given that Dell chose not to enable iGPU support in the R330 BIOS, it is quite possible they also chose to leave it disabled in the R230 and T130 BIOS images, the other two C236 offerings I can find from Dell.

Thanks I have a Dell t130. I thought I'd put that in the first post my bad.
I couldn't find any information on google over the last couple of days about enabling the iGPU in the BIOS but I couldn't find anything about it.
There were just a few posts saying it's likely enabled since it has an intergrated display adapter, but I guess that's the Matrox controller.

Thanks for the help
 

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
Top