Jump to content
  • M1GC

Private NGINX/RTMP server live-streaming using Docker & Docker Compose


M1GC
 Share

Recommended Posts

What is Docker?

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers.

Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package with the full os included so everything configured works right out the box.

Getting Started with installing Docker
Windows / Mac OSX / Linux

WINDOWS AND MAC USERS INSTALL DOCKER (STAND ALONE) :
Download & install on Windows or Mac
NOTE: With Docker Desktop you get Docker Engine, Docker CLI with Docker Compose plugin as well as other components and tools.
You can also install Docker to Virtualization Software.
Install Docker onto a VM (Virtual Machine) in VMWare Workstation (Paid) or VirtualBox (Free) or Docker (Free)

You may also use Cloud Providers Machines such as Digital Ocean, AWS, Google Cloud, Microsoft Azure or M1-Serverz to create a machine in the cloud but may be costly..
We recommend having enough CPU, Memory, & Bandwidth Resources to achieve stable streaming on the same PC.  

If you do not know how to install Ubuntu Server to VMWare WorkstationVirtualBox, & Docker,

Check the links below:

Purchase: VMWare Workstation

Download: Virtualbox

Download Docker Desktop

NOTE: DOCKER DESKTOP UPDATED THERE SUBSCRIPTION LICENSE
THIS MAY AFFECT WINDOWS USERS USING DOCKER DESKTOP.
CLICK 
HERE FOR MORE INFORMATION

Download Ubuntu Server OS Latest

GETTING STARTED


Once your Virtualization Software is installed, & you have created a VM (Virtual Machine) with the latest Ubuntu Server operating system installed on your VM

Login to your VM

INSTALL DOCKER 

curl -fsSL https://get.docker.com/ | sh


NOTE: for windows Hyper-V will be enabled via the software install.
Virtualization must be enabled via BIOS for Docker Desktop to work.

Check if docker is running & its version
ON WINDOWS Open Windows Powershell 
LINUX or MAC OSX - Use your preferred Command Line / Terminal tool on Linux or Mac OSX.

Check if dockers daemon is running

docker

Check your docker version

docker -v

What is Docker Compose?
Compose is a tool for defining and running multi-container Docker applications.
With Compose, you use a YAML file to configure your application’s services.
Then, with a single command, you create and start all the services from your configuration.

INSTALLING DOCKER COMPOSE

install Docker Compose

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

Apply executable permissions to the binary:

sudo chmod +x /usr/local/bin/docker-compose

Check your docker compose version

docker-compose -v

To install Docker Compose on other non linux bases operating systems such as Mac, Windows, Windows Server, Click Here.
NOTE: Docker Desktop will have Docker Compose Preinstalled.

Downloading and Creating your container Using docker-compose (Ubuntu Server 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

Add the code below and save

version: "3.9"
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:

NOTE: For Raspberry Pi4 Users, use Rasbpberrypi4 image. (Example: image: murderousone/nginx-ffmpeg-rtmp:ubuntu-arm64)

Check out our NGINX/RTMP Streaming Server Docker Image from Docker Hub for more information.
Docker image is a Ubuntu Server x64 and Ubuntu Server ARM x64 base os which contains all the configuration M1 created for NGINX/FFMPEG streaming using a x2 PC  Stream / Gaming setup
The docker image is also unlocked and contains pre-made bash scripts to run your streaming server even easier than our manual setup.
It will be pulled into your system with nginx/ffmpeg/rtmp streaming server preconfigured.
Docker also allows better performance and less resources to your computer / server.

# To Create, and Start the container

docker-compose up -d

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

Here's a Tutorial Video of the Install Process

Check if your RTMP Docker Container is running

docker ps -a

Attach to the Running RTMP Docker Container

docker attach nginx-rtmp-server

Execute our Bash Script to Update the server packages on the NGINX / RTMP Docker Container

./update

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

Video Example Of Editing Your Stream Keys

START THE RTMP SERVER

./start-rtmp

EXIT THE CONTAINER WHILE LEAVING IT RUNNING

HOLD: CRTL + p + q 

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 Broadcaster, vMix, Streamlabs OBS, etc)

To update the container with Docker Compose:
# Pull the latest image / update

docker-compose pull

# To Create and Start the container

docker-compose up -d

Stop containers and removes containers, networks, and images created by Docker-Compose up

docker-compose down 

NOTE:

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 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: THE IMAGE COMPLETELY TRANSPARENT / INSPECTABLE / ATTACHABLE / SIMPLE U CAN EDIT, UPDATE, INSPECT THE FULL OS / MAKE ANY CHANGES OF YOUR OWN.

docker attach nginx-rtmp-server

# To Destroy the Container 

docker-compose down

Setting up main gaming computer to stream to NGINX / RTMP

Main gaming computer

Any ol Gaming 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-obs-stream.png

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! 

  • Thanks 2
Link to comment
Share on other sites

  • M1GC changed the title to Private NGINX/RTMP server live-streaming using Docker & Docker Compose
  • M1GC featured this topic
  • M1GC locked, unlocked and pinned this topic
  • M1GC locked this topic
Guest
This topic is now closed to further replies.
 Share

  • M1GC

  • Welcome to M1GC

    tenor.gif

    We accept players of all skill levels and help members grow at their own pace.

    We are respectful, determined, and proud to be M1GC members..

  • twitch-logo.gif.6e366685b5d45bf948dad544bc71f521.gif

    Check out M1GC on Twitch

  • Sign up to Restream.io

    M1-Gaming Is Inviting you to Join Restream. The best way to stream video live to 30+ platforms simultaneously for free.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.