Update web frontend to correctly display video events
This commit is contained in:
parent
2dcee75100
commit
76c8190e8b
|
@ -32,7 +32,7 @@ public function index() {
|
||||||
};
|
};
|
||||||
|
|
||||||
$this->paginate = array(
|
$this->paginate = array(
|
||||||
'fields' => array('Event.Name', 'Event.Length', 'Event.MonitorId', 'Event.Id', 'Monitor.Name', 'Event.MaxScore', 'Event.Width', 'Event.Height', 'Event.StartTime', 'Event.TotScore', 'Event.AvgScore', 'Event.Cause', 'Event.AlarmFrames', 'TIMESTAMPDIFF (SECOND, Event.StartTime, Event.EndTime) AS Duration' ),
|
'fields' => array('Event.Name', 'Event.Length', 'Event.MonitorId', 'Event.Id', 'Monitor.Name', 'Event.MaxScore', 'Event.Width', 'Event.Height', 'Event.StartTime', 'Event.TotScore', 'Event.AvgScore', 'Event.Cause', 'Event.Videoed', 'Event.AlarmFrames', 'TIMESTAMPDIFF (SECOND, Event.StartTime, Event.EndTime) AS Duration' ),
|
||||||
'limit' => Configure::read('ZM_WEB_EVENTS_PER_PAGE'),
|
'limit' => Configure::read('ZM_WEB_EVENTS_PER_PAGE'),
|
||||||
'order' => array( 'Event.Id' => 'asc'),
|
'order' => array( 'Event.Id' => 'asc'),
|
||||||
'conditions' => $conditions
|
'conditions' => $conditions
|
||||||
|
@ -56,7 +56,7 @@ $this->set('minutes', $minutes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function view($id = null) {
|
public function view($id = null) {
|
||||||
$this->layout = 'popup';
|
$this->layout = false;
|
||||||
|
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
throw new NotFoundException(__('Invalid event'));
|
throw new NotFoundException(__('Invalid event'));
|
||||||
|
@ -66,6 +66,8 @@ $this->set('minutes', $minutes);
|
||||||
if (!$event) {
|
if (!$event) {
|
||||||
throw new NotFoundException(__('Invalid event'));
|
throw new NotFoundException(__('Invalid event'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->set('event', $event);
|
$this->set('event', $event);
|
||||||
|
|
||||||
if (!strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
|
if (!strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
|
||||||
|
@ -73,7 +75,7 @@ $this->set('minutes', $minutes);
|
||||||
} else {
|
} else {
|
||||||
$videoFormat = 'mp4';
|
$videoFormat = 'mp4';
|
||||||
}
|
}
|
||||||
$this->set('videoSrc', $this->Event->createVideo( $id, $videoFormat, 100, 100 ));
|
$this->set('videoSrc', $this->Event->createVideo( $event['Event'], $videoFormat, 100, 100 ));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,8 +100,13 @@ function getDiskSpace()
|
||||||
$frame = array('FrameId' => $frame, 'Type' => '');
|
$frame = array('FrameId' => $frame, 'Type' => '');
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the path to the capture image
|
// This is the path to the capture image. Use the video snapshot image if it is available
|
||||||
$captImage = sprintf("%0".$zm_event_image_digits."d-capture.jpg", $frame['FrameId']);
|
if($event['Videoed'] ){
|
||||||
|
$captImage = "snapshot.jpg";
|
||||||
|
}else{
|
||||||
|
$captImage = sprintf("%0".$zm_event_image_digits."d-capture.jpg", $frame['FrameId']);
|
||||||
|
}
|
||||||
|
|
||||||
$captPath = $eventPath.'/'.$captImage;
|
$captPath = $eventPath.'/'.$captImage;
|
||||||
$thumbCaptPath = $zm_dir_images.'/'.$event['Id'].'-'.$captImage;
|
$thumbCaptPath = $zm_dir_images.'/'.$event['Id'].'-'.$captImage;
|
||||||
|
|
||||||
|
|
|
@ -17,20 +17,26 @@ class Event extends AppModel {
|
||||||
);
|
);
|
||||||
|
|
||||||
function createVideo( $event, $format, $rate, $scale, $overwrite=false ) {
|
function createVideo( $event, $format, $rate, $scale, $overwrite=false ) {
|
||||||
$command = Configure::read('ZM_PATH_BIN')."/zmvideo.pl -e ".$event." -f ".$format." -r ".sprintf( "%.2F", ($rate/100) );
|
|
||||||
if ( preg_match( '/\d+x\d+/', $scale ) )
|
|
||||||
$command .= " -S ".$scale;
|
|
||||||
else
|
|
||||||
if ( version_compare( phpversion(), "4.3.10", ">=") )
|
|
||||||
$command .= " -s ".sprintf( "%.2F", ($scale/100) );
|
|
||||||
else
|
|
||||||
$command .= " -s ".sprintf( "%.2f", ($scale/100) );
|
|
||||||
if ( $overwrite )
|
|
||||||
$command .= " -o";
|
|
||||||
|
|
||||||
$result = exec( escapeshellcmd( $command ), $output, $status );
|
if ($event['Videoed']){
|
||||||
$videoSrc = str_replace(Configure::read('ZM_PATH_WEB'), '', $result);
|
$videoSrc = "/events/" . $this->getEventPath($event) . "/event.mp4";
|
||||||
return( $status?"":rtrim($videoSrc) );
|
return $videoSrc;
|
||||||
|
}else{
|
||||||
|
$command = Configure::read('ZM_PATH_BIN')."/zmvideo.pl -e ".$event['Id']." -f ".$format." -r ".sprintf( "%.2F", ($rate/100) );
|
||||||
|
if ( preg_match( '/\d+x\d+/', $scale ) )
|
||||||
|
$command .= " -S ".$scale;
|
||||||
|
else
|
||||||
|
if ( version_compare( phpversion(), "4.3.10", ">=") )
|
||||||
|
$command .= " -s ".sprintf( "%.2F", ($scale/100) );
|
||||||
|
else
|
||||||
|
$command .= " -s ".sprintf( "%.2f", ($scale/100) );
|
||||||
|
if ( $overwrite )
|
||||||
|
$command .= " -o";
|
||||||
|
|
||||||
|
$result = exec( escapeshellcmd( $command ), $output, $status );
|
||||||
|
$videoSrc = str_replace(Configure::read('ZM_PATH_WEB'), '', $result);
|
||||||
|
return( $status?"":rtrim($videoSrc) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
|
<div id="videoPopup" style="display: inline-block; margin: 20px; padding-right: 40px;">
|
||||||
|
|
||||||
<video src="<?php echo $videoSrc; ?>" controls>
|
<video src="<?php echo $videoSrc; ?>" controls>
|
||||||
</video>
|
</video>
|
||||||
|
|
||||||
<p>Event <?php echo $event['Event']['Id']; ?> started at <?php echo $event['Event']['StartTime']; ?> and lasted for <?php echo $event['Event']['Length']; ?> seconds, containing <?php echo $event['Event']['Frames']; ?> frames.</p>
|
<p>Event <?php echo $event['Event']['Id']; ?> started at <?php echo $event['Event']['StartTime']; ?> and lasted for <?php echo $event['Event']['Length']; ?> seconds, containing <?php echo $event['Event']['Frames']; ?> frames.</p>
|
||||||
|
|
||||||
|
</div>
|
|
@ -60,7 +60,9 @@ $(document).ready(function() {
|
||||||
// Events //
|
// Events //
|
||||||
$("#Events a").colorbox({
|
$("#Events a").colorbox({
|
||||||
rel: 'events',
|
rel: 'events',
|
||||||
preloading: true,
|
onComplete : function() {
|
||||||
|
$(this).colorbox.resize();
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue