Video Streaming

Setting up a video streaming service.

Streaming Server Setup

Looked at Adobe’s FMS, Red5 and nimble. Both FMS and Red5 required java to be installed. Adobe’s product appeared to require more resources than Red5. Found nimble to be the best. It has native Linux packages.

Nimble

Nimble provides dynamic HLS streaming of mp4 and mp3 files as well as dynamic DASH streaming of mp4 files. It can also provide streaming of other video files however this is done via progressive download.

See nimble site for full details

It is easily installed use Linux standard package tools. Basically adding their repository and using standard installs (apt, yum).

See installing nimble for details.

You can choose to register your server with WMSPanel in order to configure your server via their interface or you can manually edit the /etc/nimble/rules.conf.

Signing up provides a free trial for 1 month. It has configuration and monitoring features. I only used the configuration feature to generate various versions of the rules.conf file and then manually edited them.

Samples rules:

{"SyncResponse":
 {
 "status":"success",
 "RoutesHash":1373269971,
 "Users":0,
 "Routes":
 [
 {"host":"",
 "path":"/vod/",
 "origin":"file://YOURVIDEODIRHERE/",
 "origin_path":"/",
 "geo":"",
 "range":""}
 ],
 }
}

Nimble listens on port 8081 by default. I’ve setup an apache proxy to forward a virtual host on port 80 to this port.

Now setup a player such as jwplayer, bitcodin with the HLS and/or DASH playlist and a fallback progressive stream to the raw video:

<div id='my-video'></div>
<script type='text/javascript'>
jwplayer("my-video").setup({
 playlist: [{
 image: "http://YOURSERVER/YOURIMAGE",
 sources: [{ 
 file: "http://YOURNIMBLESERVER:YOURNIMBLEPORT/vod/YOURVIDEO/playlist.m3u8"
 },{
 file: "http://YOURNIMBLESERVER:YOURNIMBLEPORT/vod/YOURVIDEO"
 }]
 }],
 height: 360,
 width: 640,
 startparam: "start",
});
</script>

DASH video is provided with the URL "http://YOURNIMBLESERVER:YOURNIMBLEPORT/vod/YOURVIDEO//manifest.mpd"

Players

There are a number of free players that will handle progressive streaming among them jwplayer, flowplayer etc.

With nimble providing HLS and DASH streaming, we needed a free one that handles these formats. Jwplayer handles it but you have to pay extra.

A free one that handles all these is the player from bitcodin.

ClipBucket

Our video site choice was Clipbucket. PHPMotion was another excellent choice but required PHPShield installed. On our owned host we could have done this but to stay flexible we wanted a solution that could be ported to a hosting provider. Another not as robust video script can be found at http://www.vidiscript.co.uk/.

Note: Clipbucket is known to have some security holes. Check their forums for updates. One known one is:

This Metasploit module exploits a vulnerability found in ClipBucket version 2.6 and lower. The script "/admin_area/charts/ofc-library/ofc_upload_image.php" can be used to upload arbitrary code without any authentication. Remove this file.

Some fixes to ClipBucket during Install

Call to undefined method ADODB_mysq
Change require 'adodb/adodb.inc.php';
to
require $_SERVER['DOCUMENT_ROOT'].'/includes/adodb/adodb.inc.php';
in cb_install/db_connect.php and.or includes/dbconnect.php

Turn off PHP Warnings

error_reporting(E_ALL ^E_NOTICE ^E_DEPRECATED ^E_STRICT);

in includes/common.php or set

define(‘DEBUG_LEVEL’, 0);

Some Tips From their Forum

Did you know it is possible to block non authenticated users from going to a specific page of your Clip-Bucket powered website? Well yeah! You can redirect non authenticated users to the sign up page automatically if you set this short code in your pages.

1.  Open the PHP file of any of the pages you would like to prevent guests from entering.

2. After loading the config file, usually something like this:

require 'includes/config.inc.php';

3. Add the following code:

$userquery->logincheck();

Custom Player

The Clipbucket 2.6 players cannot handle streaming protocols, so we created a custom player using JWPlayer.

Setting up custom players is outlined on the Clipbucket site.

We created player/jwplayer6 directory and downloaded JWPlayer components into it.
README.html jwplayer.flash.swf jwplayer.html5.js jwplayer.js

Using the intructions from Clipbucket we then created jwplayer6.php file.

<?php
 /*
 Player Name: JW Player v6
 Description: Jw player for clipbucket from longtail.com
 ClipBucket Version: 2
 Plugin Version: 1.0 - JW 6
 Website: http://clip-bucket.com/
 */
if(!function_exists(jwplayer6))
 {
 function jwplayer6($data)
 {
$vdata = $data['vdetails'];
$vid_file = get_video_file($vdata,$no_video,false);
if($vid_file)
 {
$width = $data['width'];
 $height = $data['height'];
 $image = "/files/thumbs/" . $vdata['videokey'];
 $DivId = $data['player_div'] ? $data['player_div'] : config('player_div_id');
//echo "<h4>$vid_file $image $DivId</h4>";
 //print_r($data);
//<script src="http://jwpsrv.com/library/YOURCLOUDKEY.js"></script>
 echo <<<EOD
 <script src="/player/jwplayer6/jwplayer.js" ></script>
 <script>jwplayer.key="YOURJWKEY";</script>
 <div id='$DivId'></div>
 <script type='text/javascript'>
 jwplayer('$DivId').setup({
 file: '$vid_file',
 width: '$width',
 height: '$height',
 image: '$image'
 });
 </script>
 EOD;
 return " ";
}else
 return false;
 }
add_js(array('swfobject.obj.js'=>'global'));
 register_actions_play_video('jwplayer6');
 }
?>

Leave a Reply