- Newest
- Most votes
- Most comments
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
- AWS EC2 for OBS and NGINX: Use an EC2 instance to host OBS and NGINX with RTMP.
- AWS S3 and CloudFront for Distribution: Use S3 and CloudFront to serve the streams if you want to scale.
- Remote Access: Access OBS remotely using a WebSocket server or similar setup.
- Cost Management: Choose cost-effective instance types and use spot instances if suitable.
Step-by-Step Setup
Step 1: Set Up an EC2 Instance
- 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).
- 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
- 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;
}
}
}
- 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
- Install OBS WebSocket Plugin:
- Download and install the OBS WebSocket plugin to allow remote control.
sudo apt install obs-websocket
- Configure OBS WebSocket:
- Open OBS and configure the WebSocket settings (port and authentication).
- Set Up Remote Control:
- Use an iOS app that supports OBS WebSocket to control OBS remotely.
Step 3: Streaming Setup
- 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.
- Start Streaming:
- Start streaming from OBS on your local machine to the EC2 instance.
Step 4: Optimize for Cost and Performance
- Instance Type:
- Use a burstable performance instance (e.g., t3.medium) for cost-effectiveness.
- Consider spot instances for further cost savings.
- 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.
- 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:
- 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.
- 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
- 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.
- Create a MediaPackage Channel:
- Go to AWS MediaPackage.
- Create a channel and endpoints for HLS or DASH.
- Stream to MediaLive:
- Configure OBS to stream to the MediaLive RTMP endpoint.
- 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.
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
Relevant content
asked 4 years ago
asked 7 years ago
asked 4 years ago
