Archive for March, 2013

Native HLS in master

I have merged native HLS into master and tagged v0.9.13. Now you don’t need ffmpeg for HLS to work. Just compile nginx with nginx-rtmp-module. No separate hls module exist anymore. All HLS code is included in main rtmp module.

5 Comments

Switching bitrates in RTMP

Today I have fixed an issue with RTMP bitrate switch for VOD streams. With JWPlayer version 6 it’s possible to choose RTMP bitrate while playing stream in a way similar to youtube. I’ll provide a small tutorial here how to set up this on your system.

smil

In latest master I have updated JWPlayer to version 6. This version supports the following config format.


<script type="text/javascript" src="/jwplayer/jwplayer.js"></script></pre>
<div id="container">Loading the player ...</div>
<script type="text/javascript">
        jwplayer("container").setup({
        sources:[
            {
                file:"/sintel.smil"
            }
        ],
        ga: {},
        autostart: true,
        width: 640,
        height: 480,
        primary: 'flash'
});
</script>

This configuration refers smil file setting different bitrates/qualities for the same video. Here’s an example of sintel.smil

<smil>
<head>
<meta base="rtmp://localhost/vod/" />
</head>
<body>
<switch>
<video src="mp4:sintel-120p.mp4" height="120" />
<video src="mp4:sintel-240p.mp4" height="240" />
<video src="mp4:sintel-480p.mp4" height="480" />
</switch>
</body>
</smil>

Mp4 files for different bitrates can be created from the source sintel.mp4 with the following ffmpeg calls

ffmpeg -i sintel.mp4 -c:v libx264 -c:a copy -s 640x480 sintel-480p.mp4
ffmpeg -i sintel.mp4 -c:v libx264 -c:a copy -s 320x240 sintel-240p.mp4
ffmpeg -i sintel.mp4 -c:v libx264 -c:a copy -s 160x120 sintel-120p.mp4

The error fixed in 0.9.12 is nginx crash when switching stream quality in case VOD file is accessed remotely with http.

Thanks to fjyaniez for the report and config examples.

4 Comments

Vimeo is using nginx-rtmp


People from Vimeo told me recently they went live with nginx-rtmp as a part of enhancer feature.

1 Comment

Native HLS in nginx-rtmp

Until now HLS implementation in nginx-rtmp made use of ffmpeg libs to create HLS fragments. That lead to such major problems as complicated compilation process, ffmpeg/avconv confusion, libavformat API limitations, uncontrollable memory allocations in ffmpeg libs etc. Besides ffmpeg may not be available on some architectures (embedded etc). That was all too serious to keep using those libs.

Today I’m introducing native HLS support. It seems to be significantly faster that before, and does not require any third-party libs. The new code in is native-hls branch. There’s no separate HLS module anymore. HLS is included in main rtmp module as one of the features.

In addition to native mpeg-ts generation new HLS engine is more consistent with stream restarts.

24 Comments

Appending recorded files in 0.9.11

Until v0.9.11 of nginx-rtmp recorder could only create multiple unique files per stream (record_unique option) or re-write the file with each stream restart. Now a new mode is supported – append mode. The new directive is record_append. With this setting on the flv file is appended on each stream start.

record all;
record_path /tmp/rec;
record_append on;

Note that stream timestamps at the border are written close to each other without any gap so that there’s no suspension when watching the recorded stream.

1 Comment

Connection limiter in 0.9.9

Since v0.9.9 it’s now possible to limit the number of simultaneous RTMP connections to nginx-rtmp. The new directive is max_connections. By default there’s no limit on connection number.

max_connections 200;

Connection number is stored in shared memory so it affects all workers. Auto-push connections as well as relay connections (push/pull) are also limited by this engine.

Leave a comment