Coder Social home page Coder Social logo

vallahaye / docker-nginx-rtmp Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 24 KB

Dockerfiles for NGINX with the NGINX RTMP module

Home Page: https://hub.docker.com/r/vallahaye/nginx-rtmp

License: BSD 2-Clause "Simplified" License

Dockerfile 88.55% Shell 11.45%
docker nginx nginx-rtmp media streaming server

docker-nginx-rtmp's Introduction

Quick reference

Supported tags and respective Dockerfile links

Quick reference (cont.)

How to use this image

Running a simple forward broadcast service

load_module modules/ngx_rtmp_module.so;

user nginx;
worker_processes auto;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
  worker_connections 1024;
}

rtmp {
  access_log /var/log/nginx/access.log;
  server {
    listen 1935;
    listen [::]:1935 ipv6only=on;
    application live {
      live on;
      record off;
      push rtmp://live.twitch.tv/app/[streamkeyfromtwitch];
      push rtmp://a.rtmp.youtube.com/live2/[streamkeyfromyoutube];
    }
  }
}
$ docker run --name some-nginx -v nginx.conf:/etc/nginx/nginx.conf:ro -d vallahaye/nginx-rtmp

Alternatively, a simple Dockerfile can be used to generate a new image that includes the necessary configuration (which is a much cleaner solution than the bind mount above):

FROM vallahaye/nginx-rtmp
COPY nginx.conf /etc/nginx/nginx.conf

Place this file in the same directory as your directory containing the NGINX configuration, run docker build -t nginx-rtmp-forward-broadcast ., then start your container:

$ docker run --name some-nginx -d nginx-rtmp-forward-broadcast

Exposing external port

$ docker run --name some-nginx -d -p 1935:1935 nginx-rtmp-forward-broadcast

Then you can hit rtmp://host-ip/live in your streaming software (see the example bellow).

Testing the default configuration with OBS Studio and VLC

$ docker run --name some-nginx --rm -d -p 1935:1935 vallahaye/nginx-rtmp

Open OBS Studio, click on the Settings button and then go to the Stream tab. There, select Custom... from the Service drop-down menu. In the Server field, enter rtmp://host-ip/live replacing host-ip with the IP address of the host where the nginx-rtmp container is running. In the Stream Key field, enter a value that will be used later in the client URL to display that specific stream (for example: test). Click Apply and then close the Settings window. Back to the main window, click the + button in the Sources panel and add a new Display Capture source to the default scene. Start streaming by clicking on the Start Streaming button.

Open VLC, go to the Media menu and then select Open Network Stream. In the URL field, enter rtmp://host-ip/live/stream-key replacing host-ip and stream-key with the values defined above. Click the Play button.

Now VLC should display whatever you stream with OBS Studio.

Complex configuration

Please, see the NGINX RTMP module Wiki as well as the official NGINX image documentation for advanced configuration examples.

Image Variants

The nginx-rtmp images come in many flavors, each designed for a specific use case.

nginx-rtmp:<version>

This is the defacto image. If you are unsure about what your needs are, you probably want to use this one. It is designed to be used both as a throw away container (mount your source code and start the container to start your app), as well as the base to build other images off of.

nginx-rtmp:<version>-alpine

This image is based on the popular Alpine Linux project, available in the alpine official image. Alpine Linux is much smaller than most distribution base images (~5MB), and thus leads to much slimmer images in general.

This variant is highly recommended when final image size being as small as possible is desired. The main caveat to note is that it does use musl libc instead of glibc and friends, so certain software might run into issues depending on the depth of their libc requirements. However, most software doesn't have an issue with this, so this variant is usually a very safe choice. See this Hacker News comment thread for more discussion of the issues that might arise and some pro/con comparisons of using Alpine-based images.

To minimize image size, it's uncommon for additional related tools (such as git or bash) to be included in Alpine-based images. Using this image as a base, add the things you need in your own Dockerfile (see the alpine image description for examples of how to install packages if you are unfamiliar).

License

View license information for the software contained in this image.

As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).

As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.

docker-nginx-rtmp's People

Contributors

vallahaye avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

docker-nginx-rtmp's Issues

Number of connected clients

Hello,
I use the image and it has everything I need. Almost at least :-) Is there any way to find out how many clients have connected to VLC?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.