Archive for November, 2012

Getting started with nginx-rtmp

Many people asked for beginner’s tutorial on nginx-rtmp streaming.
Here’s a new Getting Started guide.


Leave a comment

Update in recorder

A fix has been introduced in recorder engine. When recording with no interval or frame number specified (making one big file) a single IO error produces infinite number of recording attempts with record error complains. That has been fixed in master. Now only one attempt is made with one record failure notification.

Development branch new-live3 will soon be merged into master with many live streaming improvements. However it’s already stable enough for everyone to try. ┬áIt has better stream synchronization, better memory usage, speed and many more.

Leave a comment

Update notifications

New type of notifications is added to nginx-rtmp – update notifications. They are called periodically with given timeout while stream is in play or publish state. If result code is other than 2xx then connection is terminated. All usual parameters are passed with this call (including client request arguments).

application myapp {
    live on;
    notify_update_timeout 20s;
    on_update http://localhost/update;

Default update timeout is 30 seconds, but it can be changed with notify_update_timeout directive.
This notification can be used to synchronize expired sessions.

Update: on_update ignores server access errors, empty or broken HTTP responses. Connection is terminated only on non-2xx HTTP return code.

Update2: Added notify_update_strict directive toggling strict mode. When in strict mode all network errors and bad HTTP responses are treated as update errors. Default is off.



In recent version of nginx-rtmp-module I have added support for remote video playback over HTTP. The syntax is similar to local playback with the only exception. Play directive argument should start with http://. Both flv & mp4 formats are supported.


The feature has a limitation. Video file is completely downloaded before playing which might introduce a lag. To cache file locally use nginx http proxy engine and set up playing from localhost.

The new feature is described in wiki directives page.


Setting HTTP method in notifications

Until recently all notifications (on_play, on_publish etc) used POST method for passing arguments. Now GET method is also supported. To set that use the directive: notify_method get.

While GET has certain limitations concerning data size, that way of passing data has one big advantage. Such callbacks can be handled directly in nginx’s http{} section.

Here’s a simple example how to disable playing for remote clients.

http {
    server {
        listen       8080;
        server_name  localhost;

        location /on_play {
            if ($arg_pageUrl ~* localhost) {
                return 200;
            return 500;

rtmp {
    server {
        listen 1935;
        notify_method get;

        application myapp {
            live on;
            on_play http://localhost:8080/on_play;

Leave a comment