Automate NDI Discovery Deployment in AWS

I will show you how to automatically deploy the base for any NDI production environment in AWS, the humble NDI discovery server.

Let's face it, manually, setting up resources in AWS can be time consuming and unnecessary. In this article, I will show you how to automatically deploy the base for any NDI production environment in AWS, the humble NDI discovery server.

What is NDI discovery?

NDI discovery simply allows for the registration of NDI sources on any network, allowing receiving machines to get a published list of all sources available along with their IP address and port number. NDI typically uses the bonjour service (or mDNS) to automatically discover sources. This protocol relies on multicast, which is not easy to set up in a cloud environment. Because of this, the easiest way to make NDI video available is to use the discovery service.

Using the following procedure, we will create an EC2 instance, add some use your data to run and download the NDI discovery service at startup, and then register it as a system service with auto-restart enabled. This will make deployments incredibly easy, with only one line of code to maintain: the download location for the NDI Linux SDK. As new tech releases new versions it's very likely this location will change.

Let's dive into the good stuff.

Launch a New EC2 Image with the Following Parameters:

AMI: Ubuntu Server 2204

Architecture: 64bit(x86)

Instance Type: t2.small or t2.medium

Key Pair: select a key pair or create a new one

Subnet: Place in the same subnet as your NDI receiving instances

Auto-Assign Public IP: Enable (you’ll need this to download the SDK. You can go back and disable it later)

Security Group: Create a new Security Group with TCP Port 5959 allowed inbound, all traffic allowed outbound.

Storage: 8GB gp3

Then open “Advanced Details” and scroll all the way down to “User Data.” This is where the magic happens.

Paste the code below into the box.


Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0

--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"

#cloud-config
cloud_final_modules:
- [scripts-user, always]

--//
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"

#!/bin/bash
export PAGER=cat

if [ ! -f "Install_NDI_SDK_v5_Linux.tar.gz" ]; then
   sudo wget https://downloads.ndi.tv/SDK/NDI_SDK_Linux/Install_NDI_SDK_v5_Linux.tar.gz
fi

if [ ! -f "Install_NDI_SDK_v5_Linux.sh" ]; then
  sudo tar -xvf Install_NDI_SDK_v5_Linux.tar.gz
fi

if [ ! -f "/NDI SDK for Linux/bin/x86_64-linux-gnu/ndi-directory-service" ]; then
  echo "y" | ./Install_NDI_SDK_v5_Linux.sh
fi

# Check if the systemd service unit file exists
if [ ! -f "/etc/systemd/system/ndi-directory-service.service" ]; then
  # Create the systemd service unit file if it doesn't exist
  sudo tee /etc/systemd/system/ndi-directory-service.service > /dev/null << EOF
    [Unit]
    Description=NDI Directory Service
    After=network.target

    [Service]
    Type=simple
    ExecStart="/NDI SDK for Linux/bin/x86_64-linux-gnu/ndi-directory-service"
    Restart=on-failure
    RestartSec=5

    [Install]
    WantedBy=multi-user.target
    EOF

  # Reload systemd to detect the new service unit file
  sudo systemctl daemon-reload

else
  echo "The systemd service unit file already exists. Skipping creation."
fi

# Enable and start the systemd service
sudo systemctl enable ndi-directory-service
sudo systemctl start ndi-directory-service

That’s it. Now start your instance, and, magic! You have a fresh NDI discovery server when you launch the instance.

Open NDI Access Manager on all the receiving devices and point your machines to the private IP of the discovery server instances.

Subscribe to Cloud Studio Masters newsletter and stay updated.

Don't miss anything. Get all the latest posts delivered straight to your inbox. It's free!
Great! Check your inbox and click the link to confirm your subscription.
Error! Please enter a valid email address!