rtmp

RTMP, HLS, and MPEG-DASH live streaming

dynamic moduleBSD-2-Clausesource docs

Overview

nginx-rtmp-module turns nginx into a live streaming server. It accepts RTMP streams from encoders such as OBS or FFmpeg and can repackage them as HLS or MPEG-DASH for playback in browsers and mobile apps. It also serves video on demand from FLV and MP4 files.

The module supports stream relaying with push and pull, recording streams to disk, HTTP callbacks on publish and play events, and running external commands such as FFmpeg transcoders. A built-in stats handler reports server state as XML.

RTMP configuration lives in its own top-level rtmp block, next to http, not inside it. The module is written by Roman Arutyunyan, an nginx core developer.

Key directives

rtmp { server { application } }Defines the RTMP server in its own top-level block, with listen ports and named applications that clients publish to and play from.
live onEnables one-to-many live broadcasting for an application, distributing each published stream to all subscribers.
hls onRepackages the live stream as HLS segments and playlists in hls_path, served to players over plain HTTP.
dash onProduces MPEG-DASH fragments and an MPD manifest for the same stream, written to dash_path.
push / pullRelays streams to another RTMP server or fetches them from one on demand, for multi-server distribution.
recordWrites published streams to FLV files, with options to record all, audio only, video only, or keyframes.

Example

nginx.conf
load_module modules/ngx_rtmp_module.so; rtmp { server { listen 1935; application live { live on; hls on; hls_path /var/www/hls; hls_fragment 3s; } } }

Availability

Ships as a dynamic module in libnginx-mod-rtmp, installed automatically with nginx-extras. The package drops a load_module config into /etc/nginx/modules-enabled/, so it loads on start.