OK, I setup ming to view events in flash SWF format. It looks GREAT!! It is faster than using Java (on the client side). It is better looking over the web (IMHO).
The flash file will resize or scale for zoom in / zoom out effect. The rate does not work yet. So you cannot speed up or slow down yet. My cameras capture at 4 frames per second. So this looks like real time viewing for me. You can also toggle play/pause playback by clicking the mouse inside the image.
Here is some code I used:
I edited the zm_html_view_event.php file on line 329 to include this code:
Code: Select all
# this is place to add a flash based viewer.
elseif ("true")
{
$slideshow_image_path = ZM_DIR_EVENTS.'/'.$event['MonitorId'].'/'.$event['Id'].'/';
$slideshow_width=reScale($event['Width']);
$slideshow_height=reScale($event['Height']);
$slideshow_rate=$rate;
$slideshow_scale="100";
include("ming_funcs.php");
event_to_swf($slideshow_image_path,$slideshow_width,$slideshow_height,$slideshow_rate,$slideshow_scale);
?>
<embed type="flash/swf"
src="swf/slideshow.swf"
width="<?= reScale( $event['Width'], $scale ) ?>"
height="<?= reScale( $event['Height'], $scale ) ?>"
loop="0">
</embed>
<?php
}
In pure laziness, the first line "elseif("true")" simply evaluates to true in order to activate this streaming method. A real install would look this up in a database or config file.
As you can see, the code above includes this page, which I created, called "ming_funcs.php", with this code:
Code: Select all
<?php
function event_to_swf($path,$width,$height,$rate,$scale) {
// just put the directories with the jpgs here and compile
$pathtojpgs= array();
$pathtojpgs[0]= $path;
$slide_show_width = $width;
$slide_show_height = $height;
// some typical movie variables
Ming_setScale((20.00000000)*($scale/100));
ming_useswfversion(6);
$movie=new SWFMovie();
$movie->setBackground(33,33,33);
$movie->setRate((4)*($rate/100));
$movie->setDimension($slide_show_width,$slide_show_height);
// basic actionscript control of playback using mouse
$strAction="
if(!init){
init=true;
stopped=false;
controls = {
onMouseDown: function () {
if(!stopped){
stop();
stopped=true;
}else{
play();
stopped=false;
}
}
};
Mouse.addListener(controls);
}
";
$movie->add(new SWFAction($strAction));
// grab the jpgs
$f = array();
for($i=0;$i<count($pathtojpgs);$i++){
$f[$i] = array();
if ($handle = opendir($pathtojpgs[$i])) {
while (false !== ($file = readdir($handle))) {
$tmp = explode(".",$file);
if( ($tmp[1]=="jpg") && (substr($tmp[0],((strlen($tmp[0]))-7),strlen($tmp[0]))=="capture") ) {
array_push ($f[$i],$pathtojpgs[$i] . $file);
}
}
}
sort($f[$i]);
}
closedir($handle);
// add the jpgs to the movie with basic fade in/out
$movie->nextFrame();
for($i=0;$i<count($f);$i++){
for($k=0;$k<count($f[$i]);$k++){
$img = new SWFBitmap(fopen($f[$i][$k],"rb"));
$pic=$movie->add($img);
$pic->moveTo( ((($slide_show_width)/2)-$img->getwidth()/2),((($slide_show_height)/2)-$img->getheight()/2));
$movie->nextFrame();
$movie->remove($pic);
}
}
$movie->nextFrame();
// save the movie
$movie->save("swf/slideshow.swf",9);
}
?>
The code that creates the SWF file is a modified version of sample code at a link off the
http://ming.sf.net website. This is the site with the original code:
http://www16.brinkster.com/gazb/ming/index.html . The sample code is called "jpg slideshow version 2.0".
I also created a folder called "swf" that user apache owns has write access to. It will store a SWF file called "slideshow.swf".
Installing ming is tough. You have to use the CVS version (that is what I use). You need some packages installed before compiling: php-devel, ungif-devel, bison, flex, and some others. Read the documentation.
I hope everyone enjoys this.