Archive for April, 2013

Updated HLS in 0.9.18

New HLS in 0.9.18 includes the following updates

  • Directory-per-stream mode: hls_nested on
  • Automatic asynchronous fragment erasing. Fragments and playlists are erased automatically after timeout has expired from nginx cache manager process
  • Fixed iPhone playback
  • Introduced HLS discontinuities on stream restart
  • Three fragment naming modes: hls_fragment_naming sequential|timestamp|system
  • Two fragment slicing modes: hls_fragment_slicing plain|aligned. Aligned mode creates ts fragments aligned to incoming timestamp boundaries.
  • Max fragment size limitation to escape giant fragments
  • Smaller fragment size
  • Fractional durations described in HLSv3 specs for better seeking
  • Fragment duration and discontinuity recovery on stream restart
  • Always new fragment files, no fragment reuse
Advertisements

2 Comments

Setting file name pattern in recorder

In the latest master it’s possible to set strftime-compliant pattern when specifying record_suffix value.

recorder rec1 {
    record all;
    record_interval 5s;
    record_suffix -%d-%b-%y-%T.flv;
    record_path /tmp/rec;
}

This config will produce files of the form mystream-24-Apr-13-18:23:38.flv. Full list of supported strftime format options you can find on strftime man page.

Leave a comment

Shell-style exec redirects in 0.9.17

The new feature is shell-style redirects in exec-family directives. Now you can save ffmpeg (or any other executed child) output in file and pass input to it (makes no sense with ffmpeg however).

    application myapp {
        live on;
        exec ffmpeg -i rtmp://localhost/myapp/$name -c copy 
                    -f flv rtmp://example.com/myapp/$name 2>>/var/log/ffmpeg-$name.log;
    }

Now you have a single log file like /var/log/ffmpeg-mystream.log for each stream where you can find all ffmpeg output including errors. You can redirect stdout (1>/var/log/ffmpeg-$name.out) and any other stream (1>&2) as well. Both truncate > and append >> modes are supported as well as usual variable substitutions .

2 Comments

Updates and fixes in 0.9.16

Updates in version 0.9.16 of nginx-rtmp-module

  • New stat.xsl with smart byte counter and bandwidth numbers. Thanks to misiek08 for the contribution.
  • Fixed auto-pushing to cache manager and cache loader processes. Earlier versions used to write millions of errors when one of these processes is created by nginx. Now it’s fixed.
  • Fixed exe_static and static pull auto-start. No need to wait until first network connection for them to start.
  • Fixed relays on FreeBSD. It’s been reported that on some FreeBSD systems pull/push sometimes fail to connect to remote side. Now it’s fixed.

There are two upcoming updates as well.

  • New version of VOD statistics in branch vod-stat2. Many people asked for this. I’m waiting for response on this feature before I merge it into master. It’s now ready to be merged. I hope I’ll have enough feedback to merge it until the branch gets too old.
  • Significantly improved version of HLS in hls-restart-on-audio branch. Many HLS updates have been implemented in this branch. iPhone playback has been improved. Fragment creation and erasing has been improved as well. I’ll post more details about this later. You can try this branch and report the issues. I’m planning to merge it soon.

2 Comments

Done-family notifications

A little bug has been fixed today. When on_play/on_publish return error on_play_done/on_publish_done/on_done are not called anymore.

Leave a comment

RTMP notify redirects in 0.9.14

Recently I have committed a new feature in nginx-rtmp. The feature is called notify-redirects. HTTP notifications have been available in ngnx-rtmp for a long time. Unsuccessful (non-2xx) HTTP result code used to terminate RTMP connection.

Since version 0.9.14 notification HTTP result code 3xx redirects RTMP connection to another application/stream. Application redirect is done in case of on_connect, stream redirect is done in case of on_play and on_publish. Application/stream name should be returned in Location field of HTTP response header.

In this example fallback is returned as new application name instead of the one provided by RTMP client.

curl -v http://localhost:8080/on_connect?...
...
< HTTP/1.1 301 Moved Permanently
< Server: nginx/1.2.4
< Date: Sun, 14 Apr 2013 04:41:18 GMT
< Content-Type: text/html
< Content-Length: 184
< Connection: keep-alive
< Location: fallback
...

Redirects can be easily implemented in nginx. The following example implements on_connect handler checking for RTMP flashVer equal to my_secret_flashver and redirecting client to fallback application in case of failure.

http {
    server {
        listen 8080;
        server_name localhost;
        location /on_connect {
            if ($arg_flashver != "my_secret_flashver") {
                rewrite ^.*$ fallback? permanent;
            }
            return 200;
        }
    }
}

Rtmp config for this case.

rtmp {
    server {
        listen 1935;
        notify_method get;
        on_connect http://localhost:8080/on_connect;
        application myapp {
            # Live stream for good clients
            live on;
        }
        application fallback {
            # VOD video for bad clients
            live on;
            play /var/fallback;
        }
    }
}

The same way you can redirect streams with on_play and on_publish handlers.

PS: Several important issues have been fixed in HLS engine as well. Please make sure you use the latest code. Moreover new updated HLS engine is under development.

8 Comments