$event = dbFetchOne($sql, NULL, array($_REQUEST['eid'])); $deviceWidth = isset($device) && !empty($device['width']) ? $device['width'] : DEVICE_WIDTH; $deviceHeight = isset($device) && !empty($device['height']) ? $device['height'] : DEVICE_HEIGHT; if ($deviceWidth >= 352 && $deviceHeight >= 288) { $videoSize = "352x288"; } elseif ($deviceWidth >= 176 && $deviceHeight >= 144) { $videoSize = "176x144"; } else { $videoSize = "128x96"; } $eventWidth = $event['Width']; $eventHeight = $event['Height']; if (!isset($rate)) { $_REQUEST['rate'] = reScale(RATE_BASE, $event['DefaultRate'], ZM_WEB_DEFAULT_RATE); } $eventPath = ZM_DIR_EVENTS . '/' . getEventPath($event); $videoFormats = array(); $ffmpegFormats = preg_split('/\\s+/', ZM_FFMPEG_FORMATS); foreach ($ffmpegFormats as $ffmpegFormat) { preg_match('/^([^*]+)(\\**)$/', $ffmpegFormat, $matches); $videoFormats[$matches[1]] = $matches[1]; if ($matches[2] == '*') { $defaultVideoFormat = $matches[1]; } elseif ($matches[2] == '**') { $defaultPhoneFormat = $matches[1]; } } if (!isset($_REQUEST['videoFormat'])) { if (isset($defaultPhoneFormat)) { $_REQUEST['videoFormat'] = $defaultPhoneFormat; } elseif (isset($defaultVideoFormat)) {
function getImageSrc($event, $frame, $scale = SCALE_BASE, $captureOnly = false, $overwrite = false) { $eventPath = getEventPath($event); if (!is_array($frame)) { $frame = array('FrameId' => $frame, 'Type' => ''); } //echo "S:$scale, CO:$captureOnly<br>"; $captImage = sprintf("%0" . ZM_EVENT_IMAGE_DIGITS . "d-capture.jpg", $frame['FrameId']); $captPath = $eventPath . '/' . $captImage; $thumbCaptPath = ZM_DIR_IMAGES . '/' . $event['Id'] . '-' . $captImage; //echo "CI:$captImage, CP:$captPath, TCP:$thumbCaptPath<br>"; $analImage = sprintf("%0" . ZM_EVENT_IMAGE_DIGITS . "d-analyse.jpg", $frame['FrameId']); $analPath = $eventPath . '/' . $analImage; $analFile = ZM_DIR_EVENTS . "/" . $analPath; $thumbAnalPath = ZM_DIR_IMAGES . '/' . $event['Id'] . '-' . $analImage; //echo "AI:$analImage, AP:$analPath, TAP:$thumbAnalPath<br>"; $alarmFrame = $frame['Type'] == 'Alarm'; $hasAnalImage = $alarmFrame && file_exists($analFile) && filesize($analFile); $isAnalImage = $hasAnalImage && !$captureOnly; if (!ZM_WEB_SCALE_THUMBS || $scale >= SCALE_BASE || !function_exists('imagecreatefromjpeg')) { $imagePath = $thumbPath = $isAnalImage ? $analPath : $captPath; $imageFile = ZM_DIR_EVENTS . "/" . $imagePath; $thumbFile = ZM_DIR_EVENTS . "/" . $thumbPath; } else { if (version_compare(phpversion(), "4.3.10", ">=")) { $fraction = sprintf("%.3F", $scale / SCALE_BASE); } else { $fraction = sprintf("%.3f", $scale / SCALE_BASE); } $scale = (int) round($scale); $thumbCaptPath = preg_replace("/\\.jpg\$/", "-{$scale}.jpg", $thumbCaptPath); $thumbAnalPath = preg_replace("/\\.jpg\$/", "-{$scale}.jpg", $thumbAnalPath); if ($isAnalImage) { $imagePath = $analPath; $thumbPath = $thumbAnalPath; } else { $imagePath = $captPath; $thumbPath = $thumbCaptPath; } $imageFile = ZM_DIR_EVENTS . "/" . $imagePath; //$thumbFile = ZM_DIR_EVENTS."/".$thumbPath; $thumbFile = $thumbPath; if ($overwrite || !file_exists($thumbFile) || !filesize($thumbFile)) { // Get new dimensions list($imageWidth, $imageHeight) = getimagesize($imageFile); $thumbWidth = $imageWidth * $fraction; $thumbHeight = $imageHeight * $fraction; // Resample $thumbImage = imagecreatetruecolor($thumbWidth, $thumbHeight); $image = imagecreatefromjpeg($imageFile); imagecopyresampled($thumbImage, $image, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imageWidth, $imageHeight); if (!imagejpeg($thumbImage, $thumbFile)) { Error("Can't create thumbnail '{$thumbPath}'"); } } } $imageData = array('eventPath' => $eventPath, 'imagePath' => $imagePath, 'thumbPath' => $thumbPath, 'imageFile' => $imageFile, 'thumbFile' => $thumbFile, 'imageClass' => $alarmFrame ? "alarm" : "normal", 'isAnalImage' => $isAnalImage, 'hasAnalImage' => $hasAnalImage); //echo "IP:$imagePath<br>"; //echo "TP:$thumbPath<br>"; return $imageData; }
} else { $midSql = ''; } $sql = "select E.*,M.Name as MonitorName,M.Width,M.Height,M.DefaultRate,M.DefaultScale from Events as E inner join Monitors as M on E.MonitorId = M.Id where E.Id = " . dbEscape($_REQUEST['eid']) . $midSql; $event = dbFetchOne($sql); if (isset($_REQUEST['rate'])) { $rate = validInt($_REQUEST['rate']); } else { $rate = reScale(RATE_BASE, $event['DefaultRate'], ZM_WEB_DEFAULT_RATE); } if (isset($_REQUEST['scale'])) { $scale = validInt($_REQUEST['scale']); } else { $scale = reScale(SCALE_BASE, $event['DefaultScale'], ZM_WEB_DEFAULT_SCALE); } $eventPath = getEventPath($event); $videoFormats = array(); $ffmpegFormats = preg_split('/\\s+/', ZM_FFMPEG_FORMATS); foreach ($ffmpegFormats as $ffmpegFormat) { if (preg_match('/^([^*]+)(\\*\\*?)$/', $ffmpegFormat, $matches)) { $videoFormats[$matches[1]] = $matches[1]; if (!isset($videoFormat) && $matches[2] == "*") { $videoFormat = $matches[1]; } } else { $videoFormats[$ffmpegFormat] = $ffmpegFormat; } } $videoFiles = array(); if ($dir = opendir($eventPath)) { while (($file = readdir($dir)) !== false) {
echo translate('ViewEvent'); ?> " title="<?php echo translate('ViewEvent'); ?> "/>--> <!-- width="<?php echo $event['Width']; ?> " height="<?php echo $event['Height']; ?> " --> <video id="preview" width="100%" controls> <source src="<?php echo "/events/" . getEventPath($event) . "/event.mp4"; ?> " type="video/mp4"> Your browser does not support the video tag. </video> </div> </div> <div id="dataPanel"> <div id="textPanel"> <div id="instruction"> <p><?php echo translate('TimelineTip1'); ?> </p> <p><?php
"><?php echo strftime(STRF_FMT_DATETIME_SHORT, strtotime($event['StartTime'])); ?> </span></td> <td class="right"><span id="dataDuration" title="<?php echo $SLANG['Duration']; ?> "><?php echo $event['Length']; ?> </span>s</td> </tr> </table> <div id="imageFeed"> <img src="events/<?php echo getEventPath($event); ?> /001-capture.jpg" id="img_0" alt="" /> </div> <div id="videoExport"> <span id="progress"></span> <input type="submit" value="Play" id="btnPlay" disabled="disabled"></input> <input type="submit" value="Pause" id="btnPause"></input> <input type="submit" value="Delete" id="btnDelete"></input> <input type="submit" value="Export Video" id="btnVideo"></input> <input type="submit" value="Export Images" id="btnExport"></input> <span id="spinner"></span> </div> <div id="eventStills"></div> </div> </div>