Archive for June, 2012

Documentation: directives

I’ve started writing documentation. The “Directives” page is already full of information:

https://github.com/arut/nginx-rtmp-module/wiki/Directives

Leave a comment

Play/publish argument support

I’ve already posted about NGINX-RTMP’s support of on_publish & on_play (& recently added on_done) callbacks. These are HTTP callbacks which can be used to notify or reject RTMP operations. They receive connect and publish/play arguments like pageUrl, tcUrl etc. However in certain cases that’s not enough. It’s extremely useful to have arbitrary arguments to be passed there from outside.

Recently that problem has been solved with the support of play/publish arguments. These are submitted with usual form-urlencoded syntax:

rtmp://cdn.example.com/myapp/mystream?a=b&c=d.

The values for a and c are now passed to all callbacks. It can be used to check session and reject publish/play operations for certain clients.

1 Comment

HLS support in NGINX-RTMP

Recently I’ve added initial Apple’s HLS support to the module.

HLS stands for HTTP Live Streaming. It’s supported by iPhones & iPads to watch videos right from their browsers. The biggest benefit of the technology is the ability to stream data through HTTP which is great for passing proxies, mobile & corporate networks.

HLS is m3u8 playlist file plus a number of stream fragments in mpeg-ts format,

Recently I’ve added HLS support to nginx-rtmp-module. The module does not decode streams. It can be done asynchronously with ffmpeg (see exec directive). However RTMP stream should be reformatted into mpeg-ts fragments. FFmpeg’s libavformat is used for that. Please make sure ffmpeg is installed on your system before building nginx with HLS module.

To add HLS support to nginx one should add HLS module explicitly in addition to core nginx-rtmp-moduie when configuring

./configure ... --add-module=/path/to/nginx-rtmp-module/hls

The following lines should be added to nginx.conf.

application myapp {
    hls on;
    hls_path /tmp/app;
    hls_fragment 5s;
}

The path /tmp/app is where m3u8 playlist and *.ts fragments will be placed. The path should exist before starting nginx. For best results it should be located in tmpfs. To serve the HLS data use usual nginx settings within http{} block:

location /myapp {
    alias /tmp/app;
}

When you navigate your iPhone to playlist file within this location (for example: http://example.com/myapp/movie.m3u8) you’ll see live stream right in mobile browser.

Known issues:

When streaming in MP3 audio is choppy. However H264/AAC (the modern way to encode streams) works pretty good.

Please feel free to report issues. The HLS support is still in experimental state.


			

13 Comments