$cores = `cat /proc/cpuinfo | grep 'cpu cores'`; $threads = trim(end(explode(":", $cores))) - 1; return (int) $threads === 0 ? 1 : $threads; } $threads = getThreads(); while (true) { foreach ($inputdirarray as $inputdir) { $re = "/(\\.mov\$)|(\\.mpg\$)|(\\.mpeg\$)|(\\.mkv\$)|(\\.mp4\$)|(\\.avi\$)|(\\.wmv\$)|(\\.ts\$)|(\\.flv\$)|(\\.mjpg\$)/i"; $outputdir = Conf::CONVERTDIR . "/" . $inputdir; foreach (glob(Conf::UPLOADDIR . "/" . $inputdir . "/*.*") as $filename) { if (preg_match($re, $filename)) { $inputfile = "{$filename} size " . filesize($filename); $outfilename = $outputdir . "/" . pathinfo($filename, PATHINFO_FILENAME) . ".mp4"; FFmpeg::$source = $filename; FFmpeg::$dest = $outfilename; $cmd = FFmpeg::init(); sleep(1); Logger::getLogger(Conf::CONVERTLOGFILE)->log("Using threads = " . $threads . "\n" . "video file found in " . $dirs[0] . "/" . $inputdir . "\n" . "cmd=" . $cmd); $exit_code = 3; $ffmpeg_error = 0; echo exec($cmd, $ffmpeg_error, $ffmpeg_exit_code); if ($ffmpeg_exit_code === 0) { $exit_code = $exit_code - 1; if (in_array(pathinfo($filename, PATHINFO_FILENAME), Conf::ADDS)) { $out = Conf::BASEDIR . "/" . $inputdir . "/adds/" . pathinfo($filename, PATHINFO_FILENAME) . ".mp4"; } else { $out = Conf::BASEDIR . "/" . $inputdir . "/" . pathinfo($filename, PATHINFO_FILENAME) . ".mp4"; } $in = "" . $outputdir . "/" . pathinfo($filename, PATHINFO_FILENAME) . ".mp4"; if (copy($in, $out)) { unlink($in);