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(
|
||||
'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'),
|
||||
'order' => array( 'Event.Id' => 'asc'),
|
||||
'conditions' => $conditions
|
||||
|
@ -56,7 +56,7 @@ $this->set('minutes', $minutes);
|
|||
}
|
||||
|
||||
public function view($id = null) {
|
||||
$this->layout = 'popup';
|
||||
$this->layout = false;
|
||||
|
||||
if (!$id) {
|
||||
throw new NotFoundException(__('Invalid event'));
|
||||
|
@ -66,6 +66,8 @@ $this->set('minutes', $minutes);
|
|||
if (!$event) {
|
||||
throw new NotFoundException(__('Invalid event'));
|
||||
}
|
||||
|
||||
|
||||
$this->set('event', $event);
|
||||
|
||||
if (!strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
|
||||
|
@ -73,7 +75,7 @@ $this->set('minutes', $minutes);
|
|||
} else {
|
||||
$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' => '');
|
||||
}
|
||||
|
||||
// This is the path to the capture image
|
||||
$captImage = sprintf("%0".$zm_event_image_digits."d-capture.jpg", $frame['FrameId']);
|
||||
// This is the path to the capture image. Use the video snapshot image if it is available
|
||||
if($event['Videoed'] ){
|
||||
$captImage = "snapshot.jpg";
|
||||
}else{
|
||||
$captImage = sprintf("%0".$zm_event_image_digits."d-capture.jpg", $frame['FrameId']);
|
||||
}
|
||||
|
||||
$captPath = $eventPath.'/'.$captImage;
|
||||
$thumbCaptPath = $zm_dir_images.'/'.$event['Id'].'-'.$captImage;
|
||||
|
||||
|
|
|
@ -17,20 +17,26 @@ class Event extends AppModel {
|
|||
);
|
||||
|
||||
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";
|
||||
|
||||
if ($event['Videoed']){
|
||||
$videoSrc = "/events/" . $this->getEventPath($event) . "/event.mp4";
|
||||
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) );
|
||||
$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>
|
||||
|
||||
<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 a").colorbox({
|
||||
rel: 'events',
|
||||
preloading: true,
|
||||
onComplete : function() {
|
||||
$(this).colorbox.resize();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue