181 lines
6.1 KiB
PHP
181 lines
6.1 KiB
PHP
<?php
|
|
set_time_limit(0);
|
|
/* $Id: video_conversion_cronjob.php 13 2009-01-11 06:04:29Z john $ */
|
|
|
|
$page = 'video_conversion_cronjob';
|
|
include "header.php";
|
|
include "include/getid/getid3/getid3.php";
|
|
|
|
|
|
|
|
|
|
|
|
function video_manage_jobs3()
|
|
{
|
|
global $database, $setting, $actions, $misc, $url;
|
|
|
|
$query=$database->database_query("SELECT * FROM se_videos WHERE video_user_id='7653' AND video_is_converted=0 AND rawfile!='' ORDER BY video_id LIMIT 1");
|
|
$job_counter = 0;
|
|
$video = new se_video();
|
|
//echo $database->database_num_rows($query);
|
|
if($database->database_num_rows($query)==0){
|
|
//video_groupmanage_jobs2();
|
|
}
|
|
|
|
|
|
while($row=$database->database_fetch_array($query))
|
|
{
|
|
|
|
|
|
$directory=video_dir($row["video_user_id"]);
|
|
|
|
$getID3 = new getID3;
|
|
$file = $getID3->analyze($directory.$row["rawfile"]."");
|
|
//echo $file["video"]["resolution_x"];
|
|
if($file["video"]["resolution_x"]>1280)
|
|
{
|
|
$setting['setting_video_width']=1280;
|
|
}
|
|
else{
|
|
$setting['setting_video_width']=$file["video"]["resolution_x"];
|
|
}
|
|
|
|
|
|
$duration=mbmGetFLVDuration($directory.$row["rawfile"]);
|
|
|
|
|
|
//echo "<br />".$duration."<br />";
|
|
$min_duration = 1;
|
|
|
|
// mail("leprakhauns@gmail.com", "Bateworld Video Cron", "Bateworld Cron");
|
|
// DELETE VIDEO IF ENCODING WAS SCREWED UP
|
|
if(empty($duration) || $duration <= $min_duration)
|
|
{//mail("leprakhauns@gmail.com", "Bateworld Video Cron Failed", "Bateworld Cron ".$video_id);
|
|
// GET USER ID
|
|
$user_info = $database->database_fetch_assoc($database->database_query("SELECT video_user_id FROM se_videos WHERE video_id='".htmlspecialchars(strip_tags($row["video_id"]))."' LIMIT 1"));
|
|
|
|
$database->database_query("UPDATE se_videos SET video_is_converted='-1' WHERE video_id='".htmlspecialchars(strip_tags($row["video_id"]))."'");
|
|
|
|
$directory = getcwd().substr($video->video_dir($user_info[video_user_id]), 1);
|
|
|
|
unlink($directory.$row["rawfile"]);
|
|
unlink($directory.$row["video_id"].'_thumb.jpg');
|
|
}
|
|
|
|
// VIDEO WAS ENCODED SUCCESSFULLY, UPDATE DATABASE
|
|
else
|
|
{
|
|
|
|
if(!file_exists($directory.$row["video_id"].".mp4")||!file_exists($directory.$row["video_id"].".flv")){
|
|
|
|
$dir = opendir('uploads_video/encoding/queue/'); # This is the directory it will count from
|
|
$i = 0; # Integer starts at 0 before counting
|
|
|
|
|
|
$database->database_query("UPDATE se_videos SET video_is_converted='2', video_duration_in_sec='".$duration."', secondduration='".$duration."' WHERE video_id='".$row["video_id"]."'");
|
|
|
|
$a= exec("{$setting['setting_video_ffmpeg_path']} -i ".$directory.$row["rawfile"]. " -f null /dev/null 2>&1", $o, $t);
|
|
//echo $o[30];
|
|
$o=implode("//", $o);
|
|
$o=str_replace(" ", "",$o);
|
|
$o=explode("rotate:",$o);
|
|
|
|
if($o[1]!=""){
|
|
|
|
$t=explode("//", $o[1]);
|
|
$rotate=$t[0];
|
|
if($rotate==180)
|
|
{
|
|
$vf='-vf "vflip,hflip"';
|
|
}
|
|
else{$vf="";}
|
|
}
|
|
else{$rotate="";}
|
|
echo "/bin/nice {$setting['setting_video_ffmpeg_path']} -i ".$directory.$row["rawfile"]." -threads 1 -vf scale=".$setting['setting_video_width'].":-1 -f image2 -ss 2.00 -vframes 1 {$directory}".$row["video_id"]."_thumb.jpg 2>&1 \n";
|
|
//echo "touch uploads_video/encoding/queue/".$row["video_id"];exit;
|
|
$output=shell_exec("/bin/nice {$setting['setting_video_ffmpeg_path']} -i ".$directory.$row["rawfile"]." -threads 1 -vf scale=".$setting['setting_video_width'].":-1 -f image2 -ss 2.00 -vframes 1 {$directory}".$row["video_id"]."_thumb.jpg 2>&1 \n");
|
|
//sleep(10);
|
|
//shell_exec("/bin/nice {$setting['setting_video_ffmpeg_path']} -i ".$directory.$row["rawfile"]." -threads 1 -ar 22050 -y -vcodec libx264 -ab 32k -f flv scale=".$setting['setting_video_width'].":-1 ".$directory.$row["video_id"].".flv 2>&1 \n");
|
|
//sleep(300);
|
|
|
|
//echo "/bin/nice {$setting['setting_video_ffmpeg_path']} -i ".$directory.$row["rawfile"]." -threads 1 -ar 22050 -y -vcodec libx264 -g 30 -vf scale=".$setting['setting_video_width'].":-1 ".$directory.$row["video_id"].".mp4 2>&1 \n";
|
|
shell_exec("/bin/nice {$setting['setting_video_ffmpeg_path']} -i ".$directory.$row["rawfile"]." -threads 1 -ar 22050 -y -vcodec libx264 -g 30 -vf scale=".$setting['setting_video_width'].":-1 ".$directory.$row["video_id"].".mp4 2>&1 \n");
|
|
|
|
|
|
/*$convertVideo = "";
|
|
//echo $convertVideo;
|
|
system($convertVideo, $i);
|
|
echo $convertVideo;
|
|
//var_dump($x);
|
|
|
|
$convertVideo = "";
|
|
//echo $convertVideo;
|
|
system($convertVideo, $i);
|
|
|
|
shell_exec(");
|
|
//var_dump($u);*/
|
|
}
|
|
else{
|
|
if($row["twice"]==0){
|
|
if($row["video_duration_in_sec"]==NULL||$row["video_duration_in_sec"]==0)
|
|
{
|
|
unlink($directory.$row["video_id"].".mp4");
|
|
unlink($directory.$row["video_id"].".flv");
|
|
$database->database_query("UPDATE se_videos SET video_is_converted='0', `twice`=1 WHERE video_id='".$row["video_id"]."'");
|
|
}
|
|
else{
|
|
$database->database_query("UPDATE se_videos SET video_is_converted='1', video_admin_approved='1' WHERE video_id='".$row["video_id"]."'");
|
|
unlink($directory.$row["rawfile"]);
|
|
}
|
|
}
|
|
elseif($row["twice"]==1){
|
|
if($row["video_duration_in_sec"]==NULL||$row["video_duration_in_sec"]==0)
|
|
{
|
|
unlink($directory.$row["video_id"].".mp4");
|
|
unlink($directory.$row["video_id"].".flv");
|
|
$database->database_query("UPDATE se_videos SET video_is_converted='0', `twice`=2 WHERE video_id='".$row["video_id"]."'");
|
|
}
|
|
else{
|
|
$database->database_query("UPDATE se_videos SET video_is_converted='1', video_admin_approved='1' WHERE video_id='".$row["video_id"]."'");
|
|
unlink($directory.$row["rawfile"]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
unlink($directory.$row["video_id"].".mp4");
|
|
unlink($directory.$row["video_id"].".flv");
|
|
unlink($directory.$row["rawfile"]);
|
|
$database->database_query("UPDATE se_videos SET rawfile='', video_duration_in_sec=NULL, video_uploaded='0' WHERE video_id='".$row["video_id"]."'");
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
// Use this file to trigger the job queue handler via cronjob.
|
|
// Set a password to prevent calls, then use the following example URL to set your cronjob path:
|
|
// EX: video_conversion_cronjob.php?password=l53SDj6SGF2nb4
|
|
$password = 'leptestpassword123';
|
|
|
|
|
|
|
|
if( $_GET['password']==$password )
|
|
{
|
|
video_manage_jobs3();
|
|
//groupvideo_manage_jobs();
|
|
//video_manage_jobs1();
|
|
|
|
}
|
|
else{echo "wrong";}
|
|
|
|
|
|
exit();
|
|
|
|
?>
|