diff --git a/cron.php b/cron.php index 9351d21..1696eb2 100755 --- a/cron.php +++ b/cron.php @@ -3,6 +3,8 @@ include ("include/config.php"); include_once ('include/FLV/FLV/FLV.php'); +define('AUDIO_FRAME_INTERVAL', 3); + if (file_exists("/tmp/cron.php.lock")) exit(0); diff --git a/cron2.php b/cron2.php index 417d215..d5fb82a 100755 --- a/cron2.php +++ b/cron2.php @@ -62,8 +62,10 @@ if (($pad % 2) != 0x0) $pad ++; - if ($pad > 1) + if ($pad > 1) { $pad_str = "-padleft $pad -padright $pad "; + $pad_str = "'pad=width=400:height=300:x=$pad:y=0:color=black'"; + } else $pad_str = ""; $nH = 300; @@ -80,8 +82,10 @@ if (($pad % 2) != 0x0) $pad ++; - if ($pad > 1) + if ($pad > 1) { $pad_str = "-padtop $pad -padbottom $pad "; + $pad_str = "'pad=width=400:height=300:x=0:y=$pad:color=black'"; + } else $pad_str = ""; // $nH = 300 - ($pad * 2); @@ -91,7 +95,7 @@ // old -g 250 -i_qfactor 0.71 -gblur 0.9 // $vidParams "-deinterlace -g 250 -qcomp 0.6 -qdiff 4 -i_qfactor 0.71428572 -b_qfactor 0.76923078 -bt 200k -b 360k -r 25"; $vidParams = "-deinterlace -g 250 -qcomp 0.6 -qdiff 4 -i_qfactor 0.71 -umv -aic -sc_threshold 10000 -bt 200k -b 360k -r 25"; - +/* $encode = "/usr/local/bin/ffmpeg -i \"/usr/web/uploads/" . $qData['file'] . "\" -an $pad_str $vidParams -f flv -s " . $nW . "x" . $nH . " -pass 1 -passlogfile /tmp/pass_monkey -y \"/media/tmp/" . $qData['file'] . ".flv\""; print("[$encode]"); @@ -99,9 +103,19 @@ $res = system($encode, $retVal); if ($retVal == 1) - doExit($encode, $data['vid']); + doExit($encode, $qData['vid']); $encode = "/usr/local/bin/ffmpeg -i \"/usr/web/uploads/" . $qData['file'] . "\" -ar 44100 -ac 2 -ab 128k $pad_str $vidParams -f flv -s " . $nW . "x" . $nH . " -pass 2 -passlogfile /tmp/pass_monkey -y \"/media/tmp/" . $qData['file'] . ".flv\""; +*/ + + $encode = "/usr/local/bin/ffmpeg -i \"/usr/web/uploads/" . $qData['file'] . "\" -pass 1 -vcodec libx264 -preset slower -b:v 360k -bt 200k -threads 0 -s 400x300 -aspect 4:3 -acodec aac -ar 44100 -f flv -y \"/home/tuve/tmp/" . $qData['file'] . ".flv\""; // -ab 32 before the -f + + $encode = "/usr/local/bin/ffmpeg -i \"/usr/web/uploads/" . $qData['file'] . "\" -c:v libx264 -vprofile main -b:v 360k -bt 200k -vf \"scale=w=400:h=300:force_original_aspect_ratio=1,pad=400:300:(ow-iw)/2:(oh-ih)/2\" -c:a aac -ac 2 -ar 44100 \"/home/tuve/tmp/" . $qData['file'] . ".flv\""; + + $encode = "/usr/local/bin/ffmpeg -i \"/usr/web/uploads/" . $qData['file'] . "\" -c:v libx264 -vprofile main -vf \"scale=w=800:h=450:force_original_aspect_ratio=1,pad=800:450:(ow-iw)/2:(oh-ih)/2\" -c:a aac -ac 2 -ar 44100 \"/home/tuve/tmp/" . $qData['file'] . ".flv\""; + + + $encode = "/usr/local/bin/ffmpeg -i \"/usr/web/uploads/" . $qData['file'] . "\" -c:v libx264 -vf \"scale=w=800:h=450:force_original_aspect_ratio=1,pad=800:450:(ow-iw)/2:(oh-ih)/2\" -b:v 1M -maxrate 1M -bufsize 2M -preset veryfast -c:a mp3 -pass 1 -f flv -an -y /dev/null"; print("[$encode]"); @@ -109,10 +123,21 @@ if ($retVal == 1) doExit($encode, $data['vid']); + + $encode = "/usr/local/bin/ffmpeg -i \"/usr/web/uploads/" . $qData['file'] . "\" -c:v libx264 -vf \"scale=w=800:h=450:force_original_aspect_ratio=1,pad=800:450:(ow-iw)/2:(oh-ih)/2\" -b:v 1M -maxrate 1M -bufsize 2M -preset veryfast -c:a aac -b:a 128k -pass 2 -f flv -y \"/home/tuve/tmp/" . $qData['file'] . ".flv\""; + + print("[$encode]"); + + $res = system($encode, $retVal); + + if ($retVal == 1) + doExit($encode, $data['vid']); + print($res); + system("rm -fr /tmp/pass_monkey*"); } - system("/bin/mv \"/media/tmp/" . $qData['file'] . ".flv\" \"/usr/home/tuve/streams/" . $qData['file'] . ".flv\""); + system("/bin/mv \"/usr/home/tuve/tmp/" . $qData['file'] . ".flv\" \"/usr/home/tuve/streams/" . $qData['file'] . ".flv\""); system("/usr/sbin/chown tuve:www \"/usr/home/tuve/streams/" . $qData['file'] . ".flv\""); /* Move The File To The Mirrors */ @@ -127,7 +152,7 @@ /* Insert The Video Into The System */ $uDate = time(); - $query = "INSERT INTO videos (artist,title,genre,file,rating,classification,oid,mType,length,width,height,added) VALUES(\"$artist\",\"$title\",\"$genre\",\"$file.flv\",$rid,$cid,$oid,$mType,$oLen,400,300,$uDate)"; + $query = "INSERT INTO videos (artist,title,genre,file,rating,classification,oid,mType,length,width,height,added) VALUES(\"" . $qData['artist'] . "\",\"" . $qData['title'] . "\",\"" . $qData['genre'] . "\",\"" . $qData['file'] . ".flv\"," . $qData['rating'] . "," . (($qData['classification'] > 0) ? $qData['classification'] : 1) . "," . $qData['oid'] . ",$mType,$oLen,800,450,$uDate)"; print "[$query]"; // $res = mysql_query($query); $res = $db->query($query); @@ -157,6 +182,8 @@ function doExit($errorStr, $vid_id) { + global $db; + /* Update The videos_pending Table */ $query = "UPDATE videos_pending SET encoded = 2 WHERE vid = $vid_id"; // mysql_query($query);