PHP 8.2+ · Workerman · MIT

A media server
implemented in PHP

RTMP / HTTP-FLV ingest, RTMP / HTTP-FLV / WS-FLV playback, fMP4 recording with millisecond-precise replay, plus a bilingual admin console. No FFmpeg transcode process or Node runtime required.

6000
concurrent pull streams
6400
concurrent push streams
36 KB
memory per pull connection
2 s
fMP4 fragment duration
bash
$ composer install
$ php start.php start
rtmp server tcp://0.0.0.0:1935  start
http server 127.0.0.1:18080     start
$ ffmpeg -re -i demo.mp4 -c:v libx264 \
      -c:a aac -f flv rtmp://127.0.0.1/live/stream
▸ stream attached — open /admin/ to watch
RTMP HTTP-FLV WS-FLV H.264 / H.265 fMP4 SQLite

Media path

Ingest and delivery

One stream can be pulled by several protocols at once, recorded while it is being pushed, and reviewed later for any time range.

Ingest rtmp://host:1935/app/stream POST /app/stream

RTMP push, or POST raw FLV data

Multi-worker event loop media-server

FLV parsing · GOP cache · frame distribution · muxing

Playback RTMP HTTP-FLV WS-FLV
Recording fMP4 segments SQLite index

Scope

Features and scope

Covers ingest, delivery, fMP4 recording, time-range replay, the admin console and automated tests.

Implemented in PHP

Built on the Workerman event loop. The RTMP handshake, FLV tag parsing and fMP4 muxing are written in PHP, with no FFmpeg transcode process or C++ extension.

Three playback protocols

The same stream is served over RTMP, HTTP-FLV and WS-FLV, with disableAudio / disableVideo / disableGop query filters.

H.264 / H.265 support

Handles both Enhanced RTMP (codecId=0 + hvc1) and legacy codecId=12 HEVC framing, with AAC audio.

Real-time fMP4 recording

Fragments and segments are cut on keyframe boundaries. Every .mp4 carries a complete moov, so it plays standalone and parses in ffprobe and browsers.

Time-range replay

The /playback endpoint slices across segments and starts at the keyframe at or before start; mdat is streamed in chunks, so memory does not grow with clip length.

Built-in admin console

Dashboard, live bitrate, detailed stream information, recording replay and settings, with token auth and a Chinese/English switch.

End-to-end tests

Data-driven cases cover push → record → replay → decode verification. CI runs syntax checks and smoke tests on PHP 8.2 / 8.3 / 8.4.

Benchmarks and scripts

Scripts, raw data and analysis for five load scenarios ship with the repo and can be reproduced on other machines.

Deployment

Multi-worker architecture

Linux / WSL runs Workerman native workers with count + reusePort. Use start.php for deployment and development.

Process roles and default ports
ProcessPortResponsibility
control18090Stream registry, events and stats aggregation
ingest1935 / 18081RTMP and HTTP-FLV ingest
play1936 / 18080RTMP, HTTP-FLV and WS-FLV playback
admin18099Admin console, management API and replay
record—Independent fMP4 recording
1

Start on Linux / WSL

php start.php start

Also supports stop / restart / status. Scaling uses worker count + reusePort.

2

Live stream testing

curl -N http://127.0.0.1:18080/live/stream.flv

HTTP-FLV and RTMP ingest/playback share the same start.php entry point.

Dependencies

PHP 8.2+, ext-json, ext-shmop, workerman/workerman ^5.2, evenement/evenement ^3.0, apix/log ^1.2. ffmpeg / ffprobe are needed for push and E2E tests. The console has no Node build step.

Configuration

Configure ServerConfig in start.php, or override it with MP_INGEST_COUNT, MP_PLAY_COUNT, MP_*_PORT, MP_REGISTRY_*, MP_SHM_* and MP_MEMORY_LIMIT environment variables.

Console improvements

Live bitrate and detailed stream information are now visible in the console. Stream details are cleaned up on close, play counts are per path, and live preview always uses the play port.

Runtime fixes

getSettings and listRecordFiles are handled locally by admin; Worker::runAll is wired into the process entry; admin serves static files only, while play serves FLV only.

Note: open the console at http://127.0.0.1:18099/admin/. Live preview is fetched from http://127.0.0.1:18080.

Console

Admin console

A plain-JS single page app with no build step, served by the admin process.

Admin console dashboard
Dashboard: stream count, playback connections, uptime and memory

Benchmarks

Benchmark data

Test setup: AMD Ryzen 9 9900X · Linux / WSL · PHP 8.4 · 1080p30 @ 4096 kb/s · ffmpeg -c copy

6000pull streams

play=8, 21–22% CPU per process, 25.69 Gbps, 100% held

6400push streams

ingest=8, grouped shared memory, 60.9% average CPU, 26.99 Gbps, 0 errors

0/0drops / errors

6400 push streams, zero drops and zero errors

36 KB per connection

6000 pull streams, 100% held

Benchmark data (WSL2, Workerman native multi-process)
DirectionWorkersStreamsCPUThroughputResult
Pushingest=8640060.9%26.99 Gbps0 drops / 0 errors
Pullplay=8600021–22% / process25.69 Gbps100% held

Quick start

Install and run

Requires PHP 8.2+ and Composer. ffmpeg is only needed for pushing and for the E2E suite.

1

Install dependencies

composer install
2

Start the server

php start.php start

RTMP ingest listens on 1935, playback on 18080, admin console on 18099.

3

Push a stream in

ffmpeg -re -i file.mp4 -c:v libx264 -c:a aac -f flv \
  rtmp://127.0.0.1/live/stream
4

Start playing

  • HTTP-FLVhttp://127.0.0.1:18080/live/stream.flv
  • WS-FLVws://127.0.0.1:18080/live/stream.flv
  • RTMPrtmp://127.0.0.1/live/stream
  • Adminhttp://127.0.0.1:18099/admin/

Limitations

Scope and limitations

Matches the known-limitations section of the README — worth checking before choosing it.

See the full list of limitations
  • Multi-worker deployment requires ext-shmop; shared-memory segments are shared by multiple streams
  • H.265 push works with FFmpeg 6.x via legacy FLV codecId=12; Enhanced RTMP hvc1 needs FFmpeg 7.x
  • Only H.264 / H.265 video with AAC audio
  • In-browser H.265 playback depends on OS-level HEVC decoding
  • Change the default credentials and put the console behind proxy access control in production