modified : thumbs generation new schema completed
This commit is contained in:
parent
43f2255e11
commit
d13ede073e
7 changed files with 433 additions and 188 deletions
|
@ -115,6 +115,9 @@
|
|||
//$ffmpeg->logs = $log;
|
||||
logData('Going to call ClipBucket Function','checkpoints');
|
||||
$ffmpeg->ClipBucket();
|
||||
logData($ffmpeg->video_files,'video_files');
|
||||
$video_files = json_encode($ffmpeg->video_files);
|
||||
$db->update(tbl('video'), array("video_files"), array($video_files), " file_name = '{$outputFileName}'");
|
||||
|
||||
|
||||
if (stristr(PHP_OS, 'WIN'))
|
||||
|
|
|
@ -31,7 +31,8 @@ if($myquery->VideoExists($video)){
|
|||
$data = get_video_details($video);
|
||||
#pr($data,true);
|
||||
$vid_file = VIDEOS_DIR.'/'.$data['file_directory'].'/'.get_video_file($data,false,false);
|
||||
# Uploading Thumbs
|
||||
|
||||
# Uploading Thumbss
|
||||
if(isset($_POST['upload_thumbs'])){
|
||||
|
||||
if($data['files_thumbs_path']!=''){
|
||||
|
@ -74,18 +75,13 @@ if($myquery->VideoExists($video)){
|
|||
e(lang($response),'e');
|
||||
}
|
||||
else{
|
||||
$Upload->upload_thumbs($data['file_name'],$_FILES['vid_thumb'],$data['file_directory']);
|
||||
$Upload->upload_thumbs($data['file_name'],$_FILES['vid_thumb'],$data['file_directory'],$data['thumbs_version']);
|
||||
}
|
||||
}
|
||||
|
||||
// # Uploading Big Thumb
|
||||
// if(isset($_POST['upload_big_thumb'])) {
|
||||
// $Upload->upload_big_thumb($data['file_name'],$_FILES['big_thumb']);
|
||||
// }
|
||||
|
||||
|
||||
# Delete Thumb
|
||||
if(isset($_GET['delete'])){
|
||||
$data = get_video_details($video);
|
||||
if($data['files_thumbs_path']!=''){
|
||||
#pr($data,true);
|
||||
$files_thumbs_path= $data['files_thumbs_path'];
|
||||
|
@ -120,36 +116,53 @@ if($myquery->VideoExists($video)){
|
|||
|
||||
}else
|
||||
{
|
||||
delete_video_thumb($data['file_directory'],$_GET['delete']);
|
||||
$file_name_num = explode('-', $_GET['delete']);
|
||||
$num = get_thumb_num($_GET['delete']);
|
||||
|
||||
$file_name = $file_name_num[0];
|
||||
|
||||
delete_video_thumb($data['file_directory'],$file_name,$num);
|
||||
}
|
||||
}
|
||||
|
||||
//echo $data['file_directory'].$data['file_name'];
|
||||
# Generating more thumbs
|
||||
if(isset($_GET['gen_more']))
|
||||
{
|
||||
$num = config('num_thumbs');
|
||||
$dim = '503x283';
|
||||
$big_dim = config('big_thumb_width').'x'.config('big_thumb_height');
|
||||
$thumbs_settings_28 = thumbs_res_settings_28();
|
||||
$vid_file = get_high_res_file($data,true);
|
||||
$thumbs_num = config('num_thumbs');
|
||||
|
||||
$thumbs_input['vid_file'] = $vid_file;
|
||||
$thumbs_input['num'] = $thumbs_num;
|
||||
$thumbs_input['duration'] = $data['duration'];
|
||||
|
||||
|
||||
$thumbs_input['file_directory'] = $data['file_directory'];
|
||||
$thumbs_input['file_name'] = $data['file_name'];
|
||||
|
||||
|
||||
require_once(BASEDIR.'/includes/classes/sLog.php');
|
||||
$log = new SLog();
|
||||
$configs = array();
|
||||
|
||||
require_once(BASEDIR.'/includes/classes/conversion/ffmpeg.class.php');
|
||||
$ffmpeg = new FFMpeg($configs, $log);
|
||||
$ffmpeg->regenerateThumbs($vid_file,$data['file_directory'],$data['duration'],$dim,$num,$rand=NULL,$is_big=false,$data['file_name']);
|
||||
e(lang('Video thumbs has been regenrated successfully'),'m');
|
||||
|
||||
|
||||
//pr($thumbs_settings_28,true);
|
||||
foreach ($thumbs_settings_28 as $key => $thumbs_size) {
|
||||
$height_setting = $thumbs_size[1];
|
||||
$width_setting = $thumbs_size[0];
|
||||
$thumbs_input['dim'] = $width_setting.'x'.$height_setting;
|
||||
if($key == 'original'){
|
||||
$thumbs_input['dim'] = $key;
|
||||
$thumbs_input['size_tag'] = $key;
|
||||
}else{
|
||||
$thumbs_input['size_tag'] = $width_setting.'x'.$height_setting;
|
||||
}
|
||||
$ffmpeg->generateThumbs($thumbs_input);
|
||||
}
|
||||
|
||||
/*
|
||||
require_once(BASEDIR.'/includes/classes/conversion/ffmpeg.class.php');
|
||||
$ffmpeg = new FFMpeg();
|
||||
//Generating Thumbs
|
||||
$ffmpeg->generate_Thumbs($vid_file,$data['duration'],$dim,$num,$rand=NULL,$is_big=false);
|
||||
//Generating Big Thumb
|
||||
$ffmpeg->generate_thumbs($vid_file,$data['duration'],$big_dim,$num,true,true);
|
||||
*/
|
||||
e(lang('Video thumbs has been regenrated successfully'),'m');
|
||||
$db->update(tbl('video'), array("thumbs_version"), array("2.8"), " file_name = '".$data['file_name']."' ");
|
||||
}
|
||||
|
||||
Assign('data',$data);
|
||||
|
|
|
@ -35,6 +35,13 @@ class FFMpeg{
|
|||
public $big_thumb_dim = "";
|
||||
public $cb_combo_res = "";
|
||||
public $res_configurations = "";
|
||||
public $thumbs_res_settings = array(
|
||||
"original" => "original",
|
||||
'80' => array('128','80'),
|
||||
'240' => array('384','240'),
|
||||
'320' => array('512','320'),
|
||||
'480' => array('768','480')
|
||||
);
|
||||
public $res169 = array(
|
||||
'240' => array('428','240'),
|
||||
'360' => array('640','360'),
|
||||
|
@ -346,14 +353,6 @@ class FFMpeg{
|
|||
$this->output = new stdClass();
|
||||
$this->output->videoDetails = $videoDetails;
|
||||
|
||||
//$this->logs->writeLine("Thumbs Generation", "Starting");
|
||||
$this->log .= "\r\n Starting : Thumbs Generation \r\n";
|
||||
try{
|
||||
$this->generateThumbs($this->inputFile, $videoDetails['duration']);
|
||||
}catch(Exception $e){
|
||||
$this->log .= "\r\nErrot Occured : ".$e->getMessage()."\r\n";
|
||||
}
|
||||
|
||||
/*
|
||||
Comversion Starts here
|
||||
*/
|
||||
|
@ -420,6 +419,7 @@ class FFMpeg{
|
|||
|
||||
if (file_exists($this->sdFile))
|
||||
{
|
||||
$this->video_files[] = 'sd';
|
||||
$this->sdFile1 = "{$this->outputFile}.{$this->options['format']}";
|
||||
$path = explode("/", $this->sdFile1);
|
||||
$name = array_pop($path);
|
||||
|
@ -459,7 +459,7 @@ class FFMpeg{
|
|||
$this->log .= "\r\n output : ".$output." \r\n";
|
||||
if (file_exists($this->hdFile))
|
||||
{
|
||||
|
||||
$this->video_files[] = 'hd';
|
||||
$this->sdFile1 = "{$this->outputFile}.{$this->options['format']}";
|
||||
$path = explode("/", $this->sdFile1);
|
||||
$name = array_pop($path);
|
||||
|
@ -498,6 +498,7 @@ class FFMpeg{
|
|||
$this->log .= "\r\n output : ".$output." \r\n";
|
||||
if (file_exists($this->sdFile))
|
||||
{
|
||||
$this->video_files[] = 'sd';
|
||||
$this->sdFile1 = "{$this->outputFile}.{$this->options['format']}";
|
||||
//logData(json_encode($this->sdFile1));
|
||||
$path = explode("/", $this->sdFile1);
|
||||
|
@ -884,6 +885,35 @@ class FFMpeg{
|
|||
$nr='360';
|
||||
/*End*/
|
||||
|
||||
//$this->logs->writeLine("Thumbs Generation", "Starting");
|
||||
$this->log .= "\r\n ====== Starting : Thumbs Generation ======= \r\n";
|
||||
$this->log .= "\r\n === OutPut Thumbs Files === \r\n";
|
||||
try{
|
||||
$thumbs_settings = $this->thumbs_res_settings;
|
||||
logData($thumbs_settings,'checkpoints');
|
||||
foreach ($thumbs_settings as $key => $thumbs_size){
|
||||
$height_setting = $thumbs_size[1];
|
||||
$width_setting = $thumbs_size[0];
|
||||
$dimension_setting = $width_setting.'x'.$height_setting;
|
||||
if($key == 'original'){
|
||||
$dimension_setting = $key;
|
||||
$dim_identifier = $key;
|
||||
}else{
|
||||
$dim_identifier = $width_setting.'x'.$height_setting;
|
||||
}
|
||||
$thumbs_settings['vid_file'] = $this->input_file;
|
||||
$thumbs_settings['duration'] = $this->input_details['duration'];
|
||||
$thumbs_settings['num'] = thumbs_number;
|
||||
$thumbs_settings['dim'] = $dimension_setting;
|
||||
$thumbs_settings['size_tag'] = $dim_identifier;
|
||||
$this->generateThumbs($thumbs_settings);
|
||||
}
|
||||
|
||||
}catch(Exception $e){
|
||||
$this->log .= "\r\n Errot Occured : ".$e->getMessage()."\r\n";
|
||||
}
|
||||
$this->log .= "\r\n ====== End : Thumbs Generation ======= \r\n";
|
||||
|
||||
logData('Parsing configurations to Video convert Functions','checkpoints');
|
||||
$hr = $this->configs['high_res'];
|
||||
$this->configs['video_width'] = $res[$nr][0];
|
||||
|
@ -902,11 +932,6 @@ class FFMpeg{
|
|||
{
|
||||
case 'yes':
|
||||
{
|
||||
|
||||
|
||||
|
||||
/*$configs = $this->configs;
|
||||
logdata($configs,'checkpoints');*/
|
||||
$res169 = $this->reindex_required_resolutions($res169);
|
||||
|
||||
logdata($res169,'checkpoints');
|
||||
|
@ -959,20 +984,7 @@ class FFMpeg{
|
|||
$this->log .= "\r\n\r\nTime Took : ";
|
||||
$this->log .= $this->total_time.' seconds'."\r\n\r\n";
|
||||
|
||||
|
||||
$this->gen_thumbs = true;
|
||||
$this->gen_big_thumb = true;
|
||||
|
||||
//Generating Thumb
|
||||
//logData($this->input_file.$this->output_details['duration'],"thumb");
|
||||
if ($this->resolutions == 'yes')
|
||||
{
|
||||
$this->thumb_dim = config('thumb_width').'x'.config('thumb_height');
|
||||
$this->big_thumb_dim = config('big_thumb_width').'x'.config('big_thumb_height');
|
||||
$this->generateThumbs($this->input_file, $this->output_details['duration'],$this->thumb_dim,thumbs_number,NULL);
|
||||
$this->generateThumbs($this->input_file, $this->output_details['duration'],$this->big_thumb_dim,thumbs_number,NULL,"big");
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(!file_exists($this->output_file))
|
||||
$this->log("conversion_status","failed");
|
||||
|
@ -1935,10 +1947,27 @@ class FFMpeg{
|
|||
return false;
|
||||
}
|
||||
|
||||
private function generateThumbs($input_file,$duration,$dim='501x283',$num=thumbs_number,$rand=NULL,$is_big=false){
|
||||
|
||||
$tmpDir = TEMP_DIR.'/'.getName($input_file);
|
||||
public function generateThumbs($array){
|
||||
|
||||
$input_file = $array['vid_file'];
|
||||
$duration = $array['duration'];
|
||||
$dim = $array['dim'];
|
||||
$num = $array['num'];
|
||||
if (!empty($array['size_tag'])){
|
||||
$size_tag= $array['size_tag'];
|
||||
}
|
||||
if (!empty($array['file_directory'])){
|
||||
$regenerateThumbs = true;
|
||||
$file_directory = $array['file_directory'];
|
||||
}
|
||||
if (!empty($array['file_name'])){
|
||||
$filename = $array['file_name'];
|
||||
}
|
||||
if (!empty($array['rand'])){
|
||||
$rand = $array['rand'];
|
||||
}
|
||||
|
||||
$tmpDir = TEMP_DIR.'/'.getName($input_file);
|
||||
|
||||
/*
|
||||
The format of $this->options["outputPath"] should be like this
|
||||
|
@ -1948,19 +1977,30 @@ class FFMpeg{
|
|||
if(substr($this->options["outputPath"], strlen($this->options["outputPath"]) - 1) !== "/"){
|
||||
$this->options["outputPath"] .= "/";
|
||||
}
|
||||
mkdir($tmpDir,0777);
|
||||
|
||||
|
||||
mkdir($tmpDir,0777);
|
||||
|
||||
$output_dir = THUMBS_DIR;
|
||||
$dimension = '';
|
||||
|
||||
$big = "";
|
||||
|
||||
if($is_big=='big')
|
||||
if(!empty($size_tag))
|
||||
{
|
||||
$big = 'big-';
|
||||
$size_tag = $size_tag.'-';
|
||||
}
|
||||
|
||||
if (!empty($file_directory && !empty($filename))){
|
||||
$thumbs_outputPath = $file_directory.'/';
|
||||
}else{
|
||||
$thumbs_outputPath = $this->options['outputPath'];
|
||||
}
|
||||
|
||||
|
||||
if($dim!='original'){
|
||||
$dimension = " -s $dim ";
|
||||
}
|
||||
|
||||
if($num > 1 && $duration > 14)
|
||||
{
|
||||
$duration = $duration - 5;
|
||||
|
@ -1970,23 +2010,23 @@ class FFMpeg{
|
|||
|
||||
for($id=3;$id<=$duration;$id++)
|
||||
{
|
||||
$file_name = getName($input_file)."-{$big}{$count}.jpg";
|
||||
$file_path = THUMBS_DIR.'/' . $this->options['outputPath'] . $file_name;
|
||||
if (empty($filename)){
|
||||
$file_name = getName($input_file)."-{$size_tag}{$count}.jpg";
|
||||
}else{
|
||||
$file_name = $filename."-{$size_tag}{$count}.jpg";
|
||||
}
|
||||
|
||||
$file_path = THUMBS_DIR.'/' . $thumbs_outputPath . $file_name;
|
||||
$id = $id + $division - 1;
|
||||
|
||||
if($rand != "") {
|
||||
$time = $this->ChangeTime($id,1);
|
||||
} elseif($rand == "") {
|
||||
$time = $this->ChangeTime($id);
|
||||
}
|
||||
|
||||
if($dim!='original')
|
||||
{
|
||||
$dimension = " -s $dim ";
|
||||
$mplayer_dim = "-vf scale=$width:$height";
|
||||
}
|
||||
|
||||
$command = $this->ffMpegPath." -i $input_file -an -ss $time -an -r 1 $dimension -y -f image2 -vframes 1 $file_path ";
|
||||
|
||||
/*logdata("Thumbs COmmand : ".$command,'checkpoints');*/
|
||||
$output = $this->executeCommand($command);
|
||||
//$this->//logData($output);
|
||||
//checking if file exists in temp dir
|
||||
|
@ -1995,12 +2035,25 @@ class FFMpeg{
|
|||
rename($tmpDir.'/00000001.jpg',THUMBS_DIR.'/'.$file_name);
|
||||
}
|
||||
$count = $count+1;
|
||||
if (!$regenerateThumbs){
|
||||
$this->log .= "\r\n File : $file_path ";
|
||||
}
|
||||
|
||||
}
|
||||
}else{
|
||||
$file_name = getName($input_file)."-{$big}1.jpg";
|
||||
$file_path = THUMBS_DIR.'/' . $this->options['outputPath'] . "/" . $file_name;
|
||||
$command = $this->ffMpegPath." -i $input_file -an -s $dim -y -f image2 -vframes $num $file_path ";
|
||||
|
||||
if (empty($filename)){
|
||||
$file_name = getName($input_file)."-{$size_tag}1.jpg";
|
||||
}else{
|
||||
$file_name = $filename."-{$size_tag}1.jpg";
|
||||
}
|
||||
|
||||
$file_path = THUMBS_DIR.'/' . $thumbs_outputPath . $file_name;
|
||||
echo $command = $this->ffMpegPath." -i $input_file -an $dimension -y -f image2 -vframes $num $file_path ";
|
||||
$output = $this->executeCommand($command);
|
||||
if (!$regenerateThumbs){
|
||||
$this->log .= "\r\n File : $file_path ";
|
||||
}
|
||||
}
|
||||
|
||||
rmdir($tmpDir);
|
||||
|
@ -2044,17 +2097,12 @@ public function regenerateThumbs($input_file,$test,$duration,$dim,$num,$rand=NUL
|
|||
$id = $id + $division - 1;
|
||||
$time = $this->ChangeTime($id,1);
|
||||
|
||||
|
||||
|
||||
|
||||
if($dim!='original')
|
||||
{
|
||||
$dimension = " -s $dim ";
|
||||
$mplayer_dim = "-vf scale=$width:$height";
|
||||
}
|
||||
|
||||
|
||||
|
||||
$command = $this->ffMpegPath." -i $input_file -an -ss $time -an -r 1 $dimension -y -f image2 -vframes 1 $file_path ";
|
||||
|
||||
$output = $this->executeCommand($command);
|
||||
|
|
|
@ -181,7 +181,10 @@ class Upload{
|
|||
$query_field[] = "video_version";
|
||||
$query_val[] = '2.7';
|
||||
|
||||
|
||||
//thumbs_version
|
||||
$query_field[] = "thumbs_version";
|
||||
$query_val[] = '2.8';
|
||||
|
||||
//Upload Ip
|
||||
$query_field[] = "uploader_ip";
|
||||
$query_val[] = $_SERVER['REMOTE_ADDR'];
|
||||
|
@ -271,46 +274,42 @@ class Upload{
|
|||
*/
|
||||
function get_available_file_num($file_name,$big=false)
|
||||
{
|
||||
// echo dir;
|
||||
|
||||
//Starting from 1
|
||||
|
||||
$code = 1;
|
||||
if($big)
|
||||
$big = "big-";
|
||||
|
||||
if(dir!=NULL)
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
|
||||
$path = THUMBS_DIR.'/'.dir.'/'.$file_name.'-'.$big.$code.'.';
|
||||
if(!file_exists($path.'jpg') && !file_exists($path.'png') && !file_exists($path.'gif'))
|
||||
break;
|
||||
else
|
||||
$code = $code + 1;
|
||||
}
|
||||
}
|
||||
if(defined('dir')){
|
||||
|
||||
while(1){
|
||||
//setting variable for CB 2.8 gretaer versions
|
||||
$path = THUMBS_DIR.'/'.dir.'/'.$file_name.'-original-'.$code.'.';
|
||||
if(!file_exists($path.'jpg') && !file_exists($path.'png') && !file_exists($path.'gif')){
|
||||
//setting variable for CB 2.8 lower versions
|
||||
$path = THUMBS_DIR.'/'.dir.'/'.$file_name.'-'.$big.$code.'.';
|
||||
}
|
||||
|
||||
else{
|
||||
|
||||
while(1)
|
||||
{
|
||||
$path = THUMBS_DIR.'/'.$file_name.'-'.$big.$code.'.';
|
||||
if(!file_exists($path.'jpg') && !file_exists($path.'png') && !file_exists($path.'gif'))
|
||||
if(!file_exists($path.'jpg') && !file_exists($path.'png') && !file_exists($path.'gif'))
|
||||
break;
|
||||
else
|
||||
$code = $code + 1;
|
||||
}
|
||||
}else{
|
||||
|
||||
while(1){
|
||||
$path = THUMBS_DIR.'/'.$file_name.'-'.$big.$code.'.';
|
||||
if(!file_exists($path.'jpg') && !file_exists($path.'png') && !file_exists($path.'gif'))
|
||||
break;
|
||||
else
|
||||
$code = $code + 1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $code;
|
||||
else
|
||||
$code = $code + 1;
|
||||
}
|
||||
}
|
||||
return $code;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function upload_thumb($file_name,$file_array,$key=0,$files_dir=NULL)
|
||||
function upload_thumb($file_name,$file_array,$key=0,$files_dir=NULL,$thumbs_ver=false)
|
||||
{
|
||||
|
||||
global $imgObj,$LANG;
|
||||
|
@ -318,29 +317,55 @@ class Upload{
|
|||
if(!empty($file['name'][$key]))
|
||||
{
|
||||
define('dir',$files_dir);
|
||||
define('t_width','501');
|
||||
define('t_height','283');
|
||||
|
||||
|
||||
$file_num = $this->get_available_file_num($file_name);
|
||||
$ext = getExt($file['name'][$key]);
|
||||
if($imgObj->ValidateImage($file['tmp_name'][$key],$ext))
|
||||
{
|
||||
if($files_dir!=NULL){
|
||||
//One more IF statement considering CB 2.8.1 thumbs strucure
|
||||
//Author : Fahad Abbas
|
||||
if (!empty($thumbs_ver) && $thumbs_ver == '2.8'){
|
||||
|
||||
$file_path = THUMBS_DIR.'/'.$files_dir.'/'.$file_name.'-'.$file_num.'.'.$ext;
|
||||
$big_file_path = THUMBS_DIR.'/'.$files_dir.'/'.$file_name.'-big-'.$file_num.'.'.$ext;
|
||||
$thumbs_settings_28 = thumbs_res_settings_28();
|
||||
$temp_file_path = THUMBS_DIR.'/'.$files_dir.'/'.$file_name.'-'.$file_num.'.'.$ext;
|
||||
|
||||
$imageDetails = getimagesize($file['tmp_name'][$key]);
|
||||
|
||||
move_uploaded_file($file['tmp_name'][$key],$temp_file_path);
|
||||
|
||||
foreach ($thumbs_settings_28 as $key => $thumbs_size) {
|
||||
$height_setting = $thumbs_size[1];
|
||||
$width_setting = $thumbs_size[0];
|
||||
if ( $key != 'original' ){
|
||||
$dimensions = implode('x',$thumbs_size);
|
||||
}else{
|
||||
$dimensions = 'original';
|
||||
$width_setting = $imageDetails[0];
|
||||
$height_setting = $imageDetails[1];
|
||||
}
|
||||
$outputFilePath = THUMBS_DIR.'/'.$files_dir.'/'.$file_name.'-'.$dimensions.'-'.$file_num.'.'.$ext;
|
||||
$imgObj->CreateThumb($temp_file_path,$outputFilePath,$width_setting,$ext,$height_setting,false);
|
||||
}
|
||||
|
||||
unlink($temp_file_path);
|
||||
|
||||
}else{
|
||||
if($files_dir!=NULL){
|
||||
$file_path = THUMBS_DIR.'/'.$files_dir.'/'.$file_name.'-'.$file_num.'.'.$ext;
|
||||
$big_file_path = THUMBS_DIR.'/'.$files_dir.'/'.$file_name.'-big-'.$file_num.'.'.$ext;
|
||||
}
|
||||
else{
|
||||
$file_path = THUMBS_DIR.'/'.$file_name.'-'.$file_num.'.'.$ext;
|
||||
$big_file_path = THUMBS_DIR.'/'.$file_name.'-big-'.$file_num.'.'.$ext;
|
||||
}
|
||||
move_uploaded_file($file['tmp_name'][$key],$file_path);
|
||||
$imgObj->CreateThumb($file_path,$big_file_path,config('big_thumb_width'),$ext,config('big_thumb_height'),false);
|
||||
$imgObj->CreateThumb($file_path,$file_path,config('thumb_width'),$ext,config('thumb_height'),false);
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
$file_path = THUMBS_DIR.'/'.$file_name.'-'.$file_num.'.'.$ext;
|
||||
$big_file_path = THUMBS_DIR.'/'.$file_name.'-big-'.$file_num.'.'.$ext;
|
||||
}
|
||||
|
||||
move_uploaded_file($file['tmp_name'][$key],$file_path);
|
||||
|
||||
$imgObj->CreateThumb($file_path,$big_file_path,config('big_thumb_width'),$ext,config('big_thumb_height'),false);
|
||||
$imgObj->CreateThumb($file_path,$file_path,t_width,$ext,t_height,false);
|
||||
e(lang('upload_vid_thumb_msg'.THUMB_WIDTH),'m');
|
||||
e(lang('upload_vid_thumb_msg'),'m');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -372,19 +397,19 @@ class Upload{
|
|||
* @param $_FILES array name
|
||||
*/
|
||||
|
||||
function upload_thumbs($file_name,$file_array,$files_dir=NULL)
|
||||
function upload_thumbs($file_name,$file_array,$files_dir=NULL,$thumbs_ver=false)
|
||||
{
|
||||
global $LANG;
|
||||
if(count($file_array[name])>1)
|
||||
{
|
||||
for($i=0;$i<count($file_array['name']);$i++)
|
||||
{
|
||||
$this->upload_thumb($file_name,$file_array,$i,$files_dir);
|
||||
$this->upload_thumb($file_name,$file_array,$i,$files_dir,$thumbs_ver);
|
||||
}
|
||||
e(lang('upload_vid_thumbs_msg'),'m');
|
||||
}else{
|
||||
$file = $file_array;
|
||||
$this->upload_thumb($file_name,$file,$key=0,$files_dir);
|
||||
$this->upload_thumb($file_name,$file,$key=0,$files_dir,$thumbs_ver);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -572,36 +572,15 @@ class CBvideo extends CBCategory
|
|||
{
|
||||
if (strstr($thumb,'timthumb'))
|
||||
$thumb = $this->convert_tim_thumb_url_to_file($thumb,$file_name=false);
|
||||
else
|
||||
$thumb = substr($thumb, 0, -6);
|
||||
|
||||
$file = THUMBS_DIR.'/'.$thumb;
|
||||
if(file_exists($file) && is_file($file))
|
||||
if (!empty($vdetails['file_directory'])){
|
||||
$file = THUMBS_DIR.'/'.$vdetails['file_directory'].'/'.$thumb;
|
||||
}else{
|
||||
$file = THUMBS_DIR.'/'.$thumb;
|
||||
}
|
||||
|
||||
if(file_exists($file) && is_file($file)){
|
||||
unlink($file);
|
||||
}
|
||||
|
||||
foreach($thumbs as $thumb)
|
||||
{
|
||||
|
||||
if (strstr($thumb,'timthumb'))
|
||||
$fn = $this->convert_tim_thumb_url_to_file($thumb,$file_name=true);
|
||||
else
|
||||
$fn = substr($thumb, 0, -6);
|
||||
|
||||
$result = db_select("SELECT * FROM ".tbl("video")." WHERE file_name = '$fn'");
|
||||
if($result)
|
||||
{
|
||||
|
||||
foreach($result as $result1)
|
||||
{
|
||||
$str = '/'.$result1['file_directory'].'/';
|
||||
$file1 = THUMBS_DIR.$str.$thumb;
|
||||
if(file_exists($file1) && is_file($file1))
|
||||
{
|
||||
unlink($file1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -211,7 +211,7 @@ function get_thumb($vdetails,$num='default',$multi=false,$count=false,$return_fu
|
|||
$file_dir = "/" . $thumbDir;
|
||||
}
|
||||
$vid_thumbs = glob(THUMBS_DIR."/" .$file_dir.$vdetails['file_name']."*");
|
||||
|
||||
|
||||
|
||||
#replace Dir with URL
|
||||
if(is_array($vid_thumbs))
|
||||
|
@ -222,17 +222,25 @@ function get_thumb($vdetails,$num='default',$multi=false,$count=false,$return_fu
|
|||
$thumb_parts = explode('/',$thumb);
|
||||
$thumb_file = $thumb_parts[count($thumb_parts)-1];
|
||||
|
||||
if(!is_big($thumb_file) || $return_big)
|
||||
{
|
||||
//Saving All Thumbs
|
||||
if(!is_big($thumb_file) || $return_big){
|
||||
if($return_full_path)
|
||||
$thumbs[] = THUMBS_URL.'/'. $thumbDir . $thumb_file;
|
||||
else
|
||||
$thumbs[] = $thumb_file;
|
||||
}
|
||||
//Saving Original Thumbs
|
||||
if (is_original($thumb_file)){
|
||||
if($return_full_path)
|
||||
$original_thumbs[] = THUMBS_URL.'/'. $thumbDir . $thumb_file;
|
||||
else
|
||||
$original_thumbs[] = $thumb_file;
|
||||
}
|
||||
|
||||
}elseif(file_exists($thumb))
|
||||
unlink($thumb);
|
||||
}
|
||||
|
||||
#pr($thumbs,true);
|
||||
if(count($thumbs)==0)
|
||||
{
|
||||
if($count)
|
||||
|
@ -243,8 +251,18 @@ function get_thumb($vdetails,$num='default',$multi=false,$count=false,$return_fu
|
|||
}
|
||||
else
|
||||
{
|
||||
if($multi)
|
||||
return $thumbs;
|
||||
|
||||
//Initializing thumbs settings
|
||||
$thumbs_res_settings = thumbs_res_settings_28();
|
||||
|
||||
if($multi){
|
||||
if (!empty($original_thumbs) && $size == 'original'){
|
||||
return $original_thumbs;
|
||||
}else{
|
||||
return $thumbs;
|
||||
}
|
||||
}
|
||||
|
||||
if($count)
|
||||
return count($thumbs);
|
||||
|
||||
|
@ -257,20 +275,41 @@ function get_thumb($vdetails,$num='default',$multi=false,$count=false,$return_fu
|
|||
{
|
||||
|
||||
$num = 'big-'.$vdetails['default_thumb'];
|
||||
if(!file_exists(THUMBS_DIR.'/'.$vdetails['file_name'].'-'.$num.'.jpg'))
|
||||
$num = 'big';
|
||||
$num_big_28 = implode('x', $thumbs_res_settings['320']).'-'.$vdetails['default_thumb'];
|
||||
|
||||
$big_thumb_cb26 = THUMBS_DIR.'/'.$vdetails['file_name'].'-'.$num.'.jpg';
|
||||
$big_thumb_cb27 = THUMBS_DIR.'/'.$thumbDir.$vdetails['file_name'].'-'.$num.'.jpg';
|
||||
$big_thumb_cb28 = THUMBS_DIR.'/'.$thumbDir.$vdetails['file_name'].'-'.$num_big_28.'.jpg';
|
||||
|
||||
if(file_exists($big_thumb_cb26)){
|
||||
return THUMBS_URL.'/'.$vdetails['file_name'].'-'.$num.'.jpg';
|
||||
}elseif (file_exists($big_thumb_cb27)){
|
||||
return THUMBS_URL.'/'.$thumbDir.$vdetails['file_name'].'-'.$num.'.jpg';
|
||||
}elseif (file_exists($big_thumb_cb28)){
|
||||
return THUMBS_URL.'/'.$thumbDir.$vdetails['file_name'].'-'.$num_big_28.'.jpg';
|
||||
}
|
||||
}
|
||||
|
||||
$default_thumb = array_find($vdetails['file_name'].'-'.$num,$thumbs);
|
||||
|
||||
if(!empty($default_thumb))
|
||||
$default_thumb = array_find($vdetails['file_name'].'-'.$size.'-'.$num,$thumbs);
|
||||
|
||||
if(!empty($default_thumb)){
|
||||
return $default_thumb;
|
||||
return $thumbs[0];
|
||||
}
|
||||
elseif(empty($default_thumb)){
|
||||
$default_thumb = array_find($vdetails['file_name'].'-'.$num,$thumbs);
|
||||
if (!empty($default_thumb)){
|
||||
return $default_thumb;
|
||||
}else{
|
||||
return $thumbs[0];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Function used to check weaether given thumb is big or not
|
||||
*/
|
||||
|
@ -281,6 +320,18 @@ function is_big($thumb_file)
|
|||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used to check weaether given thumb is original or not
|
||||
*/
|
||||
function is_original($thumb_file)
|
||||
{
|
||||
if(strstr($thumb_file,'original'))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function GetThumb($vdetails,$num='default',$multi=false,$count=false)
|
||||
{
|
||||
|
||||
|
@ -904,24 +955,28 @@ function get_thumb_num($name)
|
|||
|
||||
|
||||
/**
|
||||
* Function used to remove thumb
|
||||
* Function used to remove specific thumbs number
|
||||
*/
|
||||
function delete_video_thumb($file_dir,$file)
|
||||
function delete_video_thumb($file_dir,$file_name,$num)
|
||||
{
|
||||
global $LANG;
|
||||
if($file_dir!=NULL){
|
||||
$path = THUMBS_DIR.'/'.$file_dir.'/'.$file;
|
||||
}
|
||||
else{
|
||||
$path = THUMBS_DIR.'/'.$file;
|
||||
}
|
||||
|
||||
if(file_exists($path))
|
||||
{
|
||||
unlink($path);
|
||||
if(!empty($file_dir)){
|
||||
$files = glob(THUMBS_DIR.'/'.$file_dir.'/'.$file_name.'*'.$num.'.*');
|
||||
}
|
||||
else{
|
||||
$files = glob(THUMBS_DIR.'/'.$file_name.'*'.$num.'.*');
|
||||
}
|
||||
//pr($files,true);
|
||||
|
||||
if ($files){
|
||||
foreach ($files as $key => $file){
|
||||
if (file_exists($file)){
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
e(lang('video_thumb_delete_msg'),'m');
|
||||
}else{
|
||||
e(lang('video_thumb_delete_err'));
|
||||
e(lang('video_thumb_delete_err'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1318,7 +1373,7 @@ function get_video_files($vdetails,$return_default=true,$with_path=true,$multi=f
|
|||
function upload_thumb($array)
|
||||
{
|
||||
|
||||
global $file_name,$LANG;
|
||||
global $file_name,$LANG,$Upload;
|
||||
|
||||
//Get File Name
|
||||
$file = $array['name'];
|
||||
|
@ -1336,14 +1391,32 @@ function upload_thumb($array)
|
|||
//exit($file_directory);
|
||||
}
|
||||
if($image->ValidateImage($array['tmp_name'],$ext)){
|
||||
$file = BASEDIR.'/files/thumbs/'.$file_directory.$_POST['file_name'].'.'.$ext;
|
||||
$bfile = BASEDIR.'/files/thumbs/'.$file_directory.$_POST['file_name'].'.-big.'.$ext;
|
||||
if(!file_exists($file))
|
||||
{
|
||||
move_uploaded_file($array['tmp_name'],$file);
|
||||
$image->CreateThumb($file,$bfile,config('big_thumb_width'),$ext,config('big_thumb_height'),false);
|
||||
$image->CreateThumb($file,$file,THUMB_WIDTH,$ext,THUMB_HEIGHT,false);
|
||||
|
||||
$imageDetails = getimagesize($array['tmp_name']);
|
||||
$file_num = $Upload->get_available_file_num($_POST['file_name']);
|
||||
$temp_file = THUMBS_DIR.'/'.$file_directory.'/'.$_POST['file_name'].'-'.$file_num.'.'.$ext;
|
||||
|
||||
move_uploaded_file($array['tmp_name'],$temp_file);
|
||||
|
||||
$thumbs_settings_28 = thumbs_res_settings_28();
|
||||
|
||||
foreach ($thumbs_settings_28 as $key => $thumbs_size) {
|
||||
|
||||
$height_setting = $thumbs_size[1];
|
||||
$width_setting = $thumbs_size[0];
|
||||
if ( $key != 'original' ){
|
||||
$dimensions = implode('x',$thumbs_size);
|
||||
}else{
|
||||
$dimensions = 'original';
|
||||
$width_setting = $imageDetails[0];
|
||||
$height_setting = $imageDetails[1];
|
||||
}
|
||||
|
||||
$outputFilePath = THUMBS_DIR.'/'.$file_directory.'/'.$_POST['file_name'].'-'.$dimensions.'-'.$file_num.'.'.$ext;
|
||||
//echo $outputFilePath.'<br>';
|
||||
$image->CreateThumb($temp_file,$outputFilePath,$width_setting,$ext,$height_setting,false);
|
||||
}
|
||||
unlink($temp_file);
|
||||
}else{
|
||||
e(lang('vdo_thumb_up_err'));
|
||||
}
|
||||
|
@ -1528,4 +1601,108 @@ function is_phone_user( $data )
|
|||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @author : Fahad Abbas
|
||||
* @param : { Null }
|
||||
* @return : { Array } { Clipbucket version 2.8 thumbs default settings }
|
||||
* @date : 02-03-2016
|
||||
*/
|
||||
function thumbs_res_settings_28(){
|
||||
|
||||
$thumbs_res_settings = array(
|
||||
"original" => "original",
|
||||
'80' => array('128','80'),
|
||||
'240' => array('384','240'),
|
||||
'320' => array('512','320'),
|
||||
'480' => array('768','480')
|
||||
);
|
||||
|
||||
return $thumbs_res_settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author : Fahad Abbas
|
||||
* @param : { Array } { Video Details }
|
||||
* @return : { Variable or boolean } { Max resolution file }
|
||||
* @date : 03-03-2016
|
||||
*/
|
||||
function get_high_res_file($vdetails,$dir=false){
|
||||
//Getting video Files array
|
||||
$video_files = $vdetails['video_files'];
|
||||
$video_files = json_decode($video_files,true);
|
||||
//Getting video actual files source
|
||||
$v_files = get_video_files($vdetails,true,true);
|
||||
|
||||
if (empty($v_files)){
|
||||
return false;
|
||||
}
|
||||
//Checking if video_files field is not empty (greater versions than CB 2.8)
|
||||
if (!empty($video_files)){
|
||||
|
||||
$pre_check_file = $video_files[0];
|
||||
if (is_int($pre_check_file)){
|
||||
$max_file_res = max($video_files);
|
||||
}else{
|
||||
if (in_array("hd", $video_files)) {
|
||||
$max_file_res = "hd";
|
||||
}else{
|
||||
$max_file_res = "sd";
|
||||
}
|
||||
|
||||
}
|
||||
}else{
|
||||
//Checking if video_files field is empty (lower versions than CB 2.8.1)
|
||||
foreach ($v_files as $key => $file) {
|
||||
$video_files[] = get_video_file_quality($file);
|
||||
}
|
||||
$pre_check_file = $video_files[0];
|
||||
if (is_int($pre_check_file)){
|
||||
$max_file_res = max($video_files);
|
||||
}else{
|
||||
if (in_array("hd", $video_files)) {
|
||||
$max_file_res = "hd";
|
||||
}else{
|
||||
$max_file_res = "sd";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// now saving the max resolution file in a variable
|
||||
|
||||
if ($dir){
|
||||
$Ext = GetExt($v_files[0]);
|
||||
$max_res_file = VIDEOS_DIR.'/'.$vdetails['file_directory'].'/'.$vdetails['file_name'].'-'.$max_file_res.'.'.$Ext;
|
||||
|
||||
}else{
|
||||
|
||||
foreach ($v_files as $key => $file) {
|
||||
$video_quality = get_video_file_quality($file);
|
||||
if ($max_file_res == $video_quality){
|
||||
$max_res_file = $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($max_res_file)){
|
||||
return $max_res_file;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author : Fahad Abbas
|
||||
* @param : { Var } { quality of input file }
|
||||
* @return : { Variable } { resolution of a file }
|
||||
* @date : 03-03-2016
|
||||
*/
|
||||
function get_video_file_quality($file){
|
||||
|
||||
$quality = explode('-',$file);
|
||||
$quality = end($quality);
|
||||
$quality = explode('.',$quality);
|
||||
$quality = $quality[0];
|
||||
return $quality;
|
||||
|
||||
}
|
|
@ -10,7 +10,7 @@
|
|||
<span class="duration">{if
|
||||
$video.duration>1}{$video.duration|SetTime}{else}00:00{/if}{*$video.duration|date_format:$config.time*}
|
||||
</span>
|
||||
<img class="img" src="{getThumb vdetails=$video size=500x283 } " border="1" />
|
||||
<img class="img" src="{getThumb vdetails=$video size=384x240 } " border="1" />
|
||||
</a>
|
||||
{ANCHOR place='in_video_thumb' data=$video}
|
||||
<img src="{$imageurl}/dot.gif" data-quick="quick-{$video.videoid}"
|
||||
|
|
Loading…
Add table
Reference in a new issue