Thanks to visit codestin.com
Credit goes to github.com

Skip to content

amad3i/rmtp-middleware

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RTMP Middleware

A powerful RTMP middleware solution with a modern web interface for managing streaming destinations and monitoring live streams.

Features

  • RTMP Server: Nginx-based RTMP server for receiving streams
  • Stream Forwarding: Forward streams to multiple destinations (Twitch, YouTube, etc.)
  • Web Interface: Modern React/Next.js dashboard for management
  • Real-time Monitoring: Live stream statistics and viewer counts
  • HLS Output: Automatic HLS transcoding for web playback
  • Docker Ready: Fully containerized solution

Quick Start

Using Docker Compose (Recommended)

  1. Clone this repository:
git clone <repository-url>
cd rtmp-middleware
  1. Copy the environment file:
cp env.example .env
  1. Start the services:
docker-compose up -d
  1. Access the web interface via Nginx at http://localhost:8081 (configurable via NGINX_PORT)
  2. Optional: access Next.js directly at http://localhost:3343 and API directly at http://localhost:8343

Development Setup

  1. Install dependencies:
bun install
  1. Start the development server:
bun dev
  1. In another terminal, start the API server:
node api-server.js

Usage

Connecting Streaming Software

Configure your streaming software (OBS, FFmpeg, etc.) with:

  • RTMP URL: rtmp://localhost:1935/live
  • Stream Key: Any unique identifier (e.g., mystream)

Managing Destinations

  1. Open the web interface at http://localhost:8081
  2. Navigate to the "Destinations" tab
  3. Add streaming destinations (Twitch, YouTube, etc.)
  4. Toggle destinations on/off as needed

Monitoring Streams

  • Live Streams: View active streams and viewer counts
  • Statistics: Monitor bandwidth usage and performance
  • Real-time Updates: Dashboard updates every 5 seconds

Streaming URLs

For Streamers (Input)

rtmp://localhost:${RTMP_HOST_PORT:-1935}/live/YOUR_STREAM_KEY

For Viewers (Output)

# HLS Playback (via Nginx on host)
http://localhost:8081/hls/YOUR_STREAM_KEY.m3u8

# DASH Playback (via Nginx on host)
http://localhost:8081/dash/YOUR_STREAM_KEY.mpd

# Direct RTMP (for restreaming)
rtmp://localhost:${RTMP_HOST_PORT:-1935}/live/YOUR_STREAM_KEY

API Endpoints

  • GET /api/destinations - List all destinations
  • POST /api/destinations - Add new destination
  • PUT /api/destinations/:id - Update destination
  • DELETE /api/destinations/:id - Delete destination
  • GET /api/streams - List active streams
  • GET /api/stats - Get stream statistics
  • GET /api/health - Server health check

Docker Services

  • rtmp-middleware: Main container with nginx-rtmp, Next.js app, and API server
  • redis: Session storage and caching

Ports

  • 1935 (host 1935 -> container 1935): RTMP input port
  • 3343 (host 3343 -> container 3000): Direct Next.js web interface (optional)
  • 8343 (host 8343 -> container 8080): Direct API server (optional)
  • 8081 (host 8081 -> container 80): Nginx HTTP (HLS/DASH and web proxy)
  • 6379 (host 6379 -> container 6379): Redis

Configuration

Edit nginx.conf to customize RTMP server settings:

  • Chunk size
  • Connection limits
  • Recording settings
  • Security restrictions

Troubleshooting

Stream Not Appearing

  1. Check if the RTMP URL and stream key are correct
  2. Verify firewall settings for port 1935
  3. Check container logs: docker-compose logs rtmp-middleware

Web Interface Not Loading

  1. Ensure port 8081 (Nginx) or 3343 (Next direct) is not in use
  2. Check if all services are running: docker-compose ps
  3. Verify API connectivity via Nginx: curl http://localhost:8081/api/health (or direct: curl http://localhost:8343/api/health)

Destinations Not Working

  1. Verify destination RTMP URLs are correct
  2. Check if stream keys are properly configured
  3. Monitor nginx logs for push errors

Development

Adding Features

  1. API changes: Edit api-server.js
  2. UI changes: Edit files in src/
  3. RTMP config: Edit nginx.conf

Building for Production

# Build Next.js app
bun run build

# Build Docker image
docker build -t rtmp-middleware .

# Run with docker-compose
docker-compose up -d

License

MIT License - see LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 81.5%
  • JavaScript 11.7%
  • Dockerfile 2.1%
  • CSS 1.8%
  • Shell 1.7%
  • Batchfile 1.2%