# arut/nginx-rtmp-module architecture

> Architecture diagram of the GitHub repository arut/nginx-rtmp-module, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arut/nginx-rtmp-module
- Repository: https://github.com/arut/nginx-rtmp-module

## Overview

nginx-rtmp-module adds RTMP ingest, live distribution, playback, and stream-processing features to NGINX. A typical path is an RTMP client publishing a stream, the server handling RTMP commands and codecs, then distributing live media to subscribers or packaging it for HLS/DASH; clients can also request local or HTTP-backed FLV/MP4 playback. Recording, relaying, callbacks, external programs, control, and statistics are additional capabilities. The README documents these product branches; some unsampled module-level wiring is therefore represented only where documented.

Main entry points: [`ngx_rtmp_live_module.c`](https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_live_module.c) (Live Streams), [`ngx_rtmp_cmd_module.c`](https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_cmd_module.c) (RTMP Commands), [`ngx_rtmp_play_module.c`](https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_play_module.c) (Playback Routing), [`ngx_rtmp_notify_module.c`](https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_notify_module.c) (HTTP Notifications)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_protocol["RTMP Protocol"]
  node_core["RTMP Core<br/>[ngx_rtmp.c]"]
  node_connection["Session Handling<br/>[ngx_rtmp_handler.c]"]
  node_commands["RTMP Commands"]
  node_amf["AMF Encoding<br/>[ngx_rtmp_amf.c]"]
end

subgraph group_media["Live Media"]
  node_codec["Codec Metadata"]
  node_live["Live Streams"]
  node_record["Stream Recording"]
end

subgraph group_delivery["Playback Delivery"]
  node_play["Playback Routing"]
  node_flv["FLV Playback"]
  node_mp4["MP4 Playback"]
  node_hls["HLS Packaging"]
  node_mpegts["MPEG-TS Writer<br/>[ngx_rtmp_mpegts.c]"]
  node_dash["DASH Packaging"]
  node_dashmp4["MP4 Segment Writer<br/>[ngx_rtmp_mp4.c]"]
end

subgraph group_operations["Operations"]
  node_relay["Stream Relay"]
  node_autopush["Worker Auto-push"]
  node_notify["HTTP Notifications"]
  node_netcall["HTTP Netcall"]
  node_exec["Event Programs"]
  node_control["HTTP Control"]
end

subgraph group_observability["Monitoring"]
  node_stats["XML Statistics"]
end

node_client(("RTMP Client"))
node_filesystem[("Media Filesystem")]
node_httpservice(("HTTP Services"))
node_ffmpeg(("FFmpeg"))
node_subscriber(("RTMP Subscriber"))

node_client -->|"connects to"| node_core
node_core -->|"handles sessions"| node_connection
node_connection -.->|"dispatches commands"| node_commands
node_commands -->|"publishes streams"| node_live
node_live -.->|"uses codec metadata"| node_codec
node_live -->|"distributes live media"| node_subscriber
node_live -->|"records streams"| node_record
node_commands -->|"requests playback"| node_play
node_play -->|"reads media"| node_filesystem
node_play -->|"plays FLV"| node_flv
node_play -->|"plays MP4"| node_mp4
node_live -->|"packages HLS"| node_hls
node_hls -.->|"writes segments"| node_mpegts
node_live -->|"packages DASH"| node_dash
node_dash -.->|"writes segments"| node_dashmp4
node_live -->|"relays streams"| node_relay
node_relay -->|"supports worker pushing"| node_autopush
node_commands -->|"triggers callbacks"| node_notify
node_notify -.->|"sends HTTP requests"| node_netcall
node_notify -->|"calls back"| node_httpservice
node_live -->|"starts event programs"| node_exec
node_exec -->|"runs transcoder"| node_ffmpeg
node_control -->|"controls clients"| node_live
node_stats -->|"serves statistics"| node_httpservice

click node_core "https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp.c"
click node_connection "https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_handler.c"
click node_commands "https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_cmd_module.c"
click node_amf "https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_amf.c"
click node_codec "https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_codec_module.c"
click node_live "https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_live_module.c"
click node_record "https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_record_module.c"
click node_play "https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_play_module.c"
click node_flv "https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_flv_module.c"
click node_mp4 "https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_mp4_module.c"
click node_hls "https://github.com/arut/nginx-rtmp-module/blob/master/hls/ngx_rtmp_hls_module.c"
click node_mpegts "https://github.com/arut/nginx-rtmp-module/blob/master/hls/ngx_rtmp_mpegts.c"
click node_dash "https://github.com/arut/nginx-rtmp-module/blob/master/dash/ngx_rtmp_dash_module.c"
click node_dashmp4 "https://github.com/arut/nginx-rtmp-module/blob/master/dash/ngx_rtmp_mp4.c"
click node_relay "https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_relay_module.c"
click node_autopush "https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_auto_push_module.c"
click node_notify "https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_notify_module.c"
click node_netcall "https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_netcall_module.c"
click node_exec "https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_exec_module.c"
click node_control "https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_control_module.c"
click node_stats "https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_stat_module.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_core,node_connection,node_commands,node_amf,node_client toneBlue
class node_codec,node_live,node_record,node_filesystem toneAmber
class node_play,node_flv,node_mp4,node_hls,node_mpegts,node_dash,node_dashmp4 toneMint
class node_relay,node_autopush,node_notify,node_netcall,node_exec,node_control toneRose
class node_stats,node_httpservice,node_ffmpeg,node_subscriber toneIndigo
```

## Components

### RTMP Protocol

- [RTMP Core](https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp.c): `ngx_rtmp.c`
- [Session Handling](https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_handler.c): `ngx_rtmp_handler.c`
- [RTMP Commands](https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_cmd_module.c): `ngx_rtmp_cmd_module.c`
- [AMF Encoding](https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_amf.c): `ngx_rtmp_amf.c`

### Live Media

- [Codec Metadata](https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_codec_module.c): `ngx_rtmp_codec_module.c`
- [Live Streams](https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_live_module.c): `ngx_rtmp_live_module.c`
- [Stream Recording](https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_record_module.c): `ngx_rtmp_record_module.c`

### Playback Delivery

- [Playback Routing](https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_play_module.c): `ngx_rtmp_play_module.c`
- [FLV Playback](https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_flv_module.c): `ngx_rtmp_flv_module.c`
- [MP4 Playback](https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_mp4_module.c): `ngx_rtmp_mp4_module.c`
- [HLS Packaging](https://github.com/arut/nginx-rtmp-module/blob/master/hls/ngx_rtmp_hls_module.c): `hls/ngx_rtmp_hls_module.c`
- [MPEG-TS Writer](https://github.com/arut/nginx-rtmp-module/blob/master/hls/ngx_rtmp_mpegts.c): `hls/ngx_rtmp_mpegts.c`
- [DASH Packaging](https://github.com/arut/nginx-rtmp-module/blob/master/dash/ngx_rtmp_dash_module.c): `dash/ngx_rtmp_dash_module.c`
- [MP4 Segment Writer](https://github.com/arut/nginx-rtmp-module/blob/master/dash/ngx_rtmp_mp4.c): `dash/ngx_rtmp_mp4.c`

### Operations

- [Stream Relay](https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_relay_module.c): `ngx_rtmp_relay_module.c`
- [Worker Auto-push](https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_auto_push_module.c): `ngx_rtmp_auto_push_module.c`
- [HTTP Notifications](https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_notify_module.c): `ngx_rtmp_notify_module.c`
- [HTTP Netcall](https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_netcall_module.c): `ngx_rtmp_netcall_module.c`
- [Event Programs](https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_exec_module.c): `ngx_rtmp_exec_module.c`
- [HTTP Control](https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_control_module.c): `ngx_rtmp_control_module.c`

### Monitoring

- [XML Statistics](https://github.com/arut/nginx-rtmp-module/blob/master/ngx_rtmp_stat_module.c): `ngx_rtmp_stat_module.c`

### Other components

- **RTMP Client**
- **Media Filesystem**
- **HTTP Services**
- **FFmpeg**
- **RTMP Subscriber**

## Connections

- RTMP Client → RTMP Core: connects to
- RTMP Core → Session Handling: handles sessions
- Session Handling → RTMP Commands: dispatches commands
- RTMP Commands → Live Streams: publishes streams
- Live Streams → Codec Metadata: uses codec metadata
- Live Streams → RTMP Subscriber: distributes live media
- Live Streams → Stream Recording: records streams
- RTMP Commands → Playback Routing: requests playback
- Playback Routing → Media Filesystem: reads media
- Playback Routing → FLV Playback: plays FLV
- Playback Routing → MP4 Playback: plays MP4
- Live Streams → HLS Packaging: packages HLS
- HLS Packaging → MPEG-TS Writer: writes segments
- Live Streams → DASH Packaging: packages DASH
- DASH Packaging → MP4 Segment Writer: writes segments
- Live Streams → Stream Relay: relays streams
- Stream Relay → Worker Auto-push: supports worker pushing
- RTMP Commands → HTTP Notifications: triggers callbacks
- HTTP Notifications → HTTP Netcall: sends HTTP requests
- HTTP Notifications → HTTP Services: calls back
- Live Streams → Event Programs: starts event programs
- Event Programs → FFmpeg: runs transcoder
- HTTP Control → Live Streams: controls clients
- XML Statistics → HTTP Services: serves statistics
