Unraid OBS Capture, Encoding, and Streaming Server

2021 Update

This is now deprecated due to the release of Unraid 6.9. Please use this new link instead:

Click -> https://www.spxlabs.com/blog/2021/3/20/unraid-69-obs-capture-encoding-and-streaming-server <-Click

This page will remain live for those of you who have yet to update to 6.9, best of luck to you.

Deprecated!

Finally a guide for creating a working lightweight container for a Twitch streaming and capture server using Unraid. The reason I am using Unraid is because the spare system I have already has Unraid installed as an Operating System and I do not want to just use a second dedicated pc/server because my Unraid server also provides other services. Secondly, you could just use a VM, BUT…. I wanted to be mindful of system resources. Also this was just a personal challenge I felt I needed to undertake using Unraid and oh boy, did it pay off. Lastly, special thanks to Reddit user u/Darqfallen for helping unlock the last secrets of getting this to work. It’s always DNS! Blame DNS!

You can also stream to YouTube and Twitch at the same time if you also add this into the mix.

Versions

Unraid: 6.8.3 2020-03-05

Community Apps: 2020.05.16

Linuxserver.io Nvidia plugin: 2019.06.23

Nvidia Driver Version: 440.59

Basic Diagram

Here is what the setup would basically look like. You will need to add the NDI Plugin to OBS Project on your target system, in my case I want to capture my Gaming Computer gameplay. Once you enable NDI on your gaming computer, it will automatically broadcast anything you are capturing to your local network. The docker-obs-ndi container you will be setting up will then capture that NDI output, encode it, and send it off to Twitch (in this example).

Installation

In Community Apps (CA) search for “bandi13 docker-obs”. You will need to “Click Here to Get More Results from DockerHub”

  1. Download and install the Docker Obs container by bandi13

  2. In the Docker tab edit “docker-obs”

    1. Set the Network type to custom: br0

    2. Assign it a useful IP

    3. Click the Advanced View button in the top right corner

    4. In the WebUI: section add http://[IP]:[PORT:5901]

    5. Add the port 5901 and connection type of tcp

    6. Click Done

Configure OBS Studio Container

  1. The app should start right up. Now connect to it with VNC

  2. The password is; 123456

  3. You should now be looking at the Ubuntu Desktop

  4. Right Click and in the pop up window navigate to DockerCustom > Xterm

  5. When Xterm opens type the following commands

    1. apt update
    2. apt upgrade -y
    3. Grab a beer and patiently wait for it to finish updating.

    4. apt-get install -y wget
    5. apt-get install -y avahi-daemon
    6. /etc/init.d/dbus start
    7. /etc/init.d/avahi-daemon start
  6. Note* the following is subject to change due to updates by the NDI developers.

    1. wget https://github.com/Palakis/obs-ndi/releases/download/4.9.1/libndi4_4.5.1-1_amd64.deb
    2. wget https://github.com/Palakis/obs-ndi/releases/download/4.9.1/obs-ndi_4.9.1-1_amd64.deb
    3. dpkg -i libndi4_4.5.1-1_amd64.deb
    4. dpkg -i obs-ndi_4.9.1-1_amd64.deb
  7. Verify OBS now has NDI available. Warning, after making all of these changes you must commit them to a new container image or else you will lose all of your work if the container is edited/stopped/started/restarted/rebooted/shutdown/etc.

Commit our Changes to a New Container

We have to commit our changes to a new container because our changes will not be retained if the container is restarted in anyway. If you wish to add additional software/packages, I recommend doing so before this point. Basically installing anything you think you may need for troubleshooting or graphics (see below about NVIDIA graphics pass-through).

We will be using the Web Terminal provided within the Unraid WebUI.

  1. docker ps -a
    • Either Copy or write down the CONTAINER ID for bandi13/docker-obs, we will need this for step 2.

  2. docker commit <CONTAINER ID> docker-obs-ndi
    • As an example this is what my command looked like: docker commit 7c8dca4783a4 docker-obs-ndi

  3. docker images
    • Verify our new container named docker-obs-ndi was created with the command, docker images

Adding the Container to the Docker Tab

There will not be template for us to work with or an available repository, so we will be adding the container and filling in all of the requirements for our newly created container. After following all the steps below, you will then have a template for your new container that you can use in the future.

Steps 9 - 11

Step 12-13

  1. Click Add Container

  2. Skip past Template

  3. Enter docker-obs-ndi into the Name field (you can give it a custom name if you wish)

  4. Enter docker-obs-ndi into the Repository field

  5. Network Type: Custom : br0

  6. Fixed IP Address (optional): whatever IP you want

  7. Click the “Add another Path, Port, Variable, Label or Device” link

    • Add Port

    • Name: VNC Port

    • Host Port: 5901

    • Container Port: 5901

  8. Click the Advanced View icon

    • WebUI: http://[IP]:[PORT:5901]

  9. Apply! Now you will now see docker-obs-ndi listed under Applications in the Docker Containers pane

  10. The container should start automatically but you will be unable to connect with VNC

  11. Left Click on the docker-obs-ndi in the pop up window select Console

  12. A new Web Terminal will pop up and type the following command.

    • rm -Rf /tmp/.X*
  13. Close the Web Terminal

  14. Restart docker-obs-ndi

  15. You should now be able to access the container through VNC, the password is still 123456

  16. Congratulations, you are now dead.


Performance Testing

My Unraid server has a ton of spare resources, see here for more details. For the basic gist of parts, here they are below.

Server Specs (PNAS)

Gaming Computer Specs (Truncator)

Unraid Statistics During a Stream

Here is a short 60 second gif of Unraid stats during the stream. If you want to see a longer version here is a YouTube link.

Quality of the Stream

Here is what the stream looked like, I think I was averaging about 52 FPS using CPU(x264) encoding only.

OBS Settings

Below are the settings that I set inside of the Docker-OBS-NDI container. These are not optimized settings just settings I used for testing purposes. You should optimize your settings in accordance with your hardware.

For my gaming computer, the Video Canvas, is just 1080p for the Base Canvas and the Output Scaled. Nothing to really see otherwise.



Advanced User Course

So you want to tinker around more? Maybe you want to record locally instead of stream to Twitch or your favorite service. Maybe you don’t have 32 cores to spare and would rather use that NVIDIA GPU you have laying around. Well look no further, instructions below!

Can I record locally?

Yes of course, the set up is pretty basic. Looks something like this. Feel free to adjust directories as needed.

  • In your OBS Container, change the Recording Path to something like /video

  • In Unraid make sure to add a Path for the container and host. My Container Path is /video and Host Path is /mnt/user/appdata/docker-obs-ndi/video. It can be any path you want this is just what I did for ease.

Can I use a GPU?

Yes, you can pass-through an NVIDIA gpu and it works pretty well.

  • You will need to follow the Linuxserver.io guide and the best part is, you do not need to install any drivers for the container. The Linuxserver.io NVIDIA build handles all the driver installation and other hard stuff, so for us it will just work. Thank Akatosh

  • I’d recommend installing “hwinfo” or “lshw” before passing through an NVIDIA GPU. These two packages/commands will allow you to find out information about your GPU.

    • apt-get install -y hwinfo
    • apt-get install -y lshw
  • The command line arguments for the two packages are as follows, respectively:

    • hwinfo —gfxcard —short
    • lshw -C display

I tested this with both of my GPU’s I have available. However, only the Quadro P600 is depicted. In theory the P600 should perform better than the K4000 but I personally didn’t notice any difference in quality.

OBS Settings with GPU Enabled

Unraid Web Terminal displaying the Quadro P600 in use, command= watch nvidia-smi

Just a moment in time while using the Quadro P600

Custom Logo?

Yup you bet! While editing your container, with advanced view enabled. You can add a URL path to any icon you like or a directory path to one on your flash drive. I downloaded the OBS Icon from Wikipedia and placed it in /boot/config/plugins/dockerMan/images/obsLogo.png.

Alternatively I could have just plugged in this URL for the Icon: https://upload.wikimedia.org/wikipedia/commons/thumb/d/d3/OBS_Studio_Logo.svg/1200px-OBS_Studio_Logo.svg.png


Bugs

The only bug I experienced from time to time, is failing to connect with VNC to the container. In the section “Adding the Container to the Docker Tab” steps 11 and 12 will fix the connection issue. I will update this if I ever find a permanent fix.

  • Use the Docker Terminal “Console” and type the command: rm -Rf /tmp/.X*

  • Then restart the container and you should be able to enter the password and connect

During the first install of bandi13/docker-obs do not include —shm-size=256mb -it in the Extra Parameters section during the initial install. The container will fail to execute.

  • According the creator; ”The shm-size argument is to make sure that the webclient does not run out of shared memory and crash.”

  • You may want to consider adding this later if your container crashes.

Troubleshooting

Iptables, firewall, and selinux are not configured in this container and thus any issues you may have are probably DNS related.

You can try some of the following things if you continue to experience issues with NDI Sources not appearing in your container.

Usually restarting both of these services fixes the issue immediately

  • /etc/init.d/dbus restart

  • /etc/init.d/avahi-daemon restart

If that doesn’t work consider doing the following.

  • yum install -y iputils-ping (just for troubleshooting basics)

  • yum install -y vim (to edit the configuration files inside the container)

  • Add your local DNS server to the /etc/resolv.conf

    • nameserver 192.168.1.7

  • Build out the /etc/hosts table, add a hostname and associated IP address of your gaming computer or other devices

    • truncator 192.168.1.69

Failing to Connect to the Container with VNC

  • You may need to delete the .X11 files if you fail to connect to the container after a restart or configuration change, see section “Adding the Container to the Docker Tab” the second set of steps 11 and 12. (rm -Rf /tmp/.X*)

  • There may be a method to execute a script or commands upon startup of the container but I haven’t figured that out yet.

Verify OBS and NDI Plugin are on compatible versions

This will require you to look at NDI’s website and do some reading. Sorry. General information can be found here.

Third Party Applications

List of 3rd party applications this setup does not work with. I may add more based off comments or other findings in the future.

  • NDI HX Camera - most likely a NDI compatibility issue.

  • SLOBS - To my knowledge SLOBS only receives NDI Output, as in, you can only add an incoming source not broadcast. Also, as far as I know SLOBS is not linux compatible. Such a shame. Please note I have not tested the following and it is mere speculation on my part.

    • You could get “crazy” with your set up and do OBS -> docker-obs-ndi -> nginx-rtmp-docker -> SLOBS VM -> Twitch/YouTube/Mixer/etc

    • Or maybe even OBS -> docker-obs-ndi -> SLOBS VM -> Twitch/Youtube/Mixer/etc


Conclusion

Whew, that’s all I got to say about that….



Would you like to know more?

Here is a video of me playing around with the setup but from a gaming laptop to the server.