Thread: [Phphtmllib-devel] SF.net SVN: phphtmllib:[3301] trunk/open2300/lib/core/daemon/ AviProcessorDaemon
Status: Beta
Brought to you by:
hemna
From: <he...@us...> - 2009-11-25 22:31:23
|
Revision: 3301 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3301&view=rev Author: hemna Date: 2009-11-25 22:30:53 +0000 (Wed, 25 Nov 2009) Log Message: ----------- small updates Modified Paths: -------------- trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc Modified: trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc =================================================================== --- trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc 2009-11-25 22:24:20 UTC (rev 3300) +++ trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc 2009-11-25 22:30:53 UTC (rev 3301) @@ -26,7 +26,7 @@ * how long to wait in between * processing. in seconds */ - protected $wait_period = 5; + protected $wait_period = 1800; /** @@ -78,8 +78,6 @@ //used for directory $ymdDate = date("Ymd"); - - $hour = date("G"); $dirname = $this->imagesdir."/".$ymdDate; //make sure the images dir exists. @@ -107,10 +105,7 @@ //now send it to the hosting provider $cmd = "/usr/bin/scp timelapse.flv wx.hemna.com:wx.hemna.com/htdocs/video/".$ymdDate; $this->exec_command($dirname, $cmd); - } - - $this->log->info("Exiting"); - exit; + } } /** @@ -119,8 +114,9 @@ */ protected function exec_command($dirname, $cmd) { $command = "cd ".$dirname."; ".$cmd." 2>&1 >>".$dirname."/processing.log"; - $this->log->info("::do_task() exec ".$command); - $last_line = system($command, $return); + $this->log->info("::exec_command() exec ".$command); + $last_line = system($command, $return); + $this->log->debug("::exec_command() done"); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <he...@us...> - 2009-11-26 03:15:22
|
Revision: 3302 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3302&view=rev Author: hemna Date: 2009-11-26 03:15:02 +0000 (Thu, 26 Nov 2009) Log Message: ----------- track image count Modified Paths: -------------- trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc Modified: trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc =================================================================== --- trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc 2009-11-25 22:30:53 UTC (rev 3301) +++ trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc 2009-11-26 03:15:02 UTC (rev 3302) @@ -35,6 +35,13 @@ protected $log; protected $imagesdir; + + /** + * track the number of images we are + * processing. If we have the same number + * as last run...no need to process. + */ + protected $image_count = 0; /** @@ -85,9 +92,9 @@ $num_images = $this->count_images($dirname); - if ($num_images == 0) { + if ($num_images == 0 || ($num_images == $this->image_count)) { //we have nothing to do - $this->log->info("::do_task() found no images to process"); + $this->log->info("::do_task() no images or same count"); } else { $this->log->info("::do_task() found ".$num_images." to process into a movie."); $rate = $this->calculate_rate($num_images); @@ -105,6 +112,9 @@ //now send it to the hosting provider $cmd = "/usr/bin/scp timelapse.flv wx.hemna.com:wx.hemna.com/htdocs/video/".$ymdDate; $this->exec_command($dirname, $cmd); + + //track the image count + $this->image_count = $num_images; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <he...@us...> - 2009-11-26 17:42:12
|
Revision: 3303 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3303&view=rev Author: hemna Date: 2009-11-26 17:42:03 +0000 (Thu, 26 Nov 2009) Log Message: ----------- use rsync instead of scp Modified Paths: -------------- trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc Modified: trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc =================================================================== --- trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc 2009-11-26 03:15:02 UTC (rev 3302) +++ trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc 2009-11-26 17:42:03 UTC (rev 3303) @@ -106,11 +106,14 @@ //now convert the avi movie to a flash file $aviname = "timelapse_640x480_".$rate."fps.avi"; - $cmd = "/usr/bin/ffmpeg -y -i ".$aviname." -b 1900k -f flv timelapse.flv"; + $cmd = "/usr/bin/ffmpeg -y -i ".$aviname." -b 1900k -f flv ".$ymdDate."/timelapse.flv"; $this->exec_command($dirname, $cmd); + + //move the //now send it to the hosting provider - $cmd = "/usr/bin/scp timelapse.flv wx.hemna.com:wx.hemna.com/htdocs/video/".$ymdDate; + //$cmd = "/usr/bin/scp timelapse.flv wx.hemna.com:wx.hemna.com/htdocs/video/".$ymdDate; + $cmd = "/usr/bin/rsync -av ".$ymdDate." wx.hemna.com:wx.hemna.com/htdocs/video"; $this->exec_command($dirname, $cmd); //track the image count @@ -187,7 +190,9 @@ */ protected function test_images_dir($dirname) { if (!file_exists($dirname)) { - $this->create_img_dir($dirname); + $this->create_dir($dirname); + $ymdDate = date("Ymd"); + $this->create_dir($dirname."/".$ymdDate) } } @@ -196,7 +201,7 @@ * (this is also done from the camera) * */ - protected function create_img_dir($dirname) { + protected function create_dir($dirname) { $this->log->info("Creating directory (".$dirname.")"); $ret = mkdir($dirname); if (!$ret) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <he...@us...> - 2009-11-26 17:43:13
|
Revision: 3304 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3304&view=rev Author: hemna Date: 2009-11-26 17:43:07 +0000 (Thu, 26 Nov 2009) Log Message: ----------- ; Modified Paths: -------------- trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc Modified: trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc =================================================================== --- trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc 2009-11-26 17:42:03 UTC (rev 3303) +++ trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc 2009-11-26 17:43:07 UTC (rev 3304) @@ -192,7 +192,7 @@ if (!file_exists($dirname)) { $this->create_dir($dirname); $ymdDate = date("Ymd"); - $this->create_dir($dirname."/".$ymdDate) + $this->create_dir($dirname."/".$ymdDate); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <he...@us...> - 2009-12-01 05:49:39
|
Revision: 3311 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3311&view=rev Author: hemna Date: 2009-12-01 05:49:29 +0000 (Tue, 01 Dec 2009) Log Message: ----------- nuked log_message() Modified Paths: -------------- trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc Modified: trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc =================================================================== --- trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc 2009-12-01 05:48:23 UTC (rev 3310) +++ trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc 2009-12-01 05:49:29 UTC (rev 3311) @@ -10,7 +10,7 @@ * @author waboring * */ -class AviProcessorDaemon extends Daemon { +class AviProcessorDaemon extends ScheduleDaemon { /** * User ID @@ -21,121 +21,130 @@ * Group ID */ protected $group_id = 100; - + /** * how long to wait in between * processing. in seconds */ protected $wait_period = 1800; - - + + /** * the log object. */ protected $log; - + protected $imagesdir; - + /** * track the number of images we are * processing. If we have the same number * as last run...no need to process. */ protected $image_count = 0; - - + + /** + * we need to return the logger. + * + */ + protected function get_logger() { + $log = new Log(); + $log->add_writer(FileLogWriter::factory(realpath($GLOBALS["path_base"])."/logs/daemon.log")); + + return $log; + } + + + /** * Do any initialization here. * */ protected function init() { - $this->log = new Log(); - $this->log->add_writer(FileLogWriter::factory(realpath($GLOBALS["path_base"])."/logs/daemon.log")); - - $config = Config::singleton(); + $config = Config::singleton(); $this->imagesdir = $config->get("imagesdir"); } - + /** * any cleanup here */ protected function cleanup() { } - - /** - * This method is used to pause the scheduler so - * we aren't constantly running as fast as we can. - * - */ - protected function wait_state() { - $this->log->debug("::wait_state() sleeping for ".$this->wait_period." seconds"); - sleep($this->wait_period); - } - - - /** - * do the actual work here. - * - */ - protected function do_task() { - //now do a wait state - //so we aren't constantly running. - $this->wait_state(); + protected function can_run() { + //used for directory $ymdDate = date("Ymd"); + + $dirname = $this->imagesdir."/".$ymdDate; - $dirname = $this->imagesdir."/".$ymdDate; //make sure the images dir exists. $this->test_images_dir($dirname); - - $num_images = $this->count_images($dirname); + $num_images = $this->count_images($dirname); + $this->num_images = $num_images; + if ($num_images == 0 || ($num_images == $this->image_count)) { - //we have nothing to do - $this->log->info("::do_task() no images or same count"); + $this->log->info("::can_run() no images or same count"); + return false; } else { + $this->log->info("::do_task() found ".$num_images." to process into a movie."); - $rate = $this->calculate_rate($num_images); - - $this->log->info("::do_task() rate is ".$rate." -> movie length = ".$num_images/$rate."s"); - //generate the avi - $cmd = "/home/waboring/bin/imgs2avi.sh -w 640 -h 480 -r ".$rate; - $this->exec_command($dirname, $cmd); + return true; + } + } + + + /** + * do the actual work here. + * + */ + protected function schedule() { + + //used for directory + $ymdDate = date("Ymd"); + + $dirname = $this->imagesdir."/".$ymdDate; + + $rate = $this->calculate_rate($this->num_images); + + $this->log->info("::do_task() rate is ".$rate." -> movie length = ".$this->num_images/$rate."s"); + //generate the avi + $cmd = "/home/waboring/bin/imgs2avi.sh -w 640 -h 480 -r ".$rate; + $this->exec_command($dirname, $cmd); - //now convert the avi movie to a flash file - $aviname = "timelapse_640x480_".$rate."fps.avi"; - $cmd = "/usr/bin/ffmpeg -y -i ".$aviname." -b 1900k -f flv ".$ymdDate."/timelapse.flv"; - $this->exec_command($dirname, $cmd); + //now convert the avi movie to a flash file + $aviname = "timelapse_640x480_".$rate."fps.avi"; + $cmd = "/usr/bin/ffmpeg -y -i ".$aviname." -b 1900k -f flv ".$ymdDate."/timelapse.flv"; + $this->exec_command($dirname, $cmd); - //move the + //move the - //now send it to the hosting provider - //$cmd = "/usr/bin/scp timelapse.flv wx.hemna.com:wx.hemna.com/htdocs/video/".$ymdDate; - $cmd = "/usr/bin/rsync -av ".$ymdDate." wx.hemna.com:wx.hemna.com/htdocs/video"; - $this->exec_command($dirname, $cmd); + //now send it to the hosting provider + //$cmd = "/usr/bin/scp timelapse.flv wx.hemna.com:wx.hemna.com/htdocs/video/".$ymdDate; + $cmd = "/usr/bin/rsync -av ".$ymdDate." wx.hemna.com:wx.hemna.com/htdocs/video"; + $this->exec_command($dirname, $cmd); - //track the image count - $this->image_count = $num_images; - } + //track the image count + $this->image_count = $num_images; } - + /** * This is used to execute an external command - * + * */ protected function exec_command($dirname, $cmd) { $command = "cd ".$dirname."; ".$cmd." 2>&1 >>".$dirname."/processing.log"; $this->log->info("::exec_command() exec ".$command); $last_line = system($command, $return); - $this->log->debug("::exec_command() done"); + $this->log->debug("::exec_command() done"); } - + /** * calculate the frame rate to use based * on the # of images we have to process. - * + * * @param $numimages * @return rate */ @@ -152,13 +161,13 @@ } else if ($num_images < 1200) { $rate = 25; } - + return $rate; } - - + + /** * Find out how many images are in the dir * @@ -166,11 +175,11 @@ */ protected function count_images($dirname) { $count = 0; - + $this->log->debug("::count_images() : check ".$dirname); if (file_exists($dirname)) { if ($dir = opendir($dirname)) { - while (($file = readdir($dir)) !== false) { + while (($file = readdir($dir)) !== false) { if (strstr($file, '.jpg')) { $count++; } @@ -178,12 +187,12 @@ closedir($dir); } } - + $this->log->debug("::count_images() : found ".$count); return $count; } - - + + /** * make sure the video dir exists. * @@ -193,9 +202,9 @@ $this->create_dir($dirname); $ymdDate = date("Ymd"); $this->create_dir($dirname."/".$ymdDate); - } + } } - + /** * Create the image directory * (this is also done from the camera) @@ -210,24 +219,19 @@ throw $ex; } } - - - - - /** - * Create the process id file on disk - * so that we can store it for later use. - * - * @return string - */ - public function generate_pid_filename() { - return realpath($GLOBALS["path_base"]).'/bin/'.__CLASS__.'.pid'; - } - - protected function log_message($message, - $level=0, - $e=NULL) { - } + + + + + /** + * Create the process id file on disk + * so that we can store it for later use. + * + * @return string + */ + public function generate_pid_filename() { + return realpath($GLOBALS["path_base"]).'/bin/'.__CLASS__.'.pid'; + } } ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <he...@us...> - 2009-12-11 23:16:35
|
Revision: 3317 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3317&view=rev Author: hemna Date: 2009-12-11 23:16:27 +0000 (Fri, 11 Dec 2009) Log Message: ----------- make sure the flash dir exists as well Modified Paths: -------------- trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc Modified: trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc =================================================================== --- trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc 2009-12-01 17:57:38 UTC (rev 3316) +++ trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc 2009-12-11 23:16:27 UTC (rev 3317) @@ -198,11 +198,17 @@ * */ protected function test_images_dir($dirname) { + + $ymdDate = date("Ymd"); + $flashdirname = $dirname."/".$ymdDate; + if (!file_exists($dirname)) { $this->create_dir($dirname); - $ymdDate = date("Ymd"); - $this->create_dir($dirname."/".$ymdDate); } + + if (!file_exists($flashdirname)) { + $this->create_dir($flashdirname); + } } /** @@ -234,4 +240,4 @@ } } -?> \ No newline at end of file +?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <he...@us...> - 2010-07-12 21:35:58
|
Revision: 3532 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3532&view=rev Author: hemna Date: 2010-07-12 21:35:51 +0000 (Mon, 12 Jul 2010) Log Message: ----------- logs Modified Paths: -------------- trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc Modified: trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc =================================================================== --- trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc 2010-07-12 21:35:15 UTC (rev 3531) +++ trunk/open2300/lib/core/daemon/AviProcessorDaemon.inc 2010-07-12 21:35:51 UTC (rev 3532) @@ -111,7 +111,7 @@ $this->log->info("::do_task() rate is ".$rate." -> movie length = ".$this->num_images/$rate."s"); //generate the avi - $cmd = "/home/waboring/bin/imgs2avi.sh -w 640 -h 480 -r ".$rate; + $cmd = "/home/waboring/local/bin/imgs2avi.sh -w 640 -h 480 -r ".$rate; $this->exec_command($dirname, $cmd); //now convert the avi movie to a flash file @@ -123,7 +123,8 @@ //now send it to the hosting provider //$cmd = "/usr/bin/scp timelapse.flv wx.hemna.com:wx.hemna.com/htdocs/video/".$ymdDate; - $cmd = "/usr/bin/rsync -av ".$ymdDate." wx.hemna.com:wx.hemna.com/htdocs/video"; + //$cmd = "/usr/bin/rsync -av ".$ymdDate." wx.hemna.com:wx.hemna.com/htdocs/video"; + $cmd = "/usr/bin/rsync -av ".$ymdDate." /home/waboring/wx.hemna.com/htdocs/video"; $this->exec_command($dirname, $cmd); //track the image count @@ -138,7 +139,7 @@ $command = "cd ".$dirname."; ".$cmd." 2>&1 >>".$dirname."/processing.log"; $this->log->info("::exec_command() exec ".$command); $last_line = system($command, $return); - $this->log->debug("::exec_command() done"); + $this->log->debug("::exec_command() done :".$last_line); } /** @@ -238,6 +239,14 @@ public function generate_pid_filename() { return realpath($GLOBALS["path_base"]).'/bin/'.__CLASS__.'.pid'; } + + + /** + * no need to set the user id + */ + public function set_identity() { + return true; + } } ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |