clean up, give generation options even if viewing. Fix viewing. Add transform option.

pull/3588/head
Isaac Connor 2022-09-06 15:44:09 -04:00
parent d3e3807263
commit 60d01376c5
1 changed files with 54 additions and 30 deletions

View File

@ -77,9 +77,7 @@ if (isset($_REQUEST['deleteIndex'])) {
$deleteIndex = validInt($_REQUEST['deleteIndex']);
unlink($videoFiles[$deleteIndex]);
unset($videoFiles[$deleteIndex]);
}
if (isset($_REQUEST['downloadIndex'])) {
} else if (isset($_REQUEST['downloadIndex'])) {
// can't be output buffering, as this file might be large
ob_end_clean();
$downloadIndex = validInt($_REQUEST['downloadIndex']);
@ -116,16 +114,32 @@ xhtmlHeaders(__FILE__, translate('Video'));
</div>
<div id="content">
<?php
if ( isset($_REQUEST['showIndex']) ) {
if (isset($_REQUEST['showIndex'])) {
$showIndex = validInt($_REQUEST['showIndex']);
preg_match('/([^\/]+)\.([^.]+)$/', $videoFiles[$showIndex], $matches);
$name = $matches[1];
$videoFormat = $matches[2];
$path_parts = pathinfo($videoFiles[$showIndex]);
$width = $event->Width();
$height = $event->Height();
foreach (explode('-', $path_parts['filename']) as $option) {
if ( preg_match('/^s(.+)$/', $option, $temp_matches) ) {
$scale = (int)(preg_replace('/_/', '.', $temp_matches[1]) );
$width = $width * $scale;
$height = $height * $scale;
} elseif ( preg_match('/^S(\d+)x(\d+)$/', $option, $temp_matches) ) {
$width = $temp_matches[1];
$height = $temp_matches[2];
}
}
?>
<h3 id="videoFile"><?php echo substr($videoFiles[$showIndex], strlen(ZM_DIR_EVENTS)+1) ?></h3>
<div id="imageFeed"><?php outputVideoStream('videoStream', $videoFiles[$showIndex], validInt($_REQUEST['width']), validInt($_REQUEST['height']), $videoFormat, $name) ?></div>
<h3 id="videoFile"><?php echo $path_parts['basename'] ?></h3>
<div id="imageFeed"><?php outputVideoStream('videoStream',
'?view=view_video&event_id='.$eid.'&file='.urlencode($path_parts['basename']),
(isset($_REQUEST['width']) ? validInt($_REQUEST['width']) : $width),
(isset($_REQUEST['height']) ? validInt($_REQUEST['height']) : $height),
$path_parts['extension'], $path_parts['filename']) ?></div>
<?php
} else {
}
?>
<form name="contentForm" id="videoForm" method="post" action="?">
<input type="hidden" name="id" value="<?php echo $event->Id() ?>"/>
@ -143,6 +157,18 @@ if ( isset($_REQUEST['showIndex']) ) {
<th class="text-nowrap text-right pr-3" scope="row"><?php echo translate('VideoSize') ?></th>
<td><?php echo buildSelect('scale', $scales) ?></td>
</tr>
<tr>
<th class="text-nowrap text-right pr-3" scope="row"><?php echo translate('Transform') ?></th>
<td>
<?php
$transforms = array(
''=>translate('None'),
'hue=s=0'=>translate('Grayscale'),
);
echo buildSelect('transform', $transforms);
?>
</td>
</tr>
<tr>
<th class="text-nowrap text-right pr-3" scope="row"><?php echo translate('OverwriteExisting') ?></th>
<td><input type="checkbox" name="overwrite" value="1"<?php if ( !empty($_REQUEST['overwrite']) ) { ?> checked="checked"<?php } ?>/></td>
@ -159,7 +185,7 @@ if ( isset($_REQUEST['showIndex']) ) {
<table id="videoTable" class="major">
<thead>
<tr>
<th scope="row"><?php echo translate('Format') ?></th>
<th scope="row"><?php echo translate('Filename') ?></th>
<th scope="row"><?php echo translate('Size') ?></th>
<th scope="row"><?php echo translate('Rate') ?></th>
<th scope="row"><?php echo translate('Scale') ?></th>
@ -177,24 +203,25 @@ if ( isset($_REQUEST['showIndex']) ) {
$index = 0;
foreach ( $videoFiles as $file ) {
if ( filesize($file) > 0 ) {
preg_match('/^(.+)-((?:r[_\d]+)|(?:F[_\d]+))-((?:s[_\d]+)|(?:S[0-9a-z]+))\.([^.]+)$/', $file, $matches);
if ( preg_match('/^r(.+)$/', $matches[2], $temp_matches) ) {
$rate = (int)(100 * preg_replace( '/_/', '.', $temp_matches[1] ) );
$rateText = isset($rates[$rate])?$rates[$rate]:($rate."x");
} elseif ( preg_match('/^F(.+)$/', $matches[2], $temp_matches) ) {
$rateText = $temp_matches[1].'fps';
}
if ( preg_match('/^s(.+)$/', $matches[3], $temp_matches) ) {
$scale = (int)(100 * preg_replace('/_/', '.', $temp_matches[1]) );
$scaleText = isset($scales[$scale])?$scales[$scale]:($scale.'x');
} elseif ( preg_match('/^S(.+)$/', $matches[3], $temp_matches) ) {
$scaleText = $temp_matches[1];
}
$width = $scale?reScale($event->Width(), $scale):$event->Width();
$height = $scale?reScale($event->Height(), $scale):$event->Height();
$path_parts = pathinfo($file);
foreach (explode('-', $path_parts['filename']) as $option) {
if ( preg_match('/^r(.+)$/', $option, $temp_matches) ) {
$rate = (int)(100 * preg_replace( '/_/', '.', $temp_matches[1] ) );
$rateText = isset($rates[$rate])?$rates[$rate]:($rate."x");
} elseif ( preg_match('/^F(.+)$/', $option, $temp_matches) ) {
$rateText = $temp_matches[1].'fps';
} else if ( preg_match('/^s(.+)$/', $option, $temp_matches) ) {
$scale = (int)(100 * preg_replace('/_/', '.', $temp_matches[1]) );
$scaleText = isset($scales[$scale])?$scales[$scale]:($scale.'x');
} elseif ( preg_match('/^S(.+)$/', $option, $temp_matches) ) {
$scaleText = $temp_matches[1];
}
} # end foreach option in filename
?>
<tr>
<td><?php echo $matches[4] ?></td>
<td>
<a href="?view=video&eid=<?php echo $event->Id() ?>&showIndex=<?php echo $index ?>"><?php echo $path_parts['basename'] ?></a></td>
<td><?php echo human_filesize(filesize($file)) ?></td>
<td><?php echo $rateText ?></td>
<td><?php echo $scaleText ?></td>
@ -212,9 +239,6 @@ if ( isset($_REQUEST['showIndex']) ) {
?>
</tbody>
</table>
<?php
}
?>
</div>
</div>
<?php xhtmlFooter() ?>