Fixed : New conversion system
Added : New profile based conversion Implemented : New Conversion KIT
This commit is contained in:
parent
f236a9e1fb
commit
dfb0e69e2a
11 changed files with 3380 additions and 3558 deletions
|
@ -133,19 +133,14 @@ switch($mode)
|
|||
move_uploaded_file($tempFile,$targetFile);
|
||||
|
||||
$Upload->add_conversion_queue($targetFileName);
|
||||
$quick_conv = config('quick_conv');
|
||||
|
||||
$use_crons = config('use_crons');
|
||||
if($quick_conv=='yes' || $use_crons=='no')
|
||||
{
|
||||
//exec(php_path()." -q ".BASEDIR."/actions/video_convert.php &> /dev/null &");
|
||||
if (stristr(PHP_OS, 'WIN')) {
|
||||
exec(php_path()." -q ".BASEDIR."/actions/video_convert.php $targetFileName");
|
||||
} else {
|
||||
exec(php_path()." -q ".BASEDIR."/actions/video_convert.php $targetFileName &> /dev/null &");
|
||||
}
|
||||
}
|
||||
|
||||
/* //exec(php_path()." -q ".BASEDIR."/actions/video_convert.php &> /dev/null &");
|
||||
if (stristr(PHP_OS, 'WIN')) {
|
||||
exec(php_path()." -q ".BASEDIR."/actions/video_convert.php $targetFileName");
|
||||
} else {
|
||||
exec(php_path()." -q ".BASEDIR."/actions/video_convert.php $targetFileName &> /dev/null &");
|
||||
}
|
||||
*/
|
||||
echo json_encode(array("success"=>"yes","file_name"=>$file_name));
|
||||
|
||||
}
|
||||
|
|
|
@ -1,215 +1,142 @@
|
|||
<?php
|
||||
/**
|
||||
* Written by : Arslan Hassan
|
||||
* Software : ClipBucket v2
|
||||
* License : Attribution Assurance License -- http://www.opensource.org/licenses/attribution.php
|
||||
*
|
||||
* I have done MANY experiments on video conversion
|
||||
* so these results are the best possible output
|
||||
* you can further discuss about it on forums.clip-bucket.com
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
* @Author : Arslan Hassan
|
||||
* @Since : 2012
|
||||
* @version : 3.0
|
||||
*/
|
||||
$in_bg_cron = true;
|
||||
|
||||
ini_set('mysql.connect_timeout','6000');
|
||||
|
||||
$in_bg_cron = true;
|
||||
//Including new conversion kit, called cb kit.
|
||||
include("../includes/config.inc.php");
|
||||
include("../includes/classes/conversion/conversion.class.php");
|
||||
|
||||
include(dirname(__FILE__)."/../includes/config.inc.php");
|
||||
//Calling Cron Functions
|
||||
cb_call_functions('video_convert_cron');
|
||||
//Initializing new conversio kit
|
||||
$cb_converter = new CBConverter();
|
||||
|
||||
$server_friendly = config('server_friendly_conversion');
|
||||
$use_crons = config('use_crons');
|
||||
|
||||
if($server_friendly=='yes' && $use_crons=='yes')
|
||||
{
|
||||
/**
|
||||
*
|
||||
* Thanks to Erickson Reyes ercbluemonday at yahoo dot com | so processes dont overlap
|
||||
* ref : http://www.php.net/manual/en/function.getmypid.php#94531*/
|
||||
|
||||
// Initialize variables
|
||||
$found = 0;
|
||||
$file = basename(__FILE__);
|
||||
$commands = array();
|
||||
|
||||
// Get running processes.
|
||||
exec("ps w", $commands);
|
||||
|
||||
// If processes are found
|
||||
if (count($commands) > 0) {
|
||||
|
||||
foreach ($commands as $command) {
|
||||
if (strpos($command, $file) === false) {
|
||||
// Do nothin'
|
||||
}
|
||||
else {
|
||||
// Let's count how many times the file is found.
|
||||
$found++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the instance of the file is found more than once.
|
||||
if ($found > 1) {
|
||||
echo "Another process is running.\n";
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
$SYSTEM_OS = $row['sys_os'] ? $row['sys_os'] : 'linux';
|
||||
|
||||
//Including FFMPEG CLASS
|
||||
require_once(BASEDIR.'/includes/classes/conversion/ffmpeg.class.php');
|
||||
|
||||
if($argv[1])
|
||||
$fileName = $argv[1];
|
||||
else
|
||||
$fileName = false;
|
||||
|
||||
if($argv[2] == 'sleep')
|
||||
$dosleep = 'sleep';
|
||||
else
|
||||
$dosleep = '';
|
||||
$max_processes = 5;
|
||||
|
||||
//Get Vido
|
||||
$queue_details = get_queued_video(TRUE,$fileName);
|
||||
if(!$queue_details)
|
||||
exit("Nothing to do");
|
||||
|
||||
|
||||
//Setting up details, moving files
|
||||
$tmp_file = $queue_details['cqueue_name'];
|
||||
$tmp_ext = $queue_details['cqueue_tmp_ext'];
|
||||
$ext = $queue_details['cqueue_ext'];
|
||||
$queued_files = $cbupload->get_queued_files();
|
||||
|
||||
if(!empty($tmp_file)){
|
||||
//Total Running proccesses...
|
||||
$process_running = $cbupload->conversion_count();
|
||||
|
||||
if($process_running<=$max_processes && $queued_files)
|
||||
{
|
||||
foreach($queued_files as $queue)
|
||||
{
|
||||
//Creating dated folders
|
||||
$folder = create_dated_folder(NULL,$queue['date_added']);
|
||||
|
||||
$original_source = ORIGINAL_DIR.'/'.$folder.'/'.$queue['queue_name'].'.'
|
||||
.$queue['queue_ext'];
|
||||
|
||||
$temp_source = TEMP_DIR.'/'.$queue['queue_name'].'.'.$queue['queue_tmp_ext'];
|
||||
|
||||
if(!file_exists($original_source))
|
||||
{
|
||||
if(!@rename($temp_source,$original_source))
|
||||
{
|
||||
echo "Cannot make use of original file...(Err 1)";
|
||||
}else
|
||||
{
|
||||
//Get source information using ffmpeg and save it in our
|
||||
//video file database..
|
||||
$video_info = $cb_converter->getInfo($original_source);
|
||||
|
||||
if($video_info['has_video']=='no')
|
||||
{
|
||||
$cbupload->update_queue_status($queue,'f','Invalid video file');
|
||||
}else
|
||||
{
|
||||
//Add video info
|
||||
$cbupload->add_video_file($queue,$video_info,'s');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(file_exists($original_source))
|
||||
{
|
||||
|
||||
$video_profiles = $cbvid->get_video_profiles();
|
||||
$convert = false;
|
||||
foreach($video_profiles as $vid_profile)
|
||||
{
|
||||
if(!$cbupload->video_file_exists($queue['queue_name'],$queue['queue_id'],$vid_profile['profile_id']))
|
||||
{
|
||||
$convert = true;
|
||||
|
||||
$output_name = $queue['queue_name'].$vid_profile['suffix'].'.'.$vid_profile['ext'];
|
||||
$output_file = VIDEOS_DIR.'/'.$folder.'/'.$output_name;
|
||||
|
||||
$log_file = $folder.'/'.$queue['queue_name'].$vid_profile['suffix'].'-'.$vid_profile['ext'].'.log';
|
||||
|
||||
$temp_file = TEMP_DIR.'/'.$tmp_file.'.'.$tmp_ext;
|
||||
$orig_file = CON_DIR.'/'.$tmp_file.'.'.$ext;
|
||||
$fid = $cbupload->add_video_file($queue,array('noinfo'),'p',$vid_profile['profile_id'],$log_file);
|
||||
$cbupload->update_queue_status($queue,'u','Started conversion using Profile # '.$vid_profile['profile_id'],true);
|
||||
|
||||
echo $log_file = LOGS_DIR.'/'.$log_file;
|
||||
|
||||
//copy($temp_file,$orig_file);
|
||||
rename($temp_file,$orig_file);
|
||||
/** All of our new conversion code is written here **/
|
||||
/** Lets us Prepare the ship, Lets Sail again.. **/
|
||||
|
||||
$res169 = array();
|
||||
$res169['240'] = array('427','240');
|
||||
$res169['360'] = array('640','360');
|
||||
$res169['480'] = array('853','480');
|
||||
$res169['720'] = array('1280','720');
|
||||
$res169['1080'] = array('1920','1080');
|
||||
|
||||
$res43 = array();
|
||||
$res43['240'] = array('320','240');
|
||||
$res43['360'] = array('480','360');
|
||||
$res43['480'] = array('640','480');
|
||||
$res43['720'] = array('960','720');
|
||||
$res43['1080'] = array('1440','1080');
|
||||
|
||||
$configs = array
|
||||
(
|
||||
'use_video_rate' => true,
|
||||
'use_video_bit_rate' => true,
|
||||
'use_audio_rate' => true,
|
||||
'use_audio_bit_rate' => true,
|
||||
'use_audio_codec' => true,
|
||||
'use_video_codec' => true,
|
||||
'format' => 'flv',
|
||||
'video_codec'=> config('video_codec'),
|
||||
'audio_codec'=> config('audio_codec'),
|
||||
'audio_rate'=> config("srate"),
|
||||
'audio_bitrate'=> config("sbrate"),
|
||||
'video_rate'=> config("vrate"),
|
||||
'video_bitrate'=> config("vbrate"),
|
||||
'normal_res' => config('normal_resolution'),
|
||||
'high_res' => config('high_resolution'),
|
||||
'max_video_duration' => config('max_video_duration'),
|
||||
'res169' => $res169,
|
||||
'res43' => $res43,
|
||||
'resize'=>'max'
|
||||
);
|
||||
$converter = new CBConverter($original_source);
|
||||
$converter->set_log($log_file);
|
||||
|
||||
/**
|
||||
* @todo : Add Filters for this params
|
||||
*/
|
||||
|
||||
$twoPass = false;
|
||||
if($vid_profile['2pass']=='yes')
|
||||
$twoPass = true;
|
||||
|
||||
|
||||
$params = array(
|
||||
'format' => $vid_profile['format'],
|
||||
'output_file' => $output_file,
|
||||
'preset' => $vid_profile['preset'],
|
||||
'height' => $vid_profile['height'],
|
||||
'width' => $vid_profile['width'],
|
||||
'resize' => $vid_profile['resize'],
|
||||
'bitrate' => $vid_profile['video_bitrate'],
|
||||
'aspect_ratio' => $vid_profile['aspect_ratio'],
|
||||
'arate' => $vid_profile['audio_rate'],
|
||||
'fps' => $vid_profile['video_rate'],
|
||||
'abitrate' => $vid_profile['audio_bitrate'],
|
||||
'2pass' => $twoPass,
|
||||
);
|
||||
|
||||
|
||||
$converter->convert($params);
|
||||
$output_details = $converter->getInfo($output_file);
|
||||
$time_finished = time();
|
||||
$log = $convert->log();
|
||||
|
||||
$fields = array(
|
||||
'log' => $log,
|
||||
'status' => 's',
|
||||
'output_result' => '|no_mc|'.json_encode($output_details),
|
||||
'date_completed' => $time_finished,
|
||||
);
|
||||
|
||||
$cbupload->update_video_file($fid,$fields);
|
||||
|
||||
unset($converter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$convert)
|
||||
{
|
||||
$cbupload->update_queue_status($queue,'s','File removed from queue');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Calling Functions before converting Video
|
||||
*/
|
||||
if(get_functions('before_convert_functions'))
|
||||
{
|
||||
foreach(get_functions('before_convert_functions') as $func)
|
||||
{
|
||||
if(@function_exists($func))
|
||||
$func();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$ffmpeg = new ffmpeg($orig_file);
|
||||
$ffmpeg->configs = $configs;
|
||||
$ffmpeg->gen_thumbs = TRUE;
|
||||
$ffmpeg->gen_big_thumb = TRUE;
|
||||
$ffmpeg->num_of_thumbs = config('num_thumbs');
|
||||
$ffmpeg->thumb_dim = config('thumb_width')."x".config('thumb_height');
|
||||
$ffmpeg->big_thumb_dim = config('big_thumb_width')."x".config('big_thumb_height');
|
||||
$ffmpeg->tmp_dir = TEMP_DIR;
|
||||
$ffmpeg->input_ext = $ext;
|
||||
$ffmpeg->output_file = VIDEOS_DIR.'/'.$tmp_file.'.flv';
|
||||
$ffmpeg->hq_output_file = VIDEOS_DIR.'/'.$tmp_file.'.mp4';
|
||||
$ffmpeg->raw_path = VIDEOS_DIR.'/'.$tmp_file;
|
||||
$ffmpeg->log_file = LOGS_DIR.'/'.$tmp_file.'.log';
|
||||
//$ffmpeg->remove_input = TRUE;
|
||||
$ffmpeg->keep_original = config('keep_original');
|
||||
$ffmpeg->original_output_path = ORIGINAL_DIR.'/'.$tmp_file.'.'.$ext;
|
||||
$ffmpeg->ClipBucket();
|
||||
|
||||
|
||||
|
||||
|
||||
////exec(php_path()." -q ".BASEDIR."/actions/verify_converted_videos.php &> /dev/null &");
|
||||
if (stristr(PHP_OS, 'WIN'))
|
||||
{
|
||||
exec(php_path()." -q ".BASEDIR."/actions/verify_converted_videos.php $fileName $dosleep");
|
||||
} else {
|
||||
exec(php_path()." -q ".BASEDIR."/actions/verify_converted_videos.php $fileName $dosleep &> /dev/null &");
|
||||
}
|
||||
|
||||
|
||||
//Converting File In HD Format
|
||||
if($ffmpeg->input_details['video_height']>'719')
|
||||
$hq_output = config('hq_output');
|
||||
else
|
||||
$hq_output = 'no';
|
||||
|
||||
|
||||
if($hq_output=='yes' && !$ffmpeg->failed_reason)
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
$use_crons = config('use_crons');
|
||||
|
||||
if(!$ffmpeg->isLocked(PROCESSESS_AT_ONCE) || $use_crons=='yes' || !$ffmpeg->set_conv_lock)
|
||||
{
|
||||
|
||||
$ffmpeg->convert_to_hd();
|
||||
if($ffmpeg->lock_file && file_exists($ffmpeg->lock_file))
|
||||
unlink($ffmpeg->lock_file);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if($use_crons=='no')
|
||||
sleep(10);
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unlink($ffmpeg->input_file);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -63,11 +63,11 @@ Please read more about how to set these configurations <a href="http://docs.clip
|
|||
<td>{$profile.active}</td>
|
||||
<td>{$profile.format}/{$profile.width}x{$profile.height}</td>
|
||||
<td><div class="btn-group">
|
||||
<button class="btn" data-toggle="modal" data-target="#profile-form{$profile.profile_id}">Edit</button>
|
||||
<button class="btn" onclick="cb_confirm('Delete video profile','Are you sure you want to remove {$profile.name} video profile',
|
||||
<span class="btn" data-toggle="modal" data-target="#profile-form{$profile.profile_id}">Edit</span>
|
||||
<span class="btn" onclick="cb_confirm('Delete video profile','Are you sure you want to remove {$profile.name} video profile',
|
||||
function(){
|
||||
$('#delete_profile_id').val('{$profile.profile_id}'); $('#delete_profile').submit();
|
||||
})">Delete</button>
|
||||
})">Delete</span>
|
||||
</div></td>
|
||||
|
||||
</tr>
|
||||
|
|
|
@ -1121,29 +1121,8 @@ ALTER TABLE `{tbl_prefix}collection_categories` ADD `category_icon` VARCHAR( 1
|
|||
ALTER TABLE `{tbl_prefix}playlist_items` ADD `order` BIGINT( 10 ) NOT NULL AFTER `playlist_id`;
|
||||
ALTER TABLE `{tbl_prefix}playlist_items` ADD `item_note` MEDIUMTEXT NOT NULL AFTER `item_order`;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `{tbl_prefix}video_profiles` (
|
||||
`profile_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`format` varchar(100) NOT NULL,
|
||||
`ext` varchar(10) NOT NULL,
|
||||
`suffix` varchar(100) NOT NULL,
|
||||
`height` smallint(5) NOT NULL,
|
||||
`width` smallint(5) NOT NULL,
|
||||
`profile_order` int(10) NOT NULL,
|
||||
`verify_dimension` enum('yes','no') NOT NULL DEFAULT 'yes',
|
||||
`video_codec` varchar(50) NOT NULL,
|
||||
`audio_codec` varchar(50) NOT NULL,
|
||||
`audio_bitrate` mediumint(50) NOT NULL,
|
||||
`video_bitrate` mediumint(50) NOT NULL,
|
||||
`audio_rate` mediumint(50) NOT NULL,
|
||||
`video_rate` mediumint(50) NOT NULL,
|
||||
`resize` enum('none','max','fit','wxh') NOT NULL DEFAULT 'max',
|
||||
`preset` enum('none','low','normal','hq','max') NOT NULL DEFAULT 'normal',
|
||||
`2pass` enum('yes','no') NOT NULL DEFAULT 'no',
|
||||
`apply_watermark` enum('yes','no') NOT NULL,
|
||||
`ffmpeg_cmd` mediumtext NOT NULL,
|
||||
`active` enum('yes','no') NOT NULL DEFAULT 'yes',
|
||||
`date_added` datetime NOT NULL,
|
||||
PRIMARY KEY (`profile_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
||||
ALTER TABLE `{tbl_prefix}conversion_queue` CHANGE `cqueue_conversion` `conversion` ENUM( 'yes', 'no', 'p' ) NOT NULL DEFAULT 'no';
|
||||
ALTER TABLE `{tbl_prefix}conversion_queue` CHANGE `cqueue_id` `queue_id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
|
||||
CHANGE `cqueue_name` `queue_name` VARCHAR( 32 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL ,
|
||||
CHANGE `cqueue_ext` `queue_ext` VARCHAR( 5 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL ,
|
||||
CHANGE `cqueue_tmp_ext` `queue_tmp_ext` VARCHAR( 3 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL;
|
|
@ -87,4 +87,14 @@ CREATE TABLE IF NOT EXISTS `{tbl_prefix}video_profiles` (
|
|||
`active` enum('yes','no') NOT NULL DEFAULT 'yes',
|
||||
`date_added` datetime NOT NULL,
|
||||
PRIMARY KEY (`profile_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
||||
|
||||
DROP TABLE `{tbl_prefix}video_files`;
|
||||
ALTER TABLE `{tbl_prefix}conversion_queue` CHANGE `cqueue_conversion` `conversion` ENUM( 'yes', 'no', 'p' ) NOT NULL DEFAULT 'no';
|
||||
ALTER TABLE `{tbl_prefix}conversion_queue` CHANGE `cqueue_id` `queue_id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
|
||||
CHANGE `cqueue_name` `queue_name` VARCHAR( 32 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL ,
|
||||
CHANGE `cqueue_ext` `queue_ext` VARCHAR( 5 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL ,
|
||||
CHANGE `cqueue_tmp_ext` `queue_tmp_ext` VARCHAR( 3 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL;
|
||||
|
||||
ALTER TABLE `{tbl_prefix}conversion_queue` ADD `status` ENUM( 'u', 's', 'f' ) NOT NULL DEFAULT 'u' AFTER `conversion_counts`;
|
||||
ALTER TABLE `{tbl_prefix}conversion_queue` ADD `messages` TEXT AFTER `status`;
|
|
@ -69,6 +69,12 @@ class CBConverter
|
|||
// 5 channels otherwise it will skipp the step
|
||||
var $valid_two_channels = true;
|
||||
|
||||
|
||||
//Log file where output of every command will be given.
|
||||
//By default is set to false so that defined output file can be used
|
||||
//if value set, this file will be used to save outptu.
|
||||
var $output_log = false;
|
||||
|
||||
/**
|
||||
* Constructor and sets the input file and get information..
|
||||
* @param Video File
|
||||
|
@ -224,6 +230,10 @@ class CBConverter
|
|||
$outputFile = TEMP_DIR.'/'.time().RandomString(5);
|
||||
else
|
||||
$outputFile = TEMP_DIR.'/'.time().mt_rand(5, 6);
|
||||
|
||||
if($this->output_log)
|
||||
$outputFile = $this->output_log;
|
||||
|
||||
$output_cmd = " 2> ".$outputFile;
|
||||
}
|
||||
|
||||
|
@ -762,13 +772,17 @@ class CBConverter
|
|||
'abitrate'=> 128000,
|
||||
'preset' => 'normal',
|
||||
'auto_rotate' => true,
|
||||
|
||||
);
|
||||
|
||||
|
||||
if($params && $defaults)
|
||||
$params = array_merge($defaults, $params);
|
||||
elseif($defaults)
|
||||
$params = $defaults;
|
||||
|
||||
$output_file = $params['output_file'];
|
||||
|
||||
//Creating array to pass to calculateResize func
|
||||
//and get resizeable width and height...
|
||||
|
||||
|
@ -1135,8 +1149,11 @@ class CBConverter
|
|||
}
|
||||
}
|
||||
|
||||
echo $CMD;
|
||||
$CMD .= " ".$output_file;
|
||||
|
||||
$log = $this->exec($CMD);
|
||||
|
||||
return $log;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1545,8 +1562,8 @@ class CBConverter
|
|||
|
||||
$rinfo = $this->calculateResize($dimInfo);
|
||||
|
||||
$pad_width = $rinfo['width'] + ($rinfo['pad_x']*2);
|
||||
$pad_height = $rinfo['height'] + ($rinfo['pad_y']*2);
|
||||
$pad_width = $rinfo['width'] + ($rinfo['pad_x']*2);
|
||||
$pad_height = $rinfo['height'] + ($rinfo['pad_y']*2);
|
||||
|
||||
if(!$params['padding_color'])
|
||||
$pad_color = 'black';
|
||||
|
@ -1634,7 +1651,7 @@ class CBConverter
|
|||
/* Checking if there is some ffmepg execution error */
|
||||
preg_match();
|
||||
|
||||
/* Checking for codec missing erro */
|
||||
/* Checking for codec missing error */
|
||||
|
||||
/* Checking for bitrate/width/etc issue */
|
||||
|
||||
|
@ -1643,5 +1660,22 @@ class CBConverter
|
|||
/* Checking for file missing error */
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* function used to set the log file
|
||||
* Simple set the value for output_log
|
||||
*
|
||||
* @param STRING $file
|
||||
*/
|
||||
function set_log($file=false)
|
||||
{
|
||||
if(!$file)
|
||||
$file = $outputFile = TEMP_DIR.'/'.time().mt_rand(5, 6);
|
||||
|
||||
$this->output_log = $file;
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -763,8 +763,9 @@ class Upload{
|
|||
return false;
|
||||
rename(TEMP_DIR.'/'.$file,TEMP_DIR.'/'.$new_file);
|
||||
//Adding Details to database
|
||||
$db->Execute("INSERT INTO ".tbl("conversion_queue")." (cqueue_name,cqueue_ext,cqueue_tmp_ext,date_added)
|
||||
VALUES ('".$name."','".$ext."','".$tmp_ext."','".NOW()."') ");
|
||||
$db->Execute("INSERT INTO ".tbl("conversion_queue")."
|
||||
(queue_name,queue_ext,queue_tmp_ext,date_added)
|
||||
VALUES ('".$name."','".$ext."','".$tmp_ext."','".NOW()."') ");
|
||||
return $db->insert_id;
|
||||
}else{
|
||||
return false;
|
||||
|
@ -778,24 +779,26 @@ class Upload{
|
|||
*/
|
||||
function video_keygen()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$char_list = "ABDGHKMNORSUXWY";
|
||||
$char_list .= "123456789";
|
||||
while(1)
|
||||
{
|
||||
$vkey = '';
|
||||
srand((double)microtime()*1000000);
|
||||
for($i = 0; $i < 12; $i++)
|
||||
{
|
||||
$vkey .= substr($char_list,(rand()%(strlen($char_list))), 1);
|
||||
}
|
||||
|
||||
if(!vkey_exists($vkey))
|
||||
break;
|
||||
}
|
||||
|
||||
return $vkey;
|
||||
global $db;
|
||||
|
||||
$char_list = "ABDGHKMNORSUXWY";
|
||||
$char_list .= "123456789";
|
||||
$char_list .= "qwdvbnmkpouyt";
|
||||
|
||||
while(1)
|
||||
{
|
||||
$vkey = '';
|
||||
srand((double)microtime()*1000000);
|
||||
for($i = 0; $i < 12; $i++)
|
||||
{
|
||||
$vkey .= substr($char_list,(rand()%(strlen($char_list))), 1);
|
||||
}
|
||||
|
||||
if(!vkey_exists($vkey))
|
||||
break;
|
||||
}
|
||||
|
||||
return $vkey;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1149,5 +1152,293 @@ class Upload{
|
|||
return $hours * 3600 + $minutes * 60 + $seconds;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get files from conversion queue..
|
||||
*
|
||||
* @return ARRAY
|
||||
*/
|
||||
function get_queued_files(){
|
||||
global $db;
|
||||
|
||||
$results = $db->select(tbl("conversion_queue"),"*"," conversion='p' OR conversion='no' ",NULL," conversion_counts ASC ");
|
||||
|
||||
if($db->num_rows>0)
|
||||
{
|
||||
$new_results = array();
|
||||
//Get video files...we can do this by LEFT JOIN but want a child array for this.
|
||||
foreach($results as $result)
|
||||
{
|
||||
|
||||
$result['files'] = $this->get_video_files(array('queue_id'=>$result['queue_id']));
|
||||
$new_results[] = $result;
|
||||
}
|
||||
|
||||
return $new_results;
|
||||
}else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get queue details from database
|
||||
*
|
||||
* get_queue_details
|
||||
*
|
||||
* @param INT queue_id
|
||||
* @return ARRAY queue details with video files
|
||||
*/
|
||||
function get_queue_details($qid)
|
||||
{
|
||||
global $db;
|
||||
$results = $db->select(tbl('conversion_queue'),'*',"queue_id='$qid'");
|
||||
if($db->num_rows>0)
|
||||
{
|
||||
$result = $results[0];
|
||||
$result['files'] = $this->get_video_files(array('queue_id'=>$qid));
|
||||
|
||||
return $result;
|
||||
}else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get video files from database table
|
||||
* this will fetch data from cb_video_files as per given conditions
|
||||
*
|
||||
* @param ARRAY $array a set of conditions
|
||||
* @return ARRAY $output list of files
|
||||
*/
|
||||
function get_video_files($array)
|
||||
{
|
||||
global $db;
|
||||
$array = apply_filters($array,'get_video_files');
|
||||
$cond = "";
|
||||
|
||||
if($array['limit'])
|
||||
$limit = $array['limit'];
|
||||
else
|
||||
$limit = NULL;
|
||||
|
||||
|
||||
if($array['order'])
|
||||
$order = $array['order'];
|
||||
else
|
||||
$order = ' file_id ASC ';
|
||||
|
||||
if($array['queue_id'])
|
||||
$cond = cond(" queue_id = '".$array['queue_id']."' ");
|
||||
|
||||
if($array['file_name'])
|
||||
$cond = cond(" file_name = '".$array['file_name']."' ");
|
||||
|
||||
$cond = apply_filters($cond,'get_video_files_cond');
|
||||
|
||||
|
||||
$results = $db->select(tbl('video_files'),'*',$cond,$limit,$order);
|
||||
|
||||
if($db->num_rows>0)
|
||||
{
|
||||
$output = $results;
|
||||
}else
|
||||
$output = 0;
|
||||
|
||||
$output = apply_filters($output,'get_video_files_output');
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Count number of conversion beein proccessed
|
||||
*
|
||||
* conversions_count
|
||||
*/
|
||||
function conversion_count()
|
||||
{
|
||||
global $db;
|
||||
$count = $db->count(tbl('video_files'),'file_id',"status='p'");
|
||||
return $count;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update queue status..
|
||||
*
|
||||
* @param STRING status
|
||||
* @param STRING message
|
||||
*/
|
||||
function update_queue_status($qid,$status,$message=NULL,$increment=false)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if(is_array($qid))
|
||||
{
|
||||
$queue = $qid;
|
||||
$qid = $queue['queue_id'];
|
||||
}else
|
||||
{
|
||||
$queue = $this->get_queue_details($qid);
|
||||
}
|
||||
|
||||
//Messages Array
|
||||
$messages = $queue['messages'];
|
||||
$messages = json_decode($messages,true);
|
||||
$messages[] = $message;
|
||||
$messages = '|no_mc|'.json_encode($messages);
|
||||
|
||||
$fields = array('conversion','status','messages','conversion_counts','time_completed');
|
||||
$tbl = tbl('conversion_queue');
|
||||
|
||||
$conv_count = $queue['conversion_counts'];
|
||||
|
||||
if($increment)
|
||||
{
|
||||
$conv_count = $conv_count + 1;
|
||||
}
|
||||
|
||||
switch($status)
|
||||
{
|
||||
case "u":
|
||||
{
|
||||
$db->update($tbl,$fields,array('p','u',$messages,$conv_count,time()),"queue_id='$qid'");
|
||||
}
|
||||
break;
|
||||
|
||||
case "s":
|
||||
{
|
||||
$db->update($tbl,$fields,array('yes','s',$messages,$conv_count,time()),"queue_id='$qid'");
|
||||
}
|
||||
break;
|
||||
|
||||
case "f":
|
||||
{
|
||||
$db->update($tbl,$fields,array('yes','f',$messages,$conv_count,time()),"queue_id='$qid'");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add video file
|
||||
*
|
||||
* @param INT queue_id
|
||||
* @param ARRAY video_info
|
||||
* @param INT profile_id
|
||||
*/
|
||||
function add_video_file($qid,$vid_info,$status='p',$profile_id=NULL,$log_file=NULL)
|
||||
{
|
||||
global $db,$cbvid;
|
||||
|
||||
if($profile_id)
|
||||
$profile = $cbvid->get_video_profile($profile_id);
|
||||
|
||||
if(is_array($qid))
|
||||
{
|
||||
$queue = $qid;
|
||||
$qid = $queue['queue_id'];
|
||||
}else
|
||||
{
|
||||
$queue = $this->get_queue_details($qid);
|
||||
}
|
||||
|
||||
|
||||
$fields = array();
|
||||
$values = array();
|
||||
|
||||
|
||||
$is_original = 'no';
|
||||
|
||||
if(!$profile_id)
|
||||
{
|
||||
$is_original = 'yes';
|
||||
$file_ext = $queue['queue_ext'];
|
||||
}else
|
||||
$file_ext = $profile['ext'];
|
||||
|
||||
$directory = create_dated_folder(NULL,$queue['date_added']);
|
||||
$original_source = $queue['queue_name'].'.'.$queue['queue_ext'];
|
||||
$vid_info = '|no_mc|'.json_encode($vid_info);
|
||||
$file_name = $queue['queue_name'];
|
||||
|
||||
$vid_file = $this->video_file_exists($file_name,$qid,$profile_id,$file_ext);
|
||||
|
||||
if($vid_file)
|
||||
return $vid_file['file_id'];
|
||||
|
||||
$fields = array('queue_id','file_name','file_directory',
|
||||
'original_source','is_original','file_ext',
|
||||
'output_results','status','profile_id','date_added','log_file');
|
||||
|
||||
$values = array($qid,$file_name,$directory,$original_source,
|
||||
$is_original,$file_ext,$vid_info,$status,$profile_id,now(),$log_file);
|
||||
|
||||
|
||||
if(!$profile_id)
|
||||
{
|
||||
$fields[] = 'date_completed';
|
||||
$values[] = now();
|
||||
}
|
||||
|
||||
$db->insert(tbl('video_files'),$fields,$values);
|
||||
|
||||
return $db->insert_id();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* update video file info
|
||||
*
|
||||
* @param INT profile_id
|
||||
* @param ARRAY $file_fileds
|
||||
* @param ARRAY $file_values
|
||||
*/
|
||||
function update_video_file($fid,$values)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$flds = array();
|
||||
$vals = array();
|
||||
|
||||
foreach($values as $field => $val)
|
||||
{
|
||||
$flds[] = $field;
|
||||
$vals[] = $val;
|
||||
}
|
||||
|
||||
$db->update(tbl('video_files'),$flds,$vals,"file_id='$fid' ");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* video file exists
|
||||
*
|
||||
* @param file_name
|
||||
* @param Queue_id
|
||||
* @param ext
|
||||
*/
|
||||
function video_file_exists($filename,$queueid=NULL,$profile_id=NULL,$ext=NULL)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$var = " ";
|
||||
|
||||
if($filename)
|
||||
$var = cond("file_name='$filename'","AND",$var);
|
||||
|
||||
if($queueid)
|
||||
$var = cond("queue_id='$queueid'","AND",$var);
|
||||
if($ext)
|
||||
$var = cond("file_ext='$ext'","AND",$var);
|
||||
|
||||
if($profile_id)
|
||||
$var = cond("profile_id='$profile_id'","AND",$var);
|
||||
|
||||
$results = $db->select(tbl('video_files'),"*",$var);
|
||||
|
||||
if($db->num_rows>0)
|
||||
return $results[0];
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1868,7 +1868,7 @@ class CBvideo extends CBCategory
|
|||
*
|
||||
* @param ARRAY for restrictions
|
||||
*/
|
||||
function get_video_profiles($array)
|
||||
function get_video_profiles($array=null)
|
||||
{
|
||||
global $db;
|
||||
|
||||
|
@ -1879,7 +1879,7 @@ class CBvideo extends CBCategory
|
|||
if($array['order'])
|
||||
$order = $array['order'];
|
||||
else
|
||||
$order = ' profile_id ASC ';
|
||||
$order = ' profile_order ASC ';
|
||||
|
||||
if($array['limit'])
|
||||
$limit = $array['limit'];
|
||||
|
@ -1900,6 +1900,21 @@ class CBvideo extends CBCategory
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get video profile
|
||||
*
|
||||
* @param INT profile_id
|
||||
* @return ARRAY profile details
|
||||
*/
|
||||
function get_video_profile($pid)
|
||||
{
|
||||
global $db;
|
||||
$profile = $db->select(tbl('video_profiles'),'*',"profile_id='$pid'");
|
||||
if($db->num_rows>0)
|
||||
return $profile[0];
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* get latest profile order..
|
||||
|
|
|
@ -183,8 +183,8 @@ if(!@$in_bg_cron)
|
|||
|
||||
$calcdate = new CalcDate();
|
||||
$signup = new signup();
|
||||
$Upload = new Upload();
|
||||
$cbgroup = new CBGroups();
|
||||
$cbupload = $Upload = new Upload();
|
||||
$cbgroup = new CBGroups();
|
||||
$adsObj = new AdsManager();
|
||||
$formObj = new formObj();
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -573,7 +573,7 @@ function file_name_exists($name)
|
|||
/**
|
||||
* Function used to get video from conversion queue
|
||||
*/
|
||||
function get_queued_video($update=TRUE,$fileName=NULL)
|
||||
function get_queued_video($update=TRUE)
|
||||
{
|
||||
global $db;
|
||||
$max_conversion = config('max_conversion');
|
||||
|
|
Loading…
Add table
Reference in a new issue