spacing and quotes

This commit is contained in:
Isaac Connor 2020-07-22 17:28:12 -04:00
parent c2ac7ed4a9
commit 204086a56d
1 changed files with 20 additions and 20 deletions

View File

@ -380,54 +380,54 @@ class Event extends ZM_Object {
$Event = $this;
$eventPath = $Event->Path();
if ( $frame and ! is_array($frame) ) {
if ( $frame and !is_array($frame) ) {
# Must be an Id
Logger::Debug("Assuming that $frame is an Id");
$frame = array( 'FrameId'=>$frame, 'Type'=>'', 'Delta'=>0 );
$frame = array('FrameId'=>$frame, 'Type'=>'', 'Delta'=>0);
}
if ( ( ! $frame ) and file_exists($eventPath.'/snapshot.jpg') ) {
if ( ( !$frame ) and file_exists($eventPath.'/snapshot.jpg') ) {
# No frame specified, so look for a snapshot to use
$captImage = 'snapshot.jpg';
Logger::Debug("Frame not specified, using snapshot");
$frame = array('FrameId'=>'snapshot', 'Type'=>'','Delta'=>0);
Logger::Debug('Frame not specified, using snapshot');
$frame = array('FrameId'=>'snapshot', 'Type'=>'', 'Delta'=>0);
} else {
$captImage = sprintf( '%0'.ZM_EVENT_IMAGE_DIGITS.'d-analyze.jpg', $frame['FrameId'] );
$captImage = sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d-analyze.jpg', $frame['FrameId']);
if ( ! file_exists( $eventPath.'/'.$captImage ) ) {
$captImage = sprintf( '%0'.ZM_EVENT_IMAGE_DIGITS.'d-capture.jpg', $frame['FrameId'] );
if ( ! file_exists( $eventPath.'/'.$captImage ) ) {
$captImage = sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d-capture.jpg', $frame['FrameId']);
if ( !file_exists($eventPath.'/'.$captImage) ) {
# Generate the frame JPG
if ( $Event->DefaultVideo() ) {
$videoPath = $eventPath.'/'.$Event->DefaultVideo();
if ( ! file_exists( $videoPath ) ) {
Error("Event claims to have a video file, but it does not seem to exist at $videoPath" );
if ( !file_exists($videoPath) ) {
Error('Event claims to have a video file, but it does not seem to exist at '.$videoPath);
return '';
}
#$command ='ffmpeg -v 0 -i '.$videoPath.' -vf "select=gte(n\\,'.$frame['FrameId'].'),setpts=PTS-STARTPTS" '.$eventPath.'/'.$captImage;
$command ='ffmpeg -ss '. $frame['Delta'] .' -i '.$videoPath.' -frames:v 1 '.$eventPath.'/'.$captImage;
Logger::Debug( "Running $command" );
Logger::Debug('Running '.$command);
$output = array();
$retval = 0;
exec( $command, $output, $retval );
exec($command, $output, $retval);
Logger::Debug("Retval: $retval, output: " . implode("\n", $output));
} else {
Error("Can't create frame images from video because there is no video file for event ".$Event->Id().' at ' .$Event->Path() );
Error('Can\'t create frame images from video because there is no video file for event '.$Event->Id().' at ' .$Event->Path());
}
} // end if capture file exists
} // end if analyze file exists
} // end if frame or snapshot
$captPath = $eventPath.'/'.$captImage;
if ( ! file_exists($captPath) ) {
Error("Capture file does not exist at $captPath");
if ( !file_exists($captPath) ) {
Error('Capture file does not exist at '.$captPath);
}
$analImage = sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d-analyse.jpg', $frame['FrameId']);
$analPath = $eventPath.'/'.$analImage;
$alarmFrame = $frame['Type']=='Alarm';
$alarmFrame = $frame['Type'] == 'Alarm';
$hasAnalImage = $alarmFrame && file_exists($analPath) && filesize($analPath);
$isAnalImage = $hasAnalImage && !$captureOnly;
@ -443,8 +443,8 @@ class Event extends ZM_Object {
$fraction = sprintf('%.3f', $scale/SCALE_BASE);
$scale = (int)round($scale);
$thumbCaptPath = preg_replace( '/\.jpg$/', "-$scale.jpg", $captPath );
$thumbAnalPath = preg_replace( '/\.jpg$/', "-$scale.jpg", $analPath );
$thumbCaptPath = preg_replace('/\.jpg$/', "-$scale.jpg", $captPath);
$thumbAnalPath = preg_replace('/\.jpg$/', "-$scale.jpg", $analPath);
if ( $isAnalImage ) {
$imagePath = $analPath;
@ -457,7 +457,7 @@ class Event extends ZM_Object {
$thumbFile = $thumbPath;
if ( $overwrite || ! file_exists($thumbFile) || ! filesize($thumbFile) ) {
// Get new dimensions
list( $imageWidth, $imageHeight ) = getimagesize($imagePath);
list($imageWidth, $imageHeight) = getimagesize($imagePath);
$thumbWidth = $imageWidth * $fraction;
$thumbHeight = $imageHeight * $fraction;
@ -484,7 +484,7 @@ class Event extends ZM_Object {
);
return $imageData;
}
} # getImageSrc
public function link_to($text=null) {
if ( !$text )