🤖nginx-http-flv-module
+ 💾s3fs-fuse
= ❤️🔥
⚡ Blazingly fast Docker image, that provides exceptional support for integrating Amazon S3
with nginx-http-flv-module
, which is better, than nginx-rtmp-module (see comparison table), to save the *.m3u8
files into AWS S3 storage.
Based on https://github.com/efriandika/streaming-server.
- nginx 1.16.1 (stable version compiled from source)
- nginx-http-flv-module 1.2.10 (compiled from source)
- ffmpeg 4.2.1 (compiled from source)
- S3FS FUSE (Amazon S3 Integration)
- Default HLS settings (see nginx.conf)
Run container from source:
docker run --rm -it \
-e AWS_ACCESS_KEY_ID=secret \
-e AWS_SECRET_ACCESS_KEY=secret \
-e AWS_S3_BUCKET_NAME=secret \
-e AWS_S3_REGION=us-east-1 \
--cap-add=SYS_ADMIN --device="/dev/fuse" --security-opt="apparmor=unconfined" \
-p 1935:1935 -p 8080:80 -p 8443:443 sinnrrr/streaming-server
docker-compose.yml
can be:
streaming-server:
image: sinnrrr/streaming-server:latest
env_file:
- .env # I encourage you to use .env file
ports:
- 1935:1935
- 8080:80
- 8443:443
cap_add:
- SYS_ADMIN
devices:
- /dev/fuse
security_opt:
- apparmor:unconfined
rtmp://<server_ip>:1935/stream/<stream_name>
To stream from OBS go to Settings -> Stream
, and input the following:
- Stream Type:
Custom Streaming Server
- URL:
rtmp://localhost:1935/stream
(stream name is "stream") - Stream Key:
hello
(it could be anything, but we will use this for sake of example)
- In your browser, VLC or any HLS player, open:
http://localhost:8080/live/<stream_key>.m3u8
Following our example, <stream_key>
is hello
, so:
- Access playlist using URL:
http://localhost:8080/live/hello.m3u8
- Play online using VideoJS Player
- FFplay:
ffplay -fflags nobuffer rtmp://localhost:1935/stream/hello
ATTENTION: Don't forget to set public access and enable CORS in your S3 bucket
You can access your livescream playlist using your S3 public URL.
For example: https://<s3_bucket_name>.s3.us-east-1.amazonaws.com/hls/hello.m3u8
or you can set your CloudFront (cache disabled) distribution then based on your S3.
To enable SSL, see 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.
Variable name | Default value | Required |
---|---|---|
AWS_ACCESS_KEY_ID | - | true |
AWS_SECRET_ACCESS_KEY | - | true |
AWS_BUCKET_NAME | - | true |
AWS_S3_AUTHFILE | /etc/passwd-s3fs |
false |
AWS_S3_MOUNTPOINT | /opt/data/recordings |
false |
AWS_S3_URL | https://s3.amazonaws.com |
false |
AWS_S3_REGION | us-east-1 |
false |
S3FS_ARGS | - | false |
$ ffmpeg -buildconf
ffmpeg version 4.2.1 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. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.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'