Convert Figma logo to code with AI

tiangolo logonginx-rtmp-docker

Docker image with Nginx using the nginx-rtmp-module module for live multimedia (video) streaming.

1,087
366
1,087
2

Top Related Projects

NGINX-based Media Streaming Server

25,280

SRS is a simple, high-efficiency, real-time media server supporting RTMP, WebRTC, HLS, HTTP-FLV, HTTP-TS, SRT, MPEG-DASH, and GB28181.

Quick Overview

The tiangolo/nginx-rtmp-docker repository provides a Docker image that runs the NGINX web server with the RTMP (Real-Time Messaging Protocol) module, which enables live streaming capabilities. This image can be used to set up a simple and efficient live streaming server using Docker.

Pros

  • Simplifies Live Streaming Setup: The Docker image abstracts away the complexity of setting up and configuring an NGINX server with the RTMP module, making it easier to deploy a live streaming solution.
  • Cross-Platform Compatibility: The Docker image can be run on various platforms, including Windows, macOS, and Linux, making it a versatile solution.
  • Scalability: The Docker-based approach allows for easy scaling of the live streaming infrastructure by running multiple instances of the NGINX-RTMP server.
  • Customization Flexibility: The Dockerfile provides a starting point for further customization, allowing users to extend the image with additional features or configurations.

Cons

  • Limited Documentation: The repository's documentation could be more comprehensive, making it challenging for newcomers to understand the full capabilities and configuration options of the NGINX-RTMP server.
  • Dependency on Docker: Users who are not familiar with Docker or prefer a more traditional deployment approach may find the Docker-based nature of the project a limitation.
  • Potential Performance Overhead: Running the NGINX-RTMP server within a Docker container may introduce some performance overhead compared to a native installation, depending on the specific use case and hardware resources.
  • Limited Community Support: The project has a relatively small community, which may result in slower response times for issues or feature requests.

Getting Started

To get started with the tiangolo/nginx-rtmp-docker project, follow these steps:

  1. Ensure that you have Docker installed on your system.

  2. Pull the Docker image from the Docker Hub:

    docker pull tiangolo/nginx-rtmp
    
  3. Run the Docker container with the following command:

    docker run -d --name nginx-rtmp -p 1935:1935 -p 8080:80 tiangolo/nginx-rtmp
    

    This command will start the NGINX-RTMP server and expose the RTMP port (1935) and the HTTP port (8080).

  4. To test the live streaming functionality, you can use a tool like OBS Studio to connect to the RTMP server and start streaming. The RTMP URL would be rtmp://localhost:1935/live/stream.

  5. To view the live stream, you can access the web interface at http://localhost:8080/. This will display the active streams and provide a player to view the live stream.

  6. If you need to customize the NGINX configuration or add additional features, you can create a new Docker image based on the tiangolo/nginx-rtmp image and modify the configuration files accordingly.

Competitor Comparisons

NGINX-based Media Streaming Server

Pros of nginx-rtmp-module

  • More flexible and customizable as it's a module rather than a full Docker image
  • Can be integrated into existing Nginx setups more easily
  • Potentially lighter weight as it doesn't include Docker overhead

Cons of nginx-rtmp-module

  • Requires more setup and configuration compared to the ready-to-use Docker image
  • May need additional dependencies to be installed manually
  • Less portable across different environments

Code Comparison

nginx-rtmp-module configuration:

rtmp {
    server {
        listen 1935;
        application live {
            live on;
        }
    }
}

nginx-rtmp-docker Dockerfile:

FROM alpine:3.11
RUN apk add --no-cache nginx-mod-rtmp
EXPOSE 1935
CMD ["nginx", "-g", "daemon off;"]

The nginx-rtmp-module provides more granular control over the RTMP configuration, while nginx-rtmp-docker offers a pre-configured Docker image for quick deployment. The module requires manual integration into an existing Nginx setup, whereas the Docker image is ready to run with minimal configuration. Both approaches have their merits, with nginx-rtmp-module offering more flexibility and nginx-rtmp-docker providing easier deployment and portability.

25,280

SRS is a simple, high-efficiency, real-time media server supporting RTMP, WebRTC, HLS, HTTP-FLV, HTTP-TS, SRT, MPEG-DASH, and GB28181.

Pros of SRS

  • More comprehensive streaming solution with support for multiple protocols (RTMP, HLS, WebRTC, etc.)
  • Active development and regular updates
  • Extensive documentation and community support

Cons of SRS

  • More complex setup and configuration compared to nginx-rtmp-docker
  • Larger resource footprint due to additional features

Code Comparison

SRS configuration example:

listen              1935;
max_connections     1000;
srs_log_tank        file;
srs_log_file        ./objs/srs.log;
http_server {
    enabled         on;
    listen          8080;
}

nginx-rtmp-docker configuration example:

rtmp {
    server {
        listen 1935;
        chunk_size 4096;
        application live {
            live on;
            record off;
        }
    }
}

Both projects provide Docker-based solutions for streaming, but SRS offers a more feature-rich platform with broader protocol support. nginx-rtmp-docker is simpler and easier to set up for basic RTMP streaming needs. SRS may be preferred for larger-scale or more complex streaming scenarios, while nginx-rtmp-docker is suitable for simpler use cases or those already familiar with Nginx configuration.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Deploy

Supported tags and respective Dockerfile links

Note: Note: There are tags for each build date. If you need to "pin" the Docker image version you use, you can select one of those tags. E.g. tiangolo/nginx-rtmp:latest-2020-08-16.

nginx-rtmp

Docker image with Nginx using the nginx-rtmp-module module for live multimedia (video) streaming.

Description

This Docker image can be used to create an RTMP server for multimedia / video streaming using Nginx and nginx-rtmp-module, built from the current latest sources (Nginx 1.15.0 and nginx-rtmp-module 1.2.1).

This was inspired by other similar previous images from dvdgiessen, jasonrivers, aevumdecessus and by an OBS Studio post.

The main purpose (and test case) to build it was to allow streaming from OBS Studio to different clients at the same time.

GitHub repo: https://github.com/tiangolo/nginx-rtmp-docker

Docker Hub image: https://hub.docker.com/r/tiangolo/nginx-rtmp/

Details

How to use

  • For the simplest case, just run a container with this image:
docker run -d -p 1935:1935 --name nginx-rtmp tiangolo/nginx-rtmp

How to test with OBS Studio and VLC

  • Run a container with the command above

  • Open OBS Studio

  • Click the "Settings" button

  • Go to the "Stream" section

  • In "Stream Type" select "Custom Streaming Server"

  • In the "URL" enter the rtmp://<ip_of_host>/live replacing <ip_of_host> with the IP of the host in which the container is running. For example: rtmp://192.168.0.30/live

  • In the "Stream key" use a "key" that will be used later in the client URL to display that specific stream. For example: test

  • Click the "OK" button

  • In the section "Sources" click the "Add" button (+) and select a source (for example "Screen Capture") and configure it as you need

  • Click the "Start Streaming" button

  • Open a VLC player (it also works in Raspberry Pi using omxplayer)

  • Click in the "Media" menu

  • Click in "Open Network Stream"

  • Enter the URL from above as rtmp://<ip_of_host>/live/<key> replacing <ip_of_host> with the IP of the host in which the container is running and <key> with the key you created in OBS Studio. For example: rtmp://192.168.0.30/live/test

  • Click "Play"

  • Now VLC should start playing whatever you are transmitting from OBS Studio

Debugging

If something is not working you can check the logs of the container with:

docker logs nginx-rtmp

Extending

If you need to modify the configurations you can create a file nginx.conf and replace the one in this image using a Dockerfile that is based on the image, for example:

FROM tiangolo/nginx-rtmp

COPY nginx.conf /etc/nginx/nginx.conf

The current nginx.conf contains:

worker_processes auto;
rtmp_auto_push on;
events {}
rtmp {
    server {
        listen 1935;
        listen [::]:1935 ipv6only=on;

        application live {
            live on;
            record off;
        }
    }
}

You can start from it and modify it as you need. Here's the documentation related to nginx-rtmp-module.

Technical details

  • This image is built from the same base official images that most of the other official images, as Python, Node, Postgres, Nginx itself, etc. Specifically, buildpack-deps which is in turn based on debian. So, if you have any other image locally you probably have the base image layers already downloaded.

  • It is built from the official sources of Nginx and nginx-rtmp-module without adding anything else. (Surprisingly, most of the available images that include nginx-rtmp-module are made from different sources, old versions or add several other components).

  • It has a simple default configuration that should allow you to send one or more streams to it and have several clients receiving multiple copies of those streams simultaneously. (It includes rtmp_auto_push and an automatic number of worker processes).

Release Notes

Latest Changes

Internal

  • 👷 Update issue-manager.yml. PR #95 by @tiangolo.
  • ⬆ Bump docker/build-push-action from 5 to 6. PR #92 by @dependabot[bot].
  • 👷 Update latest-changes GitHub Action. PR #93 by @tiangolo.
  • ⬆ Bump docker/build-push-action from 2 to 5. PR #68 by @dependabot[bot].
  • ⬆ Bump docker/setup-buildx-action from 1 to 3. PR #67 by @dependabot[bot].
  • ⬆ Bump docker/login-action from 1 to 3. PR #69 by @dependabot[bot].
  • 👷 Update issue-manager.yml GitHub Action permissions. PR #76 by @tiangolo.
  • 👷 Update issue-manager.yml GitHub Action permissions. PR #75 by @tiangolo.
  • 🔧 Add GitHub templates for discussions and issues, and security policy. PR #72 by @alejsdev.
  • 🔧 Update latest-changes.yml. PR #70 by @alejsdev.

0.0.1

Features

  • ✨ Allow using debug directives, enable --with-debug compile option. PR #16 by @agconti.
  • ✨ Add support for multiarch builds, including ARM (e.g. Mac M1). PR #65 by @tiangolo.

Fixes

Docs

Upgrades

Internal

License

This project is licensed under the terms of the MIT License.