Archive for March, 2013
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.
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.
In latest master I have updated JWPlayer to version 6. This version supports the following config format.
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.
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.
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.
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.
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.