0) { // Get the curent level $level = ob_get_level(); // End the buffering ob_end_clean(); // If the current level has not changed, abort if (ob_get_level() == $level) break; } // Disable apache output buffering/compression if (function_exists('apache_setenv')) { apache_setenv('no-gzip', '1'); apache_setenv('dont-vary', '1'); } } header("Content-type: text/plain"); // tell php to automatically flush after every output // including lines of output produced by shell commands //disable_ob(); $total_frm =0; $curent_frm =0; $postid = 0; $informProgress =0; if(isset($data_arry[0])){ if(empty($data_arry[0]->{'isjpg'})){ @$data_arry[0]->{'isjpg'} = 0; } } function my_exec($cmd, $input='',$id,$isjpg) {$proc=proc_open($cmd, array(0=>array('pipe', 'r'), 1=>array('pipe', 'w'), 2=>array('pipe', 'w')), $pipes); fwrite($pipes[0], $input);fclose($pipes[0]); $stdout = ""; $fin = 0; $postid = $id; $informProgress = 10; if (is_resource($proc)) { while ($s = fgets($pipes[1])) { //print $s; //file_put_contents("alog.txt", $s, FILE_APPEND | LOCK_EX); preg_replace_callback('/PROGRESS: Duration: ([0-9]+?):([0-9]+?):([0-9]+?):([0-9]+?) /si',function($match) use (&$total_frm,&$curent_frm){ //print_r($match); $total_frm = $match[4] + $match[3]*100 + $match[2]*60*100 + $match[1]*60*60*100; print $total_frm."\n"; //file_put_contents("alog.txt", $total_frm."\n", FILE_APPEND | LOCK_EX); },substr(trim($s), 0, -1)." "); preg_replace_callback('/PROGRESS: ([0-9]+?):([0-9]+?):([0-9]+?):([0-9]+?) /si',function($match) use (&$total_frm,&$curent_frm,&$postid,&$informProgress,$isjpg){ //print_r($match); $curent_frm = $match[4] + $match[3]*100 + $match[2]*60*100 + $match[1]*60*60*100; //print $curent_frm."\n"; $perc=0; if($isjpg == 0 && $total_frm > 0){ $perc = ($curent_frm * 100 / $total_frm); if((int)$perc > $informProgress){ print_r($postid."\r\n"); $informProgress += 10; //$post = array('MakePool_id'=>$data_arry[0]->{'MakePool_id'},"ProgressBar"=>(int)$perc); $ch = curl_init(); print_r("https://www.videoir.com/MakePool/Progress/".$postid."/".$perc); $target_url = "https://www.videoir.com/MakePool/Progress/".$postid."/".$perc; curl_setopt($ch, CURLOPT_URL,$target_url); // curl_setopt($ch, CURLOPT_POST,1); // curl_setopt($ch, CURLOPT_POSTFIELDS, $post); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result=curl_exec ($ch); print_r($result); print_r("update progress %".$perc."\n"); } print_r("%".$perc."\n"); } //file_put_contents("alog.txt", "%".($curent_frm * 100 / $total_frm)."\n", FILE_APPEND | LOCK_EX); },substr(trim($s), 0, -1)." "); if(strstr($s, 'Finished composition', true) != false){ $fin =1; } $stdout = $stdout.$s; flush(); //ob_flush(); } } $stdout.=stream_get_contents($pipes[1]);fclose($pipes[1]); $stderr=stream_get_contents($pipes[2]);fclose($pipes[2]); $rtn=proc_close($proc); return array('fin'=>$fin, 'stdout'=>$stdout, 'stderr'=>$stderr, 'return'=>$rtn ); } function my_ff_exec($cmd,$path) {$proc=proc_open($cmd, array(0=>array('pipe', 'r'), 1=>array('pipe', 'w'), 2=>array('pipe', 'w')), $pipes); fwrite($pipes[0], "");fclose($pipes[0]); $stdout = ""; $fin = 0; $informProgress = 10; if (is_resource($proc)) { while ($s = fgets($pipes[2])) { print_r($s); preg_match('/Duration: ([0-9]{2}):([0-9]{2}):([^ ,])+/', $s, $matches); if(isset($matches[0])){ print_r($matches); $time = str_replace("Duration: ", "", $matches[0]); $time_breakdown = explode(":", $time); $total_seconds = round(($time_breakdown[0]*60*60) + ($time_breakdown[1]*60) + $time_breakdown[2]); shell_exec('"C:\xampp\htdocs\ffmpeg\bin\ffmpeg.exe" -y -i '.$path." -f mjpeg -vframes 1 -ss " . ($total_seconds / 2) . " screan.jpg"); } //$stdout = $stdout.$s; flush(); //ob_flush(); } } $stdout.=stream_get_contents($pipes[1]);fclose($pipes[1]); $stderr=stream_get_contents($pipes[2]);fclose($pipes[2]); $rtn=proc_close($proc); return array('fin'=>$fin, 'stdout'=>$stdout, 'stderr'=>$stderr, 'return'=>$rtn ); } if(isset($data_arry[0]->{'_id'})) { if(empty($data_arry[0]->{'rangframe'})){ $data_arry[0]->{'rangframe'} = 0; } //print_r($data_arry[0]->{'_id'}); //echo __DIR__."/".$data_arry[0]->{'Name'}; download("https://www.videoir.com/File/".$data_arry[0]->{'Name'},__DIR__.'/temp/videoir.zip'); $zip = new ZipArchive; $res = $zip->open(__DIR__."/temp/videoir.zip"); if ($res === TRUE) { delTree(__DIR__.'/temp/'); $zip->extractTo(__DIR__.'/temp/'); $zip->close(); $files1 = scandir(__DIR__.'/temp/'); rename(__DIR__.'/temp/'.$files1[2],__DIR__.'/temp/videoir'); $files1 = scandir(__DIR__.'/temp/'); $file_name_with_full_path = 'C:\xampp\htdocs\1.mp4'; $file_name_with_full_path2 = 'C:\xampp\htdocs\2.mp4'; @unlink($file_name_with_full_path); @unlink($file_name_with_full_path2); @unlink("C:\xampp\htdocs\2_00008.jpg"); $files2 = scandir(__DIR__.'/temp/'.$files1[2]); $aep =""; foreach($files2 as $k=>$v){ if (endsWith($v, 'aep') == 'aep') { $aep = $v; } } file_put_contents("1.bat",'"C:\Program Files\Adobe\Adobe After Effects 2020\Support Files\aerender.exe" -project "C:\xampp\htdocs\temp\\'.$files1[2].'\\'.$aep.'" -comp "render" '.(($data_arry[0]->{'rangframe'} == 0)?'':'-s '.$data_arry[0]->{'startframe'}.' -e '.$data_arry[0]->{'endframe'}).' -output "C:\xampp\htdocs\2.'.(($data_arry[0]->{'isjpg'}==1)?'jpg':'mp4').'"' ); //-RStemplate "Best Settings" //exec('"C:\Program Files\Adobe\Adobe After Effects 2020\Support Files\aerender.exe" -project "C:\xampp\htdocs\temp\videoir\01.aep" -comp "render" -output "'.$file_name_with_full_path2.'" -mp ',$retArr, $retVal); //exec('C:\xampp\htdocs\1.bat',$retArr, $retVal); $retArr = my_exec('C:\xampp\htdocs\1.bat',"",$data_arry[0]->{'MakePool_id'},$data_arry[0]->{'isjpg'}); $retVal = $retArr["fin"]; // print_r($retArr); // print_r($retVal); //$retVal = "0"; if($retVal == 1 and is_file($file_name_with_full_path2)){ if($data_arry[0]->{'isjpg'}==0){ exec('"C:\xampp\htdocs\ffmpeg\bin\ffmpeg.exe" -y -i "'.$file_name_with_full_path2.'" -filter:v fps=25 "'.$file_name_with_full_path.'"'); my_ff_exec('"C:\xampp\htdocs\ffmpeg\bin\ffmpeg.exe" -i '.$file_name_with_full_path2 ,$file_name_with_full_path2); } //$post = array('Name'=>$data_arry[0]->{'Name'},'Video_id'=>$data_arry[0]->{'Video_id'},'MakePool_id'=>$data_arry[0]->{'MakePool_id'},'download'=>'http://188.253.3.27/1.mp4'); $ch = curl_init(); $target_url = "https://www.videoir.com/MakePool/Receive/".$data_arry[0]->{'Name'}."/".$data_arry[0]->{'Video_id'}."/".$data_arry[0]->{'MakePool_id'}."/188.253.3.27"; print_r($target_url); curl_setopt($ch, CURLOPT_URL,$target_url); // curl_setopt($ch, CURLOPT_POST,1); // curl_setopt($ch, CURLOPT_POSTFIELDS, $post); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result=curl_exec ($ch); echo 'do upload!'; print_r($result); curl_close ($ch); }else{ //$post = array('Name'=>$data_arry[0]->{'Name'},'Video_id'=>$data_arry[0]->{'Video_id'},'MakePool_id'=>$data_arry[0]->{'MakePool_id'},'download'=>'http://188.253.3.27/1.mp4'); $ch = curl_init(); $target_url = "https://www.videoir.com/MakePool/Receive/".$data_arry[0]->{'Name'}."/".$data_arry[0]->{'Video_id'}."/".$data_arry[0]->{'MakePool_id'}."/188.253.3.27"; print_r($target_url); curl_setopt($ch, CURLOPT_URL,$target_url); // curl_setopt($ch, CURLOPT_POST,1); // curl_setopt($ch, CURLOPT_POSTFIELDS, $post); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result=curl_exec ($ch); echo 'do error!'; print_r($result); } echo 'woot!'; } else { echo 'doh!'; } @unlink(__DIR__."/".$data_arry[0]->{'Name'}); }