Skip to content

MurderousOne/nginx-rtmp-ffmpeg-docker

Repository files navigation

NGINX-based Media Streaming Server / RTMP / FFMPEG SERVER


(https://hub.docker.com/r/murderousone/nginx-ffmpeg-rtmp)

THIS DOCKER IMAGE WILL WORK WITH 64 Bit Systems.

LIGHTWEIGHT - IMAGE WILL CONTAIN REALLY SIMPLE SHELL SCRIPTS TO MAKE LIFE EASIER. NOTHING CODE SAVY


DOCKER IMAGE MAY NOT WORK WITH 32bit Systems.

Image can be attached too and is fully customizable.

Image has simple pre-installed bash scripts to make running the server easier.

Based on Ubuntu Server Latest LTS 64 Bit

Based on Ubuntu Server Latest LTS ARM64 for Raspberry Pi4 / Pi400


UPDATES FOR UBUNTU SERVER LATEST LTS

* COMPILED WITH NGINX RTMP MODULE - NGINX v1.25.4
* COMPILED WITH FFMPEG Version 6.1.1 - use image tag: ubuntu-latest
* EASY INIT SCRIPT FOR NGINX START, RESTART, STOP
* EASY SHELL EXECUTABLE SCRIPTS FOR EDITING, NGINX START, RESTART, STOP AND EASIER MANAGING YOUR RTMP SERVER
* ALL UBUNTU PACKAGES UPDATED

UPDATES FOR RASPBERRY Pi4 / Pi400

* UBUNTU SERVER LATEST LTS ARM64
* COMPILED WITH NGINX RTMP MODULE - NGINX v1.25.4
* COMPILED WITH FFMPEG 6.1.1 - use image tag: ubuntu-arm64
* EASY INIT SCRIPT FOR NGINX START, RESTART, STOP
* EASY SHELL EXECUTABLE SCRIPTS FOR EDITING, NGINX START, RESTART, STOP AND EASIER MANAGING YOUR RTMP SERVER
* ALL UBUNTU ARM64 PACKAGES UPDATED

NGINX-based Media Streaming Server Features

* RTMP Video on demand FLV/MP4, playing from local filesystem or HTTP
* Stream relay support for distributed streaming: push & pull models
* Recording streams in multiple FLVs
* H264/AAC support
* Online transcoding with FFmpeg
* HTTP callbacks (publish/play/record/update etc)
* Running external programs on certain events (exec)
* HTTP control module for recording audio/video and dropping clients
* Advanced buffering techniques to keep memory allocations at a minimum level for faster streaming and low memory footprint
* Proved to work with Wirecast, FMS, Wowza, JWPlayer, FlowPlayer, StrobeMediaPlayback, ffmpeg, avconv, rtmpdump, flvstreamer and many more
* Statistics in XML/XSL in machine- & human- readable form

ENJOY! 

NGINX-based Media Streaming Server / RTMP / FFMPEG SERVER

Docker image is a ubuntu x64 or Debian latest nginx/ffmpeg base os which contains all the configuration created for setting up a streaming server

The docker image is also unlocked and contains pre-made bash scripts to run your streaming server even easier than our manual setup.

Docker also allows better performance and less resources to your computer / server.

Install Docker on Linux

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

INSTALL DOCKER FOR OTHER NON-LINUX OS's

RUN THE DOCKER CONTAINER WITH DOCKER COMPOSE

Install Docker Compose on Linux

sudo curl -L "https://github.com/docker/compose/releases/download/v2.24.7/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

To install Docker Compose on other non-Linux OS's

Downloading and Creating your container Using docker-compose (Ubuntu Image)

Create a new Directory

mkdir nginx-rtmp

Create a Docker Compose file inside your new directory:

(example: docker-compose.yml)

Change Directory

cd nginx-rtmp

Create the docker compose file:

nano docker-compose.yml

COPY and PASTE the code below for Ubuntu OS Container and Save

version: "3.8"
services:
  nginx-rtmp-streaming-server:
    image: murderousone/nginx-ffmpeg-rtmp:ubuntu-latest
    volumes:
      - nginxconfig:/usr/local/nginx/conf/
    container_name: m1gc-nginx-rtmp-server
    restart: unless-stopped
    stdin_open: true
    tty: true
    ports:
      - "80:80"
      - "443:443"
      - "1935:1935"

volumes:
  nginxconfig:

Downloading and Creating your container Using docker-compose (Raspberry Pi4 Ubuntu Arm64 image)

Create a new Directory

mkdir nginx-rtmp

Change Directory

cd nginx-rtmp

Create the docker compose file:

nano docker-compose.yml

COPY and PASTE the code below for Raspberry Pi Ubuntu OS Container and Save

version: "3.8"
services:
  nginx-rtmp-streaming-server:
    image: murderousone/nginx-ffmpeg-rtmp:ubuntu-arm64
    volumes:
      - nginxconfig:/usr/local/nginx/conf/
    container_name: m1gc-nginx-rtmp-server
    restart: unless-stopped
    stdin_open: true
    tty: true
    ports:
      - "80:80"
      - "443:443"
      - "1935:1935"

volumes:
  nginxconfig:

To update the container with Docker Compose:

# Pull the latest image / update

docker-compose pull

# To Create, Start, Update and Restart the container

docker-compose up -d

Stop containers and removes containers, networks, and images created by up

docker-compose down 

Above docker command will pull the image, create, run and start the Docker Container / Streaming Server already configured with ports opened.

IF YOU UPDATE THE DOCKER IMAGE TO A NEW VERSION, DOCKER COMPOSE WILL RECREATE THE DOCKER CONTAINER WITH THE NEW IMAGE UPDATES.

WHEN DOCKER COMPOSE RECREATES THE DOCKER CONTAINER, ANY CONFIGS CHANGES MADE TO THE CONTAINER WILL NOT BE DELETED

VOLUMES WILL BACKUP YOUR CONTAINER NGINX CHANGES AND WILL REQUIRE A VOLUME DELETE TO GO BACK TO DEFAULTS BUT IS OPTIONAL


List and Delete Volumes

List Docker Volumes

docker volume ls

Delete Docker Volumes

docker volume rm volume_name volume_name

YOU CAN EXECUTE THE SCRIPTS FROM OUTSIDE THE CONTAINER WITHOUT ATTACHING USING DOCKER EXEC

docker exec  nginx-rtmp-server ./restart-rtmp

OR Attach to the Running RTMP Docker Container

NOTE: I LIKE TO KEEP THE IMAGE COMPLETELY TRANSPARENT / INSPECTABLE / ATTACHABLE / SIMPLE / U CAN ACCESS THE ENTIRE FILE SYSTEM IMAGE, EDIT, UPDATE, INSPECT THE FULL OS / MAKE ANY CHANGES OF YOUR OWN.

docker attach nginx-rtmp-server

To Update the server packages on the NGINX / RTMP Docker Container

./upgrade

Edit and Add your Stream Key and URL's & Set your RTMP Servers Stream Key to the RTMP Config

Stream URL / Key from Restream.io, Youtube, Twitch

(Example: - Change -> push rtmp://live.restream.io/streamkey;)

SETTING RTMP SERVERS STREAM KEY (Can be named anything, No spaces.)

(EXAMPLE: Change -> rtmp://127.0.0.1/live/YOURSTREAMKEY to rtmp://127.0.0.1/live/ANY-KEYNAME-YOU-WANT)

./edit-rtmp

If you wish to use FFMPEG


FFMPEG LOCATION:

/usr/bin/ffmpeg
/usr/share/ffmpeg
NOTE: Must be attached to container to edit.

START THE RTMP SERVER

./start-rtmp

STOP THE RTMP SERVER

./stop-rtmp

RESTART THE RTMP SERVER

./restart-rtmp

EXIT THE CONTAINER WHILE LEAVING IT RUNNING

HOLD: CRTL + p + q 

VIDEO ON HOW TO INSTALL, EDIT AND RESTART USING BASH SCRIPTS

asciicast

Check the Video Above to View How To Setup. Edit, and Restart Using The Bash Scripts Provided....

Your docker streaming server is now started and running in the background...

You can now connect to it, using your preferred streaming software. (obs studio, xsplit, vmix, streamlabs obs, etc)

Setting up main computer to stream to NGINX / RTMP / FFMPEG

Any ol PC with OBS Studio & NVENC encoding.

In OBS, i use NVENC encoding and I use my monitor’s native resolution (1080p).

Using OBS Studio, in your broadcast settings you need to use the “Custom” streaming service.

M1GC

The Streaming URL will be something like rtmp://192.168.1.100/live (Use your own server’s IP).

Your Stream Key needs to be the same you used in your nginx configuration.

(Example: KEYNAME-YOU-SET)

In the Encoding, use NVIDIA NVENC (Since it doesn’t use a lot of CPU).

Bit-rates

Click here for Live encoder best settings for bit-rates, and resolutions

You may need to reduce your bit-rate depending on services bandwidth limits.

You may need to adjust your max bit rate according to your needs and capabilities

AUDIO

As for Audio encoding, I use the AAC codec, 160 bit rate and a Format of 44 or 48 Khz.

  • RTMP Video on demand FLV/MP4, playing from local filesystem or HTTP
  • Stream relay support for distributed streaming: push & pull models
  • Recording streams in multiple FLVs
  • H264/AAC support
  • Online transcoding with FFmpeg
  • HTTP callbacks (publish/play/record/update etc)
  • Running external programs on certain events (exec)
  • HTTP control module for recording audio/video and dropping clients
  • Advanced buffering techniques to keep memory allocations at a minimum level for faster streaming and low memory footprint
  • Proved to work with Wirecast, FMS, Wowza, JWPlayer, FlowPlayer, StrobeMediaPlayback, ffmpeg, avconv, rtmpdump, flvstreamer and many more
  • Statistics in XML/XSL in machine- & human- readable form

ENJOY!

Releases

No releases published

Packages

No packages published

Languages