Вход Регистрация
Файл: adultscript-2.0.3-pro/files/modules/video/scripts/convert.php
Строк: 71
<?php
define
('_VALID'TRUE);
define('_CONSOLE'TRUE);

if (
php_sapi_name() != 'cli') {
    die(
'This script can be called only from the console!');
}

set_time_limit(0);

$base_dir realpath(dirname(__FILE__).'/../../../');
require 
$base_dir.'/libraries/bootstrap.php';

if (isset(
$_SERVER['argv']['1']) &&
    isset(
$_SERVER['argv']['2']) &&
    isset(
$_SERVER['argv']['3'])) {
    
$filter        VF::factory('filter');
      
$video_id     = (int) $_SERVER['argv']['1'];
      
$ext        $filter->clean($_SERVER['argv']['2']);
      
$status        = (int) $_SERVER['argv']['3'];
      
$watermark    = (isset($_SERVER['argv']['4'])) ? (int) $_SERVER['argv']['4'] : true;
    
$src        MEDIA_DIR.'/videos/vid/'.$video_id.'.'.$ext;
    if (
file_exists($src) && is_file($src)) {
        
$conv    = new VVideo();
        
$conv->log_setup($video_id);
        if (
$conv->load($src)) {
            
$conv->log("Executed by: ".__FILE__." ".$video_id." ".$ext." ".$status);
            
$conv->log("Loaded video from: ".$src."n".$conv->get_data_string());
        
            
// we need to extract thumbs before conversion (watermarking hooks)
            
$sql_add    null;
            
$thumbs     $conv->extract_thumbs($src$video_id);
            if (
$thumbs) {
                if (
VCfg::get('video.thumb_slide')) {
                      
$conv->log('Creating thumb slide...');
                    
$slide $conv->extract_slide($src$video_id);
        
                    if (
count($slide) === 3) {
                        
$sql_add    ", slideversion= '".$slide['2']."', slidenum = '".$slide['0']."', slideoffset = '".$slide['1']."'";
                    } else {
                          
$conv->log('Failed to create thumb slide!');
                    }
                }
            } else {
                
$thumbs    0;
                
$conv->log('Failed to extract thumbs from video!');
            }
            
            
VHelper::load('module.video.conv');
            
$proc VHelper_video_conv::process($video_id$src$conv$watermark);
            
            
// set status to 7 if no FLV and no HD was processed
            
$status        = (VF::cfg_item('module.video.approve')) ? $status;
            if ((!
$proc['flv'] && !$proc['mp4']) or $thumbs <= 0) {
                
$conv->log('Failed -> flv: '.(int) $proc['flv'].', mp4: '.(int) $proc['mp4'].', thumbs: '.$thumbs);
                  
$status 7;
              }
            
            
$ext        = ($proc['mp4']) ? 'mp4' 'flv';
            
$hd            = ($proc['mp4_hd']) ? 0;
            
$mobile        = ($proc['mobile']) ? 0;
            
$thumbs        = ($thumbs 1) ? ($thumbs-1) : 0;
            
            
// we need to re-initialize our database connection here to make sure
            // we can update the video fields
            
VF::factory_remove('database');
            
$db VF::factory('database');
            
            
$conv->log('Deleting queue entry.');
            
$db->query("DELETE FROM #__video_queue
                       WHERE video_id = "
.$video_id."
                       LIMIT 1"
);

            
$sql    "UPDATE #__video
                       SET ext = '"
.$db->escape($ext)."',
                           hd = "
.$hd.",
                             mobile = '"
.$mobile."',
                           duration = "
.(float) $conv->data['duration_seconds'].",
                           thumbs = "
.$thumbs.",
                           server = "
.$proc['server_id'].",
                           s3 = '"
.$proc['s3']."',
                           status = "
.$status.$sql_add."
                       WHERE video_id = "
.$video_id."
                       LIMIT 1"
;
            
$conv->log("Executing update query: ".$sql);
            
$db->query($sql);
            if (
$db->affected_rows()) {
                
$conv->log('Video database data updated!');
                if (
$status === OR $status === 1) {
                    
// delete the original file if enabled and status is active or approve required
                    // (conversion success)
                    
if (VCfg::get('video.delete_orig')) {
                        
$conv->log('Deleting '.$src.' ...');
                        
VFile::delete($src);
                    }
                    
                    
$conv->log_clean TRUE;
                }
            } else {
                
$conv->log('Failed to execute video updated query!');
            }
        } else {
            
$conv->log('Failed to load video: '.$src);
        }
    }
}
?>
Онлайн: 1
Реклама