Archive for January, 2013

No HLS cache

I’ve added the following line to HLS playlist


This disables caching HLS files on client side.


Leave a comment

Fixed nginx_status

Today I have fixed a small issue concerning wrong active connection number on nginx_status page. Before the fix that number used to grow with every rtmp connection.

Leave a comment

HLS continuous streaming

HLS is a sequence of MPEG-TS fragments and M3U8 playlist. Each fragment has its sequence number. Upon stream restart these sequence numbers used to start from beginning. Some players don’t like that behavior and stop the stream. Besides some HLS files can remain unerased.

A new directive hls_continuous makes HLS generation more consistent. When stream is started nginx-rtmp parses the playlist and finds the last sequence number. Streaming is started from that sequence number.

hls on;
hls_path /tmp/hls;
hls_continuous on;

Ffplay/ffmpeg is completely happy with that. However VLC sometimes stops playing at fragment boundary.

The feature is off by default.

Leave a comment

Mp4 track selector

In version 0.9.2 of nginx-rtmp I have added track selector for mp4 playback. If your mp4 has multiple audio (or video) tracks then you can provide track index to play. Argument names are aindex and vindex.




# ignore video track



HLS audio synchronization

Sometimes when playing HLS on iPhone you can hear crackles. The reason for them is MPEG-TS timestamps have much higher resolution than RTMP timestamps. Nginx-rtmp has a built-in feature fixing that. The directive name is hls_sync. I have not announced this feature before. Now I have added it to directives page. Moreover the feature is on by default. So if you have crackles in HLS just update from master.

Leave a comment

Locking files in recorder

Sometimes you need to find out which recorded files are ready for processing and which are still being recorded. A new feature record_lock makes that possible.

recorder myrec {
               record all;
               record_interval 30s;
               record_path /tmp/rec;
               record_unique on;
               record_lock on;

File being recorded is exclusively locked with fcntl lock engine. You can easily check file lock status from elsewhere. On FreeBSD you can use flock tool to check that. On Linux flock and fcntl are unrelated so you’re left with writing a simple script. Here’s an example of


import fcntl, sys

fcntl.lockf(open(sys.argv[1], "a"), fcntl.LOCK_EX|fcntl.LOCK_NB)

Use this script to check if file is currently being recorded.

for file in /tmp/rec/*; do
    printf "$file : ";
    if ~/ $file; then echo "ready"; else echo "locked"; fi;

Leave a comment

HLS on Android

For Android devices to play HLS stream properly you have to assign application/ content type to m3u8 playlist.

location /hls {
    types {
        application/ m3u8;
    alias /tmp/hls;

I want to thank module users in nginx-rtmp-ru google group for this solution.

Leave a comment