Wednesday, March 20, 2013

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.


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">
ga: {},
autostart: true,
width: 640,
height: 480,
primary: 'flash'

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

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

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.


  1. Thank you for your effort, nginx-rtmp-module is awesome :)

  2. Does this fix also apply to live rtmp streams and auto bandwidth detection (vide: netstream2 function)?

  3. Hi, flowplayer sollutions? not working, i think there is server problem. thx

  4. I didn't test that with flowplayer. I will do that when I have time. Thanks.

  5. any news? Thank you. David