File: /home/httpd/html/freecams1.com/public_html/admin/cli/regenSingleVideoThumbs.php
<?
require("../../mb.php");
require_once("$basepath/admin/getid3/getid3.php");
if(is_numeric($argv[1])) {
$id = (int)$argv[1];
} else {
exit("Usage: php regenSingleVideoThumbs.php 12345 (where 12345 is the video id)\n");
}
if (is_odd($thumbwidth)) {
$thumbwidth++;
}
if (is_odd($thumbheight)) {
$thumbheight++;
}
$result = dbQuery("SELECT * FROM content WHERE record_num = '$id'", false);
foreach ($result as $row) {
$i = $row['filename'];
$first = $row['filename'][0];
$second = $row['filename'][1];
$third = $row['filename'][2];
$forth = $row['filename'][3];
$fifth = $row['filename'][4];
@mkdir($thumb_path.'/'.$first);
@mkdir($thumb_path.'/'.$first.'/'.$second);
@mkdir($thumb_path.'/'.$first.'/'.$second.'/'.$third);
@mkdir($thumb_path.'/'.$first.'/'.$second.'/'.$third.'/'.$forth);
@mkdir($thumb_path.'/'.$first.'/'.$second.'/'.$third.'/'.$forth.'/'.$fifth);
$subdir = $first . '/' . $second . '/' . $third . '/' . $forth . '/' . $fifth . '/';
@mkdir($subdir.$i);
$target_movie = $video_path . "/" . $subdir . $i;
$rrow['id'] = uniqid();
if (1) {
$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze("$video_path/$subdir" . $row['filename']);
$reallengthid3 = $ThisFileInfo['playtime_string'];
$thisarray = explode(':', $reallengthid3);
if(count($thisarray) == 3) {
$length = ($thisarray[0]*3600)+($thisarray[1]*60)+$thisarray[2];
} else {
$length = ($thisarray[0]*60)+$thisarray[1];
}
$movie_width = $ThisFileInfo['video']['resolution_x'];
$movie_height = $ThisFileInfo['video']['resolution_y'];
if($numFrames == 0) {
$numFrames = $length*15;
}
dbReconnect();
dbQuery("UPDATE content SET length = '$length' WHERE record_num = '$rrow[id]'");
$dirname = str_replace('.flv', '', $row['orig_filename']);
@mkdir($basepath.'/media/thumbs/' . $subdir . $dirname);
//create thumbnails
echo "Total Length: $length\n";
$interval = floor($length / 13);
$first = 1;
for ($i = 0; $i < 11; $i++) {
if ($first) {
$target_image = "$thumb_path/$subdir$dirname/" . $row['orig_filename'] . "-$i.jpg";
$target_imageb = "$thumb_path/$subdir$dirname/" . $row['orig_filename'] . "-$i" . "b" . ".jpg";
if ($length) {
echo "Creating thumb #$i at second: $first...";
unlink($target_image);
unlink($target_imageb);
shell_exec("$ffmpeg_path -ss $first -i \"" . "$video_path/$subdir" . $row['filename'] . "\" -vcodec mjpeg -vframes 1 -an -f rawvideo -s " . $thumbwidth . "x" . $thumbheight . " \"$target_image\"");
shell_exec("$ffmpeg_path -ss $first -i \"" . "$video_path/$subdir" . $row['filename'] . "\" -vcodec mjpeg -vframes 1 -an -f rawvideo \"$target_imageb\"");
if (file_exists($target_image)) {
echo "Success!\n";
} else {
echo "Failure! Unable to create thumbnail!\n";
}
if (file_exists("/usr/local/bin/mogrify")) {
shell_exec("/usr/local/bin/mogrify $imagick_command $target_image");
} else {
shell_exec("/usr/bin/mogrify $imagick_command $target_image");
}
}
$first = $first + $interval;
}
}
echo "Success!\n\n";
$counter++;
}
}
echo "\n----------------------\nComplete";