Tuesday, January 15, 2013

Static pull feature in nginx-rtmp

Currently implemented pull/push relays are dynamic. They are created dynamically when there's at least one RTMP client playing/publishing the stream. That's useful for saving network bandwidth and handling undefined set of streams. However this implementation suffers from several problems

  • HLS is not generated until there's at least one RTMP client playing the pulled stream

  • In multi-worker mode each worker pulls its own stream from remote server

  • In multi-worker mode recording pulled stream and generating HLS from such stream leads to conflict between workers writing the same files

I've been asked many times to solve that, especially HLS/pull. That's hardly possible with dynamic relays. However not many people really need that kind of relays. In many cases It'd be enough to have static relays activated at nginx start with no dependence on RTMP clients. With static relays all above mentioned problems can easily be solved.

Static pulls are implemented in static-relay branch. To create one you need to add static keyword to pull directive argument list.

pull rtmp://remote.example.com/myapp/rstream pageUrl=ABC name=mystream static;

Such stream is started at nginx start and restarted on stream error. There's new pull_reconnect directive setting restart timeout. Unlike earlier you cannot omit stream name when creating static pull.

This feature will be later merged into master. I'm waiting for your feedback until then.


  1. after install it work and can restream, If play video on ipad long time maybe audio not sync but refresh it come back ok. and I listen some noise on IPAD2 but not have on flashplayer.

  2. to fix crackling noise in HLS use hls_sync directive:
    hls_sync 300ms;

  3. An additional advantage of this product is its cost.