aboutsummaryrefslogtreecommitdiff
path: root/libraries/phpvideotoolkit/adapters/toolkit
diff options
context:
space:
mode:
authorHeshan <heshan@heidisoft.com>2011-07-12 09:42:44 +0530
committerHeshan <heshan@heidisoft.com>2011-07-12 09:42:44 +0530
commitb2eb0df792e7724538c4afeb7d8929a241a03773 (patch)
tree08753d134ca763de0fa58b46809d1f164443731b /libraries/phpvideotoolkit/adapters/toolkit
parent0efed16fb38616e5a1c94fa5f1f74107059d6d43 (diff)
downloadvideo-b2eb0df792e7724538c4afeb7d8929a241a03773.tar.gz
video-b2eb0df792e7724538c4afeb7d8929a241a03773.tar.bz2
Remove the library addons and other unwanted folders.
Diffstat (limited to 'libraries/phpvideotoolkit/adapters/toolkit')
-rw-r--r--libraries/phpvideotoolkit/adapters/toolkit/audio.php33
-rw-r--r--libraries/phpvideotoolkit/adapters/toolkit/capture.php29
-rw-r--r--libraries/phpvideotoolkit/adapters/toolkit/conversion.php29
-rw-r--r--libraries/phpvideotoolkit/adapters/toolkit/frame.php325
-rw-r--r--libraries/phpvideotoolkit/adapters/toolkit/join.php29
-rw-r--r--libraries/phpvideotoolkit/adapters/toolkit/queue.php32
-rw-r--r--libraries/phpvideotoolkit/adapters/toolkit/stream.php32
-rw-r--r--libraries/phpvideotoolkit/adapters/toolkit/video.php387
8 files changed, 0 insertions, 896 deletions
diff --git a/libraries/phpvideotoolkit/adapters/toolkit/audio.php b/libraries/phpvideotoolkit/adapters/toolkit/audio.php
deleted file mode 100644
index 415adae..0000000
--- a/libraries/phpvideotoolkit/adapters/toolkit/audio.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-
- /* SVN FILE: $Id$ */
- /**
- * @author Oliver Lillie (aka buggedcom) <publicmail@buggedcom.co.uk>
- * @package PHPVideoToolkit
- * @license BSD
- * @copyright Copyright (c) 2008 Oliver Lillie <http://www.buggedcom.co.uk>
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
- * is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
- class PHPVideoToolkit_Audio
- {
- function __construct()
- {
- }
- function __destruct()
- {
- }
- public function save()
- {
- }
- }
- \ No newline at end of file
diff --git a/libraries/phpvideotoolkit/adapters/toolkit/capture.php b/libraries/phpvideotoolkit/adapters/toolkit/capture.php
deleted file mode 100644
index 827c5f9..0000000
--- a/libraries/phpvideotoolkit/adapters/toolkit/capture.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
- /* SVN FILE: $Id$ */
- /**
- * @author Oliver Lillie (aka buggedcom) <publicmail@buggedcom.co.uk>
- * @package PHPVideoToolkit
- * @license BSD
- * @copyright Copyright (c) 2008 Oliver Lillie <http://www.buggedcom.co.uk>
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
- * is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
- class PHPVideoToolkit_Capture
- {
- function __construct()
- {
- }
- function __destruct()
- {
- }
- }
diff --git a/libraries/phpvideotoolkit/adapters/toolkit/conversion.php b/libraries/phpvideotoolkit/adapters/toolkit/conversion.php
deleted file mode 100644
index 0ada11c..0000000
--- a/libraries/phpvideotoolkit/adapters/toolkit/conversion.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
- /* SVN FILE: $Id$ */
- /**
- * @author Oliver Lillie (aka buggedcom) <publicmail@buggedcom.co.uk>
- * @package PHPVideoToolkit
- * @license BSD
- * @copyright Copyright (c) 2008 Oliver Lillie <http://www.buggedcom.co.uk>
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
- * is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
- class PHPVideoToolkit_Conversion
- {
- function __construct()
- {
- }
- function __destruct()
- {
- }
- }
diff --git a/libraries/phpvideotoolkit/adapters/toolkit/frame.php b/libraries/phpvideotoolkit/adapters/toolkit/frame.php
deleted file mode 100644
index ecbed92..0000000
--- a/libraries/phpvideotoolkit/adapters/toolkit/frame.php
+++ /dev/null
@@ -1,325 +0,0 @@
-<?php
-
- /* SVN FILE: $Id$ */
- /**
- * @author Oliver Lillie (aka buggedcom) <publicmail@buggedcom.co.uk>
- * @package PHPVideoToolkit
- * @license BSD
- * @copyright Copyright (c) 2008 Oliver Lillie <http://www.buggedcom.co.uk>
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
- * is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
- /**
- * This is similar in terms to FFmpeg-PHP's ffmpeg_frame, however the constructor can accept any number of items such as
- * a GD image, an image file, or an instance of PHPVideoToolkit, note if using an instance of PHPVideoToolkit you must
- * have already specified the frame you wish to extract with PHPVideoToolkit::extractFrame() or set
- */
- class PHPVideoToolkit_Frame
- {
-
- private $_resource = null;
- private $_gd_resource = null;
- private $_resource_type = null;
- private $_width = null;
- private $_height = null;
- private $_timecode = null;
-
- /**
- * Class Constructor
- * @param resource $gd_resource A GD image resource.
- * @param integer $timecode The time in seconds of the frame. If false and the $resource is a PHPVideoToolkit instance then the timecode will be retrieved from
- * the instance. However if $timecode is set and the $resource is a PHPVideoToolkit the $timecode will override the time retrieved from the instance.
- */
- function __construct($resource, $timecode=false)
- {
-// is this a gd resource
- if(is_resource($resource) && get_resource_type($resource) == 'gd')
- {
- $this->_gd_resource = $resource;
- $this->_resource_type = 'gd';
- $this->_width = imagesx($resource);
- $this->_height = imagesy($resource);
- $this->_timecode = $timecode;
- }
-// is this a gd resource
- else if(is_string($resource) && is_file($resource))
- {
- $this->_resource_type = 'file';
- $dimensions = getimagesize($resource);
- $this->_width = $dimensions[0];
- $this->_height = $dimensions[1];
- $this->_timecode = $timecode;
- }
-// check for PHPVideoToolkit class instance
- else if(get_class($resource) == 'PHPVideoToolkit')
- {
- $info = $resource->getFileInfo();
- if(!$info)
- {
-// throw error
- }
- if(!isset($info['video']))
- {
-// throw error
- }
- $this->_resource = $resource;
- $this->_resource_type = 'toolkit';
- $this->_width = $info['video']['dimensions']['width'];
- $this->_height = $info['video']['dimensions']['height'];
-// set the timecode, the $timecode value will override
- $set_timecode = $resource->hasCommand('-ss');
- $this->_timecode = $timecode === false && $set_timecode !== false ? $set_timecode : $timecode;
- }
-// isn't a valid resource type so throw error
- else
- {
-// throw error
- }
- }
-
- /**
- * Destroys any gd resource if made
- */
- function __destruct()
- {
- if($this->_resource_type == 'gd' && is_resource($this->_resource))
- {
- imagedestroy($this->_resource);
- }
- }
-
- /**
- * Determines if the resource supplied to the frame is valid.
- * @access public
- * @return integer
- */
- public function hasValidResource()
- {
- return $this->_resource_type !== null;
- }
-
- /**
- * Return the width of the frame.
- * @access public
- * @return integer
- */
- public function getWidth()
- {
- return $this->_width;
- }
-
- /**
- * Return the height of the frame.
- * @access public
- * @return integer
- */
- public function getHeight()
- {
- return $this->_height;
- }
-
- /**
- * Return the presentation time stamp of the frame.
- * @access public
- * @uses ffmpeg_frame::getPTS()
- * @return integer
- */
- public function getPresentationTimestamp()
- {
- return $this->getPTS();
- }
-
- /**
- * Return the presentation time stamp of the frame.
- * @access public
- * @return integer
- */
- public function getPTS()
- {
- return $this->_timecode;
- }
-
- /**
- * Determines if the current frame is a keyframe.
- * @access public
- * @return integer
- */
- public function isKeyFrame()
- {
- return false;
- }
-
- /**
- * Resize and optionally crop the frame.
- * NOTE 1: Cropping is always applied to the frame before it is resized.
- * NOTE 2: Crop values must be even numbers.
- * @access public
- * @param integer $width New width of the frame (must be an even number).
- * @param integer $height New height of the frame (must be an even number).
- * @param integer $crop_top Remove [croptop] rows of pixels from the top of the frame.
- * @param integer $crop_bottom Remove [cropbottom] rows of pixels from the bottom of the frame.
- * @param integer $crop_left Remove [cropleft] rows of pixels from the left of the frame.
- * @param integer $crop_right Remove [cropright] rows of pixels from the right of the frame.
- * @return boolean
- */
- public function resize($width, $height, $crop_top=false, $crop_bottom=false, $crop_left=false, $crop_right=false)
- {
-// generate a GD resource
- $this->_generateGDImageFromResource();
-// are we cropping?
- if($crop_top !== false || $crop_bottom !== false || $crop_left !== false || $crop_right !== false)
- {
-// crop and check it went ok
- if(!$this->crop($crop_top, $crop_bottom, $crop_left, $crop_right))
- {
- return false;
- }
- }
-// check the width and height
- if($width <= 0 || $height <= 0)
- {
- return false;
- }
-// now resize what we have
- $resize_resource = imagecreatetruecolor($width, $height);
-// copy the portion we want
- imagecopyresampled($resize_resource, $this->_gd_resource, 0, 0, 0, 0, $width, $height, $this->_width, $this->_height);
-// destroy the old crop resource to free up memory
- imagedestroy($this->_gd_resource);
-// save the new resource
- $this->_gd_resource = $resize_resource;
-// update the saved width and height
- $this->_width = $width;
- $this->_height = $height;
- return true;
- }
-
- /**
- * Crop the frame.
- * @access public
- * @param integer $crop_top Remove [croptop] rows of pixels from the top of the frame.
- * @param integer $crop_bottom Remove [cropbottom] rows of pixels from the bottom of the frame.
- * @param integer $crop_left Remove [cropleft] rows of pixels from the left of the frame.
- * @param integer $crop_right Remove [cropright] rows of pixels from the right of the frame.
- * @return boolean
- */
- public function crop($crop_top=false, $crop_bottom=false, $crop_left=false, $crop_right=false)
- {
-// generate a GD resource
- $this->_generateGDImageFromResource();
-// work out the newwidth and height and positions
- $w = $this->_width;
- $h = $this->_height;
- $x = 0;
- $y = 0;
- $x_bottom_chord = 0;
- if($crop_top !== false)
- {
- $x = $crop_top;
- $h -= $crop_top;
- }
- if($crop_bottom !== false)
- {
- $h -= $crop_bottom;
- }
- if($crop_left !== false)
- {
- $y = $crop_left;
- $w -= $crop_left;
- }
- if($crop_right !== false)
- {
- $w -= $crop_left;
- }
-// is the width and height greater than 0
- if($w < 0 || $h < 0)
- {
- return false;
- }
-// create the new image resource
- $crop_resource = imagecreatetruecolor($w, $h);
-// copy the portion we want
- imagecopyresampled($crop_resource, $this->_gd_resource, 0, 0, $x, $y, $w, $h, $w, $h);
-// destroy the old resource to free up memory
- imagedestroy($this->_gd_resource);
-// save the new resource
- $this->_gd_resource = $crop_resource;
-// update the saved width and height
- $this->_width = $w;
- $this->_height = $h;
- return true;
- }
-
- /**
- * Returns a truecolor GD image of the frame.
- * @access public
- * @return resource Returns a GD resource.
- */
- public function toGDImage()
- {
- $this->_generateGDImageFromResource()
- return $this->_gd_resource;
- }
-
- /**
- * Returns a GD resource from the current resource type.
- * @access private
- */
- private function _generateGDImageFromResource()
- {
-// don't do this if the gd resource is already defined
- if($this->_gd_resource === null)
- {
- switch($this->_resource_type)
- {
- case 'toolkit' :
- $result = $this->_resource->execute(false, false);
-// check the return value in-case of error
- if($result !== PHPVideoToolkit::RESULT_OK)
- {
-// throw error
- }
- $img = array_shift($this->_resource->getLastOutput());
- if(!is_file($img))
- {
-// throw error
- }
- $this->_gd_resource = imagecreatefromjpeg($img);
- break;
-
- case 'file' :
- $path_info = pathinfo($this->_resource);
- switch(strtolower($path_info['extension']))
- {
- case 'jpeg' :
- case 'jpg' :
- $this->_gd_resource = imagecreatefromjpeg($this->_resource);
- break;
- case 'gif' :
- $this->_gd_resource = imagecreatefromgif($this->_resource);
- break;
- case 'png' :
- $this->_gd_resource = imagecreatefrompng($this->_resource);
- break;
- default :
-// throw error
- }
- break;
-
- case 'gd' :
-// resource is already gd
- break;
- }
- }
- }
-
- }
diff --git a/libraries/phpvideotoolkit/adapters/toolkit/join.php b/libraries/phpvideotoolkit/adapters/toolkit/join.php
deleted file mode 100644
index 9d038c0..0000000
--- a/libraries/phpvideotoolkit/adapters/toolkit/join.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
- /* SVN FILE: $Id$ */
- /**
- * @author Oliver Lillie (aka buggedcom) <publicmail@buggedcom.co.uk>
- * @package PHPVideoToolkit
- * @license BSD
- * @copyright Copyright (c) 2008 Oliver Lillie <http://www.buggedcom.co.uk>
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
- * is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
- class PHPVideoToolkit_Join
- {
- function __construct()
- {
- }
- function __destruct()
- {
- }
- }
diff --git a/libraries/phpvideotoolkit/adapters/toolkit/queue.php b/libraries/phpvideotoolkit/adapters/toolkit/queue.php
deleted file mode 100644
index 5248b1c..0000000
--- a/libraries/phpvideotoolkit/adapters/toolkit/queue.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
- /* SVN FILE: $Id$ */
- /**
- * @author Oliver Lillie (aka buggedcom) <publicmail@buggedcom.co.uk>
- * @package PHPVideoToolkit
- * @license BSD
- * @copyright Copyright (c) 2008 Oliver Lillie <http://www.buggedcom.co.uk>
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
- * is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
- /**
- * This class creates a queue object that will sequentially process a conversion queue.
- */
- class PHPVideoToolkit_Queue
- {
- function __construct()
- {
- }
- function __destruct()
- {
- }
- }
diff --git a/libraries/phpvideotoolkit/adapters/toolkit/stream.php b/libraries/phpvideotoolkit/adapters/toolkit/stream.php
deleted file mode 100644
index cfd3825..0000000
--- a/libraries/phpvideotoolkit/adapters/toolkit/stream.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
- /* SVN FILE: $Id$ */
- /**
- * @author Oliver Lillie (aka buggedcom) <publicmail@buggedcom.co.uk>
- * @package PHPVideoToolkit
- * @license BSD
- * @copyright Copyright (c) 2008 Oliver Lillie <http://www.buggedcom.co.uk>
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
- * is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
- /**
- * This class
- */
- class PHPVideoToolkit_Stream
- {
- function __construct()
- {
- }
- function __destruct()
- {
- }
- }
diff --git a/libraries/phpvideotoolkit/adapters/toolkit/video.php b/libraries/phpvideotoolkit/adapters/toolkit/video.php
deleted file mode 100644
index 759d884..0000000
--- a/libraries/phpvideotoolkit/adapters/toolkit/video.php
+++ /dev/null
@@ -1,387 +0,0 @@
-<?php
-
- /* SVN FILE: $Id$ */
- /**
- * @author Oliver Lillie (aka buggedcom) <publicmail@buggedcom.co.uk>
- * @package PHPVideoToolkit
- * @license BSD
- * @copyright Copyright (c) 2008 Oliver Lillie <http://www.buggedcom.co.uk>
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
- * is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
- if(!defined('DS'))
- {
- define('DS', DIRECTORY_SEPARATOR);
- }
-
- /**
- * This is similar in terms to FFmpeg-PHP's ffmpeg_movie, however it is just for video's and not just audio.
- */
- class PHPVideoToolkit_Video
- {
- private $_frame_index = 1;
- private $_toolkit = null;
- private $_media_data = null;
- private $_path_to_media = null;
- private $_tmp_directory = null;
-
- /**
- * Class Constructor
- * @param string $path_to_media The path to the media file you want to use.
- * @param string $tmp_directory The temp directory to which to work from. (remember the trailing slash), default set by PHPVIDEOTOOLKIT_TEMP_DIRECTORY
- */
- function __construct($path_to_media, $tmp_directory=PHPVIDEOTOOLKIT_TEMP_DIRECTORY)
- {
-// init PHPVideoToolkit class
- require_once dirname(dirname(dirname(__FILE__))).DS.'phpvideotoolkit.php5.php';
-// store the media path
- $this->_path_to_media = $path_to_media;
- $this->_tmp_directory = $tmp_directory;
-// if the path is infact a class of PHPVideoToolkit then just copy the class
- if(get_class($path_to_media) === false)
- {
- $this->_toolkit = $path_to_media;
- }
- else
- {
-// create the toolkit item
- $this->_toolkit = new PHPVideoToolkit($tmp_directory);
- $this->_toolkit->on_error_die = false;
-// set the input
- $this->_toolkit->setInputFile($path_to_media);
- }
- }
-
- /**
- * Destructs any internal processes.
- * @access private
- */
- function __destruct()
- {
-// loop through the temp files to remove first as they have to be removed before the dir can be removed
- if(!empty($this->_unlink_files))
- {
- foreach ($this->_unlink_files as $key=>$file)
- {
- if(is_file($file))
- {
- @unlink($file);
- }
- }
- $this->_unlink_files = array();
- }
-// loop through the dirs to remove
- if(!empty($this->_unlink_dirs))
- {
- foreach ($this->_unlink_dirs as $key=>$dir)
- {
- if(is_dir($dir))
- {
- @rmdir($dir);
- }
- }
- $this->_unlink_dirs = array();
- }
- }
-
- /**
- * Loads the meta data for the media file
- * @access private
- */
- private function _getMediaData()
- {
- if($this->_media_data === null)
- {
- $this->_media_data = $this->_toolkit->getFileInfo();
- }
- }
-
- /**
- * Return the duration of a movie or audio file in seconds.
- * @access public
- * @return integer
- */
- public function getDuration()
- {
- $this->_getMediaData();
- return $this->_media_data['duration']['seconds'];
- }
-
- /**
- * Return the number of frames in a movie or audio file.
- * @access public
- * @return integer
- */
- public function getFrameCount()
- {
- return $this->hasVideo() ? $this->_media_data['video']['frame_count'] : -1;
- }
-
- /**
- * Return the frame rate of a movie in fps.
- * @access public
- * @return integer
- */
- public function getFrameRate()
- {
- return $this->hasVideo() ? $this->_media_data['video']['frame_rate'] : -1;
- }
-
- /**
- * Return the path and name of the movie file or audio file.
- * @access public
- * @return string
- */
- public function getFilename()
- {
- return basename($this->_path_to_media);
- }
-
- /**
- * Return the height of the movie in pixels.
- * @access public
- * @return integer
- */
- public function getFrameHeight()
- {
- return $this->hasVideo() && isset($this->_media_data['video']['dimensions']) ? $this->_media_data['video']['dimensions']['height'] : -1;
- }
-
- /**
- * Return the width of the movie in pixels.
- * @access public
- * @return integer
- */
- public function getFrameWidth()
- {
- return $this->hasVideo() && isset($this->_media_data['video']['dimensions']) ? $this->_media_data['video']['dimensions']['width'] : -1;
- }
-
- /**
- * Return the pixel format of the movie.
- * @access public
- * @return mixed string | -1
- */
- public function getPixelFormat()
- {
- return $this->hasVideo() ? $this->_media_data['video']['pixel_format'] : -1;
- }
-
- /**
- * Return the pixel aspect ratio of the movie
- * @access public
- * @return integer
- */
- public function getPixelAspectRatio()
- {
- return -1;
- }
-
- /**
- * Return the bit rate of the movie or audio file in bits per second.
- * @access public
- * @return integer
- */
- public function getBitRate()
- {
- $this->_getMediaData();
- return isset($this->_media_data['bitrate']) ? $this->_media_data['bitrate'] : -1;
- }
-
- /**
- * Return the bit rate of the video in bits per second.
- * NOTE: This only works for files with constant bit rate.
- * @access public
- * @return integer
- */
- public function getVideoBitRate()
- {
- return $this->hasVideo() && isset($this->_media_data['video']['bitrate']) ? $this->_media_data['video']['bitrate'] : -1;
- }
-
- /**
- * Return the audio bit rate of the media file in bits per second.
- * @access public
- * @return integer
- */
- public function getAudioBitRate()
- {
- return $this->hasAudio() && isset($this->_media_data['audio']['bitrate']) ? $this->_media_data['audio']['bitrate'] : -1;
- }
-
- /**
- * Return the audio sample rate of the media file in bits per second.
- * @access public
- * @return integer
- */
- public function getAudioSampleRate()
- {
- return $this->hasAudio() && isset($this->_media_data['audio']['sample_rate']) ? $this->_media_data['audio']['sample_rate'] : -1;
- }
-
- /**
- * Return the name of the video codec used to encode this movie as a string.
- * @access public
- * @param boolean $return_all If true it will return all audio codecs found.
- * @return mixed string | array
- */
- public function getVideoCodec($return_all=false)
- {
- return $this->hasVideo() ? $this->_media_data['video']['codec'] : -1;
- }
-
- /**
- * Return the name of the audio codec used to encode this movie as a string.
- * @access public
- * @param boolean $return_all If true it will return all audio codecs found.
- * @return mixed string | array
- */
- public function getAudioCodec()
- {
- return $this->hasAudio() ? $this->_media_data['audio']['codec'] : -1;
- }
-
- /**
- * Return the number of audio channels in this movie as an integer.
- * @access public
- * @return integer
- */
- public function getAudioChannels()
- {
- return $this->hasAudio();
- }
-
- /**
- * Return boolean value indicating whether the movie has an audio stream.
- * @access public
- * @return boolean
- */
- public function hasAudio()
- {
- $this->_getMediaData();
- return isset($this->_media_data['audio']);
- }
-
- /**
- * Return boolean value indicating whether the movie has a video stream.
- * @access public
- * @return boolean
- */
- public function hasVideo()
- {
- $this->_getMediaData();
- return isset($this->_media_data['video']);
- }
-
- public function convert()
- {
- }
-
- /**
- * This will resize and return an new instance of PHPVideoToolkit_Video.
- * @access public
- * @return PHPVideoToolkit_Video
- */
- public function resize($width, $height=null, $multi_pass_encode=false)
- {
-// set the instance dimensions
- $this->_toolkit->setVideoDimensions($width, $height);
-// create a new video toolkit object to return
- return new PHPVideoToolkit_Video($this->_toolkit, $this->_tmp_directory);
- }
-
- public function watermark()
- {
- }
-
- public function getAudio()
- {
- }
-
- public function save($filename, $multi_pass_encode=false, $overwrite_mode=PHPVideoToolkit::OVERWRITE_FAIL)
- {
- $output_directory, $output_name,
- $path_info = pathinfo($filename);
-// set the output
- $this->_toolkit->setOutput($path_info['dirname'], $path_parts['basename'], $overwrite_mode);
- return $this->_toolkit->execute($multi_pass_encode, false);
- }
-
- /**
- * Returns a frame from the movie as an PHPVideoToolkit_Frame object.
- * Returns false if the frame was not found.
- * @access public
- * @return mixed boolean | PHPVideoToolkit_Frame
- */
- public function getFrame($frame_number=false)
- {
- if(!$this->hasVideo())
- {
- return false;
- }
- $this->_toolkit->reset(true);
- require_once dirname(__FILE__).DS.'frame.php';
- if(!$frame_number)
- {
- $frame_number = $this->_frame_index;
- $this->_frame_index += 1;
- }
- else
- {
- $this->_frame_index = $frame_number;
- }
-// check the frame required exists in the video
- if($frame_number > $this->getFrameCount())
- {
- return false;
- }
-// work out the exact frame to take
- $frame_rate = $this->getFrameRate();
-// generate a unique name
- $this->_toolkit->setOutput($this->_tmp_directory, $this->_toolkit->unique().'-%timecode.jpg', PHPVideoToolkit::OVERWRITE_EXISTING);
-// extract the frame and check the extract is ok
- if(!($result = $this->_toolkit->extractFrame($frame_number, $frame_rate, '%ft'))
- {
- return $result;
- }
-// return the PHPVideoToolkit_Frame instance
- return new PHPVideoToolkit_Frame($this->_toolkit);
- }
-
- /**
- * Returns the next key frame from the movie as an PHPVideoToolkit_Frame object.
- * Returns false if the frame was not found.
- * @uses PHPVideoToolkit_Video::getFrame();
- * @access public
- * @return mixed boolean | PHPVideoToolkit_Frame
- */
- public function getNextKeyFrame()
- {
- $frame_rate = $this->getFrameRate();
-// work out the next frame
- $current_second = floor($frame_number/$frame_rate);
- $excess = $frame_number-($seconds * $frame_rate);
- $frames_to_next = $frame_rate-$excess;
- $this->_frame_index += $frames_to_next;
-// get the frame
- return $this->getFrame();
- }
-
- /**
- * Return the current frame index.
- * @access public
- * @return integer
- */
- public function getFrameNumber()
- {
- return $this->_frame_index;
- }
- }