docker-nginx-rtmp - NGINX-based Media Streaming Server

docker-nginx-rtmp - NGINX-based Media Streaming Server

https://github.com/alfg/docker-nginx-rtmp

A Dockerfile installing NGINX, nginx-rtmp-module and FFmpeg from source with default settings for HLS live streaming. Built on Alpine Linux.

  • Nginx 1.16.0 (Stable version compiled from source)
  • nginx-rtmp-module 1.2.1 (compiled from source)
  • ffmpeg 4.1.3 (compiled from source)
  • Default HLS settings (nginx.conf)
HTTP Live Streaming,HLS
Alpine Linux is a security-oriented, lightweight Linux distribution based on musl libc and busybox.
Alpine Linux 是一个基于安全的轻量级 Linux 发行版,基于 musl libc 和 busybox。

docker-nginx-rtmp - overview
https://hub.docker.com/r/alfg/nginx-rtmp

0. Installation - Server

确保服务器上 Docker CE 已安装完成。
https://docs.docker.com/install/linux/docker-ce/ubuntu/

  • Pull docker image and run:
docker pull alfg/nginx-rtmp
docker run -it -p 1935:1935 -p 8080:80 --rm alfg/nginx-rtmp

or

  • Build and run container from source:
docker build -t nginx-rtmp .
docker run -it -p 1935:1935 -p 8080:80 --rm nginx-rtmp
strong@foreverstrong:~$ sudo docker pull alfg/nginx-rtmp
Using default tag: latest
latest: Pulling from alfg/nginx-rtmp
c87736221ed0: Pull complete 
4de2c1381e30: Pull complete 
660f83b200e9: Pull complete 
1f10093590a5: Pull complete 
42f71f341285: Pull complete 
8b8824ee8a8f: Pull complete 
6cb56c9cea77: Pull complete 
a4b905ed9413: Pull complete 
Digest: sha256:0ce3fdbc80ac62e19fcf465d9d26e84cb7600e541df97f7d0d00f3ed14357a98
Status: Downloaded newer image for alfg/nginx-rtmp:latest
strong@foreverstrong:~$ 
strong@foreverstrong:~$ sudo docker run -d -it -p 1935:1935 -p 8080:80 --rm alfg/nginx-rtmp
[sudo] password for strong: 
19da2baf652132f32f50fe9f32c3dd1b0395883feeb418fe0d40a908c87345c7
strong@foreverstrong:~$ 

1. Streaming

rtmp://<server ip>:1935/stream/$STREAM_NAME

2. OBS Configuration

Stream Type: Custom Streaming Server
URL: rtmp://localhost:1935/stream
Stream Key: yongqiang

3. Watch Stream

Safari, VLC or any HLS player:

http://<server ip>:8080/live/$STREAM_NAME.m3u8

Example Playlist:

http://localhost:8080/live/hello.m3u8

FFplay:

ffplay -fflags nobuffer rtmp://localhost:1935/stream/hello

4. SSL

To enable SSL, nginx.conf and uncomment the lines:

listen 443 ssl;
ssl_certificate     /opt/certs/example.com.crt;
ssl_certificate_key /opt/certs/example.com.key;

This will enable HTTPS using a self-signed certificate supplied in /certs. If you wish to use HTTPS, it is highly recommended to obtain your own certificates and update the ssl_certificate and ssl_certificate_key paths.

I recommend using Certbot from Let's Encrypt.
https://certbot.eff.org/docs/install.html
https://letsencrypt.org/

5. FFmpeg Build

ffmpeg version 4.1.3 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 6.4.0 (Alpine 6.4.0)
  configuration: --prefix=/usr/local --enable-version3 --enable-gpl --enable-nonfree --enable-small --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libvpx --enable-libtheora --enable-libvorbis --enable-libopus --enable-libfdk-aac --enable-libass --enable-libwebp --enable-librtmp --enable-postproc --enable-avresample --enable-libfreetype --enable-openssl --disable-debug --disable-doc --disable-ffplay --extra-libs='-lpthread -lm'
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100

  configuration:
    --prefix=/usr/local
    --enable-version3
    --enable-gpl
    --enable-nonfree
    --enable-small
    --enable-libmp3lame
    --enable-libx264
    --enable-libx265
    --enable-libvpx
    --enable-libtheora
    --enable-libvorbis
    --enable-libopus
    --enable-libfdk-aac
    --enable-libass
    --enable-libwebp
    --enable-librtmp
    --enable-postproc
    --enable-avresample
    --enable-libfreetype
    --enable-openssl
    --disable-debug
    --disable-doc
    --disable-ffplay
    --extra-libs='-lpthread -lm'

Resources

Alpine Linux
https://alpinelinux.org/

NGINX
http://nginx.org/

NGINX-based Media Streaming Server - nginx-rtmp-module
https://github.com/arut/nginx-rtmp-module

FFmpeg
https://www.ffmpeg.org/

OBS Studio
https://obsproject.com/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Yongqiang Cheng

梦想不是浮躁,而是沉淀和积累。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值