***[GUIDE]*** SETUP EMBY (with HW transcoding) ON UNRAID & REMOTE ACCESS THROUGH REVERSE PROXY USING SWAG


Mik3

Recommended Posts

Hi guys,

I wanted to move from plex to emby since a while for multiple reasons.


I decided to make this guide first because I want to give back something to the amazing community behind UNRAID/REDDIT/EMBY and second because I couldn't find a step by step guide so I thought it would be nice to have a lot of useful informations in a single place.
If you just want to setup the hardware transcoding using intel quick sync video in emby on unraid go directly to STEP 8.

 

I take also the opportunity to thank spaceinvaderone for the amazing videos he made about UNRAID, I learned a lot, and the linuxserver.io guys/gals for the amazing job they do supporting and maintaining the community images.

 

Note: I am not affiliated with anybody nor I get paid to do this, this shows the steps I used to setup emby on unraid so to make it easier for you to do the same. Also english is not my native language so excuse me for any syntax/grammar error.

 

Last premise before we start, if you want to add something or you think some steps needs additional informations to be clearer let me know in the comments. @Mods: if you think this guide is useful and you want to stick this post for ease of reference for the community please do so, thanks.

 

Let the fun begin...


PREREQUISITES:
------------------------------


SETUP:
------------
STEP 1 - Setting up a dynamic DNS
---------------------------------------------------------

Use your preferred dynamic dns provider to setup a custom dns tracking service.
For example:

"emby.hopto.org" where "emby" is the name you want and the rest is fixed depending on the dynamic dns provider.

Ex.: "myembysrv.hopto.org"

 


STEP 2 - CREATE A CUSTOM DOCKER NETWORK
-----------------------------------------------------------------------------

Inside the unraid web interface, open a terminal by clicking the terminal icon on the top right corner and type

docker network create cdocknet

where "cdocknet" is the name of our custom docker network. You can name it whatever you want.
Press ENTER and then a long string of random characters (network id) should appear meaning the custom network was successfully created. If there is an error message make sure you correctly typed in the command otherwise search google for the error message and fix it before moving onto the next step.
If everything is successful you can close the terminal window and proceed to the next step.


STEP 3 - Install SWAG (Secure Web Application Gateway)
------------------------------------------------------------------------------------------

Inside the unraid web interface, go to apps then in the top right corner inside the search bar search for "swag" (without quotes)
Click install and you will be redirected to the container settings.
Change the following settings:

 

Network type:                 -> Select Custom: cdocknet (or watherver name you assigned in step 2)
HTTP:                             -> Change it to 8080 or another port that is not in use either in unraid or any docker you have
HTTPS:                           -> Change it to 8443 or another port that is not in use either in unraid or any docker you have
EMAIL:                            -> Your email address
DOMAIN NAME:               -> The Dynamic DNS domain name, so if we use the one I setup in the first step it is going to be hopto.org Yours can
                                         be different. Ex.: ddns.net, duckdns.org
SUBDOMAINS:                 -> Delete the "www" and replance it with the custom name you chose in step 1, in our case emby.
ONLY SUBDOMAINS:        -> Set it to true (we tell swag to issue the cert. only for our subdomain as we don't own the top level domain
                                          be it hopto.org or whatever else you chose)

 

You can leave the rest as default. Now before clicking "APPLY" open a new tab and go to your router setting and setup a port forward to unraid for the port 80 and 443. I cannot give a specific guidance here as every router setting is different. Try to search for port forwarding [your router model] in google and read how to do it.
You should have a table/items like this. You need to setup 2 port forwarding, one for port 80 and one for port 443.

 

NAME/APPLICATION NAME/SERVICE NAME:   Swag80
IP ADDRESS:                            enter unraid ip address
PUBLIC PORT:                          enter the default HTTP port, in this case 80
PRIVATE PORT:                         enter the custom port you setup for the docker, in our case 8080
PROTOCOL:                             TCP

 

NAME/APPLICATION NAME/SERVICE NAME:   Swag443
IP ADDRESS:                            enter unraid ip address
PUBLIC PORT:                          enter the default HTTPS port, in this case 443
PRIVATE PORT:                         enter the custom port you setup for the docker, in our case 8443
PROTOCOL:                             TCP

 

After you did so go back to unraid and click apply.
Once swag is installed check the log setting to make sure everything is done without error thus a certificate is created and valid. Basically you shouldn't have any red/amber warning in the log and at the end you should see a "Server ready." message. If any red/amber shows then check the port are correctly forwarded (make sure the numbers are correct, the unraid server's ip address is correct) otherwise read what the error says and do a search to fix it.

 

 

STEP 4 - Install Emby
-----------------------------------

As before go under the apps tab in unraid to open the community applications and search for emby. You should see 3 or more emby containers, you can use the one you prefer. For our guide we use the official emby container. Click install and again you'll be redirected to the docker settings.
Change the following settings:

 

Network type:                 -> Select Custom: cdocknet (or watherver name you assigned in step 2; if you have multiple custom network                                                      make sure you use the same you setup in swag otherwise the reverse proxy won't work)
Host path 2:*                 -> Path to your media folder share. Ex.: /mnt/user0/Media

 

Then click apply and wait for the docker to be pulled.
Once it's complete you can open emby web interface by clicking on the EmbyServer icon and select "WebUI". Emby asks you to setup a username and a password. Note this one will be the admin of the server so use a strong password. Don't worry about Emby connect, this is not required at this moment so you can leave it blank. If you have one feel free to enter it.
Click next.

You can already setup the library in this part or skip and do it later. For the purpose of this guide we skip it as it's not difficult and there is plenty of documentation on emby website on how to do that.
So now you can click finish and you will have emby UI with all the libraries (if you setup any) and the possibility to access the server settings.

 

 

STEP 5 - Configure SWAG proxy-conf
------------------------------------------------------------

If you didn't change the default appdata config path in swag you will have all the config file under /mnt/user/appdata/swag.
So from unraid webui set the appdata share to export with public access type.
To do so just click on the appdatashare, then under SMB Security Settings set the following:
Export:           -> yes
Security:         -> Public
Click apply then done.
From your PC/MAC navigate to the appdata share and open the swag folder.
In windows would be "This PC-> Network -> unraid_server_name -> appdata -> swag"
Inside swag navigate to nginx and then open proxy-conf folder.
Search and open a file named emby.subdomain.conf.sample with your preferred text editor be it notepad, notepad++, gedit or whatever.
Inside this file you have to change:
"server_name emby.*" to whatever name you setup in step 1 for the dynamic dns.

Example if your dynamic dns is myembysrv.ddns.net in this line you would setup "server_name myembysrv.*" (without quotes).

The other line we have to change is the
"set $upstream_app emby" by replacing emby with the container name. If you used the official emby container and you didn't change it then you would set this up to "set $upstream_app EmbyServer". You can find the container name in unraid.

Now click save and rename the file by removing the ".sample" at the end. So the new file name will be "emby.subdomain.conf".
Go back to unraid webui, click on the swag container icon and restart the container. (This reloads the configuration files in swag like the one we just modified)

 


STEP 6 - Configure remote access on Emby
---------------------------------------------------------------------

Open emby webui by clicking on the emby docker icon in unraid, go to settings -> network.
Tick the "Allow remote connections to this emby server" now some extra settings will appear.
Scroll down till you find "Public HTTPS port number" and change it to "443"
Right below you find the "External domain:" and set this to the dynamic dns we setup in step 1. In our case is "emby.hopto.org"
Then scroll down a bit more till you find "Secure connection mode:" and change it to "Handled by reverse proxy"
Then just below it untick the "Enable automatic port mapping" and then scroll at the end of the page and click save.
Go back to unraid webui and restart emby docker.

 


STEP 7 - Test the remote connection
-----------------------------------------------------------

Open a new tab and go to "https://emby.hopto.org", of course replace this with your custom dynamic dns entry.

Ex.: "https://myembysrv.ddns.net"
You should see a "Please sign in" page with emby logo asking you for a login and password. If you see a connection timeout then you did something wrong. Go back and re-read all the steps and make sure you did everything correctly. If you see an SSL cert error/browser warning that the connection is not secure then you messed up with the ports or skipped some steps. Again re-read and make sure you did everything properly.

 


STEP 8 - Setting the HW (hardware) transcoding in Emby with intel QSV (Quick Sync Video)
--------------------------------------------------------------------------------------------------------------------------------------------------

Requirements:

  • Emby premiere
  • Intel CPU that has Quick Sync Video (search your cpu at https://ark.intel.com/content/www/us/en/ark.html#@Processors)
  • Compatible motherboards (sometimes iGPU has to be enabled in BIOS/UEFI, in some other cases you need a VGA/HDMI plugged-in to have it functional either by plugging in a monitor or by using a dummy VGA/HDMI adapter)

 

If you meet the above requirements please read on...

 

Open a terminal window in unraid (top right corner, click on the terminal icon inside the unraid webui) and type the following:

ls /dev/dri

and press ENTER
If you see something like

 by-path/   card0   renderD128

this means that the QSV is already enabled in your unraid server and you can skip to the docker setting step otherwise read on.
In the terminal window type:

modprobe i915

then press ENTER (if there is any error stop and solve this before moving on. Make sure you meet all the requirements)
Then type:

 ls /dev/dri

and press ENTER.
Now you should see something like this:

by-path/   card0   renderD128


Now type

chmod -R 777 /dev/dri

to set the permission on the folder so we can access to it from the emby docker container.

Once that's done close the terminal window, go over Emby docker container icon and click "Edit".

This will bring the container settings up like the first time we installed it.
Scroll down at the bottom and click on "+ Add another path, port, variable, label or device". A new window/popup will open.
Change the following settings:

 

Config Type          -> Device
Name                   -> /dev/dri
Value                   -> /dev/dri
Description          -> Intel Quick Sync Video

 

Then click "ADD" and the "APPLY" and after the container is pulled down again click on "DONE".


Now open emby webui, go to "Settings -> Transcoding" and make sure you have "Enable hardware acceleration when available:" set to "Yes" or "Advanced". With advanced you can see the various preferred hardware encoders/decoders emby will use and tick/untick the ones you want. Scroll to the bottom and click on "Save".

 

 

STEP 9 - Testing the hardware transcoding and make Intel QSV persistent across unraid server reboots
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

To test if the hardware trascoding is working as intended just go to your library, open a movie and select a different quality. For example you can set it to 480p - 1Mbps and click play.

If you go in your server dashboard inside emby webui settings you will see under "Active devices" the client name that is reproducing the movie and just below informations about wether it is being transcoded or not and which encoder/decoder is being used. For example if you see VAAPI (Video Acceleration Api) means the hardware transcoding is working using the intel QSV by accessing /dev/dri (Direct rendering infrastructure).

Finally last step is to go back into unraid webui, open a terminal window and edit the go file to make sure Intel QSV is always on even if we reboot the server. To do so type:

nano /boot/config/go

and press ENTER
Nano editor will open and you will see the content of the file. If you never modified it before it should be similar to:

#!/bin/bash
# Start the Management Utility
/usr/local/sbin/emhttp &

Just add the following lines to the bottom of the file

modprobe i915
chmod -R 777 /dev/dri

 

Your go file should look like this:

#!/bin/bash
# Start the Management Utility
/usr/local/sbin/emhttp &
modprobe i915
chmod -R 777 /dev/dri

Save using the CTRL + O and then CTRL + X to exit
Done!
If you read it this far I thank you for the attention and I hope you found this guide useful.
Finally you can enjoy your media on the sofa.

Edited by Mik3
  • Like 4
Link to comment
  • 1 year later...

This is excellent thanks! I had a change from the above:

Edit SWAG container, scroll down to Subdomains, add the subdomain from step 1 into the list. Restart SWAG.

 

For getting SWAG setup, the video/instructions from Spacedinvader are excellent.

 

I've got an AMD CPU and motherboard, and NVIDIA GeForce GTX 750 Ti, so these hardware transcoding steps didn't work.

 

Nice write up thanks!!!

Link to comment

@dkerlee Thank you for the nice comments.

 

Regarding your hardware may I suggest to have a look at the NVIDIA driver plugin (coomunity apps) from the amazing @ich777. This is a link to the forum post https://forums.unraid.net/topic/98978-plugin-nvidia-driver/

 

This allows you to use the nvidia driver into the docker container. Just follow the instructions, then use emby settings to use the gpu for transcoding and you shouldn't have any issue. Let me/us know how it goes and if you had to take any particular steps to make it working so other can benefit as well.

  • Like 1
Link to comment
33 minutes ago, Mik3 said:

Just follow the instructions

You know if you install the plugin Intel-GPU-TOP you don't have to edit the go file because it enables it on boot and the plugin also enables you to install the GPU Statistics plugin so that you can see the status from your iGPU on your unRAID Dashboard.

Link to comment
34 minutes ago, ich777 said:

You know if you install the plugin Intel-GPU-TOP you don't have to edit the go file because it enables it on boot and the plugin also enables you to install the GPU Statistics plugin so that you can see the status from your iGPU on your unRAID Dashboard.

Thanks for your reply. The plugin came out after I wrote this guide. When I have the time I'll edit/write a new one with the updated steps.

 

With the phrase "Just follow the instructions" I was referring to follow the topic you wrote for the NVIDIA driver as the guy is using AMD+NVIDIA so Intel-GPU-TOP is NOT applicable.

  • Like 2
Link to comment

The directions are a little different for nVidia GPUs for sure. Let's see how much of this I can remember:

  • the binhex-emby docker didn't work with hardware encoding. I ended up using linuxserver.io emby
  • There are two spaceinvader videos, I used both:
  • https://www.youtube.com/watch?v=VkC5Hi-rO2c&t=13m41s 3/2/21, Ed goes a bit off the rails here with an nVidia commercial; but he's also chosen to detail the process for "unlocking" consumer nVidia GPUs for multiple encoding threads, which I also did. I left a time-code in the URL to get to the meat and potatoes. The docker he uses here (linuxserver.io emby) has also been changed. I had to Remove the raspberryPi encoding items, they were giving me errors.
  • https://www.youtube.com/watch?v=GOhHiFAXwOE&t=6m14s 2/12/19, also helpful. Here he goes into the Advanced tab of the docker, adds three items (extra parameters, and two variables), all of which I had to add to get it all working
  • nVidia drivers shows up in Apps, but then lives inside Settings rather than a Docker. It's the ich777 nvidia driver package.
  • added GPU 
  • getting SWAG passthrough working for a docker, Ed's nextcloud video is good https://youtu.be/id4GcVZ5qBA?t=830 
     
  • As I recall there:
  • I had to put the name of the docker into the conf file, "emby" (ya know, that might be the default now that I think about it)
  • I created a subdomain CNAME in my webhost, emby.mysite.com
  • added the subdomain, "emby" to the subdomains to pass through on SWAG container Edit. I'll slap a pic of my docker settings in here. You can't see the linuxserver name, but that's what it is, the Rpi stuff is gone, and the two Variables are at the bottom, cribbed from Spaceinvader video up top.
  • I installed GPU Statistics, that's been nice to have. It doesn't entirely work with emby (no icon for "active applications") but it does have threads and usage and it's right there on the main page where things like that should be.

 

The reason I've been through this Emby stuff is because Plex totally stopped Sync'ing for me. I switched to an iPhone, that may have something to do with it. Plex removed the old Sync option, and came out with their new version, which was wonky at the beginning, then totally stopped working. I don't have too much to complain about, I bought the lifetime pass about five years ago, and I think I've more than gotten my value out of it.

 

I've also used Plex to share my library with family - I think the pricing scheme for Emby won't allow me to get away with that as affordably as Plex has. I think each user needs a premium membership to sync. For parents: you want sync for car and airplane trips, fer sure.

 

 

 

 

proxynet.png

Edited by dkerlee
  • Like 1
Link to comment
  • 4 months later...

The Nvidia_Driver_Capabilites and the Nvidia_Visable_Devices are no longer included in the docker container.  I understand I need the extra variable of --runtime=nvidia, but where do I put my GPU ID  if the two Nvida fields are no longer included in the Docker?  There is a field where it wants me to map a location of dev/dri I tried inserting my gpu id here, but the installation fails.

 

 

Link to comment

@Grant123 You can always add extra parameter in the docker by using the appropriate menù. It's at the end of the page. Also consider that some stuff have changed with the latest release since I wrote this guide. I am quite busy at moment, whenever I'll find the time I'll try to update this guide with the latest infos.

Link to comment
  • 7 months later...

thank you @rutherford

your guide is clear and concise but don't believe it's working for me.

My Emby (Premiere), is not showing hardware encoding. If I change my transcoding to Advanced, there are no hardware encoders, and in GPU Stats, i have zero processes.

 

Did you have to do anything special other than the --runtime=nvidia, and the two variables ? Your screenshot has them as Host Keys, his video had them as Variables.

 

Ta

Link to comment

@rutherford
Thanks for your very quick response.
Are you using the same set up for Plex to? I'm trying it there with the same settings, as seen in my screenshot, but it's not working there either. Which kind of gives me hope I can get it working for Emby, just need to figure out the bigger issue.

Thank you in advance.

1546173031_Screenshot2023-03-01103436.thumb.png.4dca53584e7bc931f213a902a4712c81.png

Link to comment

Yeah, mine looks the same as yours. ???

have you tried several different episodes? Sometimes the encoding that’s used for specific episodes doesn’t fly with our gpu. I think it’s something like the NVEC or color depth I think? I have noticed that several episodes go over to the cpu for encoding, but most are the (hw) in there. And you want to make sure on your test player, you turn down the kbps for the stream, and double check that’s what you’re seeing, the lower kbps version. 
sorry I can’t be of more help!

9BEDDD27-71D8-4ED3-AAF4-4D9E5A7C0237.jpeg

90ADA984-B661-47B1-A021-F5A0B6D33C94.png

167D8264-6C5D-4D89-BDB7-15737F9F35D3.jpeg

Link to comment

Holy crap, I've got it working with Emby!

 

Couldn't get it working with Plex. I'd change the video encode and watch the Processes on the unRAID dashboard change to one, then immediately see it revert to zero, and the stream hang. By that account, it proved my hardware was being recognised.

Then I noticed you @rutherford set the values differently to how Space Invader sets them in his video. He only does the Name, Description, and Value. Whilst you added Key and Default Value.

I went back to my linux distro of Emby and added them. Voila. Working like a treat.

What’s more than that, I just fired it up with the binhex distro and it’s working there too.

 

Below is a screenshot of my settings if anyone else is wanting to get it working in Emby.

 

640693262_Screenshot2023-03-01122602.thumb.png.a1f64a04a3636a1795d28694a04cee82.png

  • Upvote 1
Link to comment
  • 8 months later...

So I have setup Emby and I see the Intel encoder when I do the command listed in the tutorial. I also setup the source in the docker setup but in Emby it does not see any transcoder when I select advanced to view them. I have a premier sub active with Emby.
Any idea why I am not seeing and transcoders? When I play a video I also see the cpu spike which also indicates it is using the cpu and not the Intel transcoder. I have an Intel i12600k.

Link to comment
On 11/19/2023 at 12:17 PM, crowdx42 said:

So I have setup Emby and I see the Intel encoder when I do the command listed in the tutorial. I also setup the source in the docker setup but in Emby it does not see any transcoder when I select advanced to view them. I have a premier sub active with Emby.
Any idea why I am not seeing and transcoders? When I play a video I also see the cpu spike which also indicates it is using the cpu and not the Intel transcoder. I have an Intel i12600k.

An update to my issue above. I was using Binhex version of Emby, I moved to the straight Emby version and Hardware Acceleration now works. So it seems it is broken in the Binhex version.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.