Skip to content

How Do I setup Media Servers with OBS?

0

I have been streaming many years by RTMP direct into my house IP/ddns which hosts an NGINX server. I ingest that stream with OBS then remotely start obs using a websockets connected iOS app. I have recently moved to a new location where I don't have full access to the networking and would like to setup a custom streaming server that can do the same.

I have tried setting up a windows machine that I can stream into and keep online for the same purpose through AWS but it did not seem cost effective for what I needed. I also tried setting up other nginx servers and containers, as well as taking the time to play around with some of the media services available.

I'm not sure what the best solution is, but I would like your opinion on the best way to go about this and still keep it cost-effective to leave always active so whenever I start a stream, it just goes online on its own. I need the ability to access obs remotely to configure it as well as have the processing power to handle incoming/outgoing streams. the ability to leave other bots running as well such as lumia and or streamerbot is a plus.

Generally they will be 1080p @30 and sometimes @60. bitrate generally kept 5000-7000.

Another option would have AWS just handle the media and i still ingest that internally in my home and stream out from OBS there. would probably work better than me sending the stream into the house then also outgoing.

asked 2 years ago1.4K views

2 Answers
0

To set up a cost-effective and reliable media server for streaming with OBS, leveraging AWS services can be a viable solution. Here’s a detailed plan to achieve this:

Solution Overview

  1. AWS EC2 for OBS and NGINX: Use an EC2 instance to host OBS and NGINX with RTMP.
  2. AWS S3 and CloudFront for Distribution: Use S3 and CloudFront to serve the streams if you want to scale.
  3. Remote Access: Access OBS remotely using a WebSocket server or similar setup.
  4. Cost Management: Choose cost-effective instance types and use spot instances if suitable.

Step-by-Step Setup

Step 1: Set Up an EC2 Instance

  1. Launch an EC2 Instance:
  • Go to the EC2 Dashboard.
  • Click on "Launch Instance".
  • Choose an instance type based on your requirements (t3.medium or t3.large for a balance of cost and performance).
  • Configure instance details, add storage (EBS), and configure security groups to allow SSH (port 22) and RTMP (port 1935).
  1. Install Required Software:
  • Connect to your instance using SSH.
  • Update the instance and install NGINX with RTMP module.
sudo apt update
sudo apt install nginx
sudo apt install libnginx-mod-rtmp
  1. Configure NGINX for RTMP:
  • Edit the NGINX configuration file to add RTMP settings.
sudo nano /etc/nginx/nginx.conf
  • Add the following RTMP configuration:
rtmp {
    server {
        listen 1935;
        chunk_size 4096;

        application live {
            live on;
            record off;
        }
    }
}
  1. Install OBS:
  • Install OBS on the EC2 instance. This might require adding a repository and installing OBS using a package manager.
sudo apt install ffmpeg
sudo add-apt-repository ppa:obsproject/obs-studio
sudo apt update
sudo apt install obs-studio

Step 2: Configure Remote Access to OBS

  1. Install OBS WebSocket Plugin:
  • Download and install the OBS WebSocket plugin to allow remote control.
sudo apt install obs-websocket
  1. Configure OBS WebSocket:
  • Open OBS and configure the WebSocket settings (port and authentication).
  1. Set Up Remote Control:
  • Use an iOS app that supports OBS WebSocket to control OBS remotely.

Step 3: Streaming Setup

  1. Set Up OBS for Streaming:
  • Open OBS and set up the streaming settings to stream to the NGINX RTMP server.
  • Use the RTMP URL rtmp://<your-ec2-public-ip>/live.
  1. Start Streaming:
  • Start streaming from OBS on your local machine to the EC2 instance.

Step 4: Optimize for Cost and Performance

  1. Instance Type:
  • Use a burstable performance instance (e.g., t3.medium) for cost-effectiveness.
  • Consider spot instances for further cost savings.
  1. Storage and Bandwidth:
  • Monitor storage and bandwidth usage. Use CloudWatch to set up alarms for high usage.
  • Consider using S3 for storing stream recordings if needed.
  1. Auto-scaling:
  • If you expect varying traffic, set up auto-scaling groups to handle peak loads.

Alternative: AWS Media Services

If you want AWS to handle the media streaming:

  1. AWS MediaLive and MediaPackage:
  • Use AWS MediaLive to ingest and process live video streams.
  • Use AWS MediaPackage to prepare and protect your video for delivery.
  1. Workflow:
  • Stream from OBS to AWS MediaLive.
  • MediaLive processes the stream and sends it to MediaPackage.
  • MediaPackage delivers the stream via CloudFront.

Example AWS MediaLive Setup

  1. Create a MediaLive Channel:
  • Go to AWS MediaLive.
  • Create an input for your stream (RTMP).
  • Create a channel and configure it to use the input and output to MediaPackage.
  1. Create a MediaPackage Channel:
  • Go to AWS MediaPackage.
  • Create a channel and endpoints for HLS or DASH.
  1. Stream to MediaLive:
  • Configure OBS to stream to the MediaLive RTMP endpoint.
  1. Distribute via CloudFront:
  • Set up a CloudFront distribution for the MediaPackage endpoints.

Conclusion

Setting up a media server on AWS can provide flexibility and scalability for your streaming needs. Using an EC2 instance for NGINX and OBS offers a cost-effective solution, while AWS MediaLive and MediaPackage provide a more managed and scalable approach. Choose the setup that best fits your requirements and budget.

EXPERT

answered 2 years ago

0

Disclosure: I work at Ant Media, so I have an interest in one of the options below. The cost reasoning applies to any of them.

Reading your question again, I think the existing answer solved a different problem. You already have OBS where you want it. What you lost in the move is the always-on box in the middle. Do not put OBS on EC2 to get that back, and your own last paragraph is the right instinct: let AWS handle the media, keep OBS local.

Why the Windows attempt was not cost-effective

It was almost certainly not the compute. Two things were:

Windows licensing on EC2 is baked into the hourly rate and roughly doubles a small instance compared to Linux. A media server does not need Windows.

Data transfer out. This is the one that surprises people, and it will dominate your bill. AWS egress runs about $0.09/GB after the free tier. At 6 Mbps, one viewer for one hour is about 2.7 GB, so about 24 cents per viewer-hour. Ten viewers watching a three-hour stream is around $7 in bandwidth. Your 1080p60 at 7000 is worse. Always size the bandwidth before the instance, because the instance is the small number.

What I would actually build

Keep OBS at home. Put a Linux media server on EC2 that receives your stream and redistributes it. For a single 1080p ingest plus a handful of viewers a c5.large or t3.medium is enough. Attach an Elastic IP so the address survives a reboot, and leave it running so your "it just goes online on its own" requirement is satisfied with no orchestration at all.

nginx-rtmp will do this and you already know it. Worth knowing its limits before you rebuild what you had: it is effectively unmaintained, it has no admin interface, and it cannot do AV1 or HEVC because those need Enhanced RTMP.

On remote control of OBS

obs-websocket 5 has authentication, but do not expose port 4455 to the open internet. Put it behind a WireGuard tunnel or an SSH tunnel and point your iOS app at the tunnel. Same for the bots: Lumia and Streamer.bot belong on the machine OBS is on, not on the media server. Keep the server doing one job.

If you want the delay gone while you are rebuilding

Your old setup had two to five seconds of RTMP delay in it. If you are starting fresh anyway, OBS has had WHIP built in since version 30. Same Settings then Stream page, pick WHIP instead of RTMP, paste an HTTP endpoint instead of an rtmp:// one, and glass to glass drops to under half a second. One field changed; nothing else about your workflow moves.

The one thing nobody tells you: WHIP signalling goes over HTTP but the media goes over UDP. If your security group only opens the TCP ports, OBS will report that it is streaming happily and nothing will arrive. Open UDP 50000 to 60000.

Full walkthrough on EC2 if it is useful, including the security group: https://antmedia.io/whip-server-aws/

Let me know if you need any help.

Thank you

answered 8 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.