aboutsummaryrefslogtreecommitdiff
path: root/libraries/phpvideotoolkit/examples/php5
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/phpvideotoolkit/examples/php5')
-rw-r--r--libraries/phpvideotoolkit/examples/php5/example01.php158
-rw-r--r--libraries/phpvideotoolkit/examples/php5/example02.php139
-rw-r--r--libraries/phpvideotoolkit/examples/php5/example03.php114
-rw-r--r--libraries/phpvideotoolkit/examples/php5/example04.php171
-rw-r--r--libraries/phpvideotoolkit/examples/php5/example05.php84
-rw-r--r--libraries/phpvideotoolkit/examples/php5/example06.php147
-rw-r--r--libraries/phpvideotoolkit/examples/php5/example07.php120
-rw-r--r--libraries/phpvideotoolkit/examples/php5/example08.php191
-rw-r--r--libraries/phpvideotoolkit/examples/php5/example09.php92
-rw-r--r--libraries/phpvideotoolkit/examples/php5/example10.php128
-rw-r--r--libraries/phpvideotoolkit/examples/php5/example11.php162
-rw-r--r--libraries/phpvideotoolkit/examples/php5/example12.php236
-rw-r--r--libraries/phpvideotoolkit/examples/php5/example13.php111
-rw-r--r--libraries/phpvideotoolkit/examples/php5/example14.php183
-rw-r--r--libraries/phpvideotoolkit/examples/php5/example15.php41
15 files changed, 2077 insertions, 0 deletions
diff --git a/libraries/phpvideotoolkit/examples/php5/example01.php b/libraries/phpvideotoolkit/examples/php5/example01.php
new file mode 100644
index 0000000..ebbeae1
--- /dev/null
+++ b/libraries/phpvideotoolkit/examples/php5/example01.php
@@ -0,0 +1,158 @@
+<?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.
+ */
+
+ echo '<html><head><link type="text/css" rel="stylesheet" href="../common/styles.css"><script type="text/javascript" charset="utf-8" src="../common/pluginobject/pluginobject.js"></script><script>PO.Options.auto_load_prefix="../common/pluginobject/plugins/";</script><meta name="author" content="Oliver Lillie"></head><body>';
+ echo '<a class="backtoexamples" href="../index.php#examples">&larr; Back to examples list</a><br /><br />';
+ echo '<strong>This example shows you how to convert video to flash video (flv).</strong><br />';
+ echo '<span class="small">&bull; The media player used below is Jeroen Wijering\'s excellent <a href="http://www.jeroenwijering.com/?item=JW_FLV_Media_Player">Flash Media Player</a>. Although bundled with this package the Flash Media Player has a <a href="http://creativecommons.org/licenses/by-nc-sa/2.0/">Creative Commons Attribution-Noncommercial-Share Alike 2.0 Generic</a> license.</span><br />';
+ echo '<span class="small">&bull; The media player is embedded using <a href="http://sourceforge.net/projects/pluginobject/">PluginObject</a> to embed the examples. It is distributed under a BSD License.</span><br /><br />';
+
+// load the examples configuration
+ require_once '../example-config.php';
+
+// require the library
+ require_once '../../phpvideotoolkit.'.$use_version.'.php';
+
+// temp directory
+ $tmp_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'tmp'.DS;
+
+// input movie files
+ $files_to_process = array(
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'MOV00007.3gp',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'Video000.3gp',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'cat.mpeg'
+ );
+
+// output files dirname has to exist
+ $video_output_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'processed'.DS.'videos'.DS;
+
+// log dir
+ $log_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'logs'.DS;
+
+// bit rate of audio (valid vaues are 16,32,64)
+ $bitrate = 64;
+
+// sampling rate (valid values are 11025, 22050, 44100)
+ $samprate = 44100;
+
+// start PHPVideoToolkit class
+ $toolkit = new PHPVideoToolkit($tmp_dir);
+
+// set PHPVideoToolkit class to run silently
+ $toolkit->on_error_die = FALSE;
+
+// start the timer collection
+ $total_process_time = 0;
+
+// loop through the files to process
+ foreach($files_to_process as $key=>$file)
+ {
+// get the filename parts
+ $filename = basename($file);
+ $filename_minus_ext = substr($filename, 0, strrpos($filename, '.'));
+ echo '<strong>Processing '.$filename.'</strong><br />';
+
+// set the input file
+ $ok = $toolkit->setInputFile($file);
+// check the return value in-case of error
+ if(!$ok)
+ {
+// if there was an error then get it
+ echo $toolkit->getLastError()."<br /><br />\r\n";
+ $toolkit->reset();
+ continue;
+ }
+
+// set the output dimensions
+ $toolkit->setVideoOutputDimensions(320, 240);
+
+// set the video to be converted to flv
+ $ok = $toolkit->setFormatToFLV($samprate, $bitrate, true);
+// check the return value in-case of error as we are validating the codecs
+ if(!$ok)
+ {
+// if there was an error then get it
+ echo $toolkit->getLastError()."<br /><br />\r\n";
+ $toolkit->reset();
+ continue;
+ }
+// set the output details and overwrite if nessecary
+ $ok = $toolkit->setOutput($video_output_dir, $filename_minus_ext.'.flv', PHPVideoToolkit::OVERWRITE_EXISTING);
+// check the return value in-case of error
+ if(!$ok)
+ {
+// if there was an error then get it
+ echo $toolkit->getLastError()."<br /><br />\r\n";
+ $toolkit->reset();
+ continue;
+ }
+
+// execute the ffmpeg command using multiple passes and log the calls and ffmpeg results
+ $result = $toolkit->execute(true, true);
+
+// get the last command given
+ $command = $toolkit->getLastCommand();
+// echo $command[0]."<br />\r\n";
+// echo $command[1]."<br />\r\n";
+
+// check the return value in-case of error
+ if($result !== PHPVideoToolkit::RESULT_OK)
+ {
+// move the log file to the log directory as something has gone wrong
+ $toolkit->moveLog($log_dir.$filename_minus_ext.'.log');
+// if there was an error then get it
+ echo $toolkit->getLastError()."<br /><br />\r\n";
+ $toolkit->reset();
+ continue;
+ }
+
+// get the process time of the file
+ $process_time = $toolkit->getLastProcessTime();
+ $total_process_time += $process_time;
+
+ $file = array_shift($toolkit->getLastOutput());
+ $filename = basename($file);
+ $filename_hash = md5($filename);
+
+// echo a report to the buffer
+ echo 'Video converted in '.$process_time.' seconds... <b>'.$file.'</b><br /><br />
+<div id="'.$filename_hash.'"></div>
+<script type="text/javascript" charset="utf-8">
+ PluginObject.embed("../working/processed/videos/'.$filename.'", {
+ width : 320,
+ height: 240,
+ force_plugin:PluginObject.Plugins.FlashMedia,
+ player: "../common/mediaplayer/player.swf",
+ force_into_id:"'.$filename_hash.'",
+ overstretch:true,
+ params: {
+ autoplay: false
+ }
+ });
+</script><br />'."\r\n";
+
+// reset
+ $toolkit->reset();
+ }
+
+ echo ''."\r\n".'The total time taken to process all '.($key+1).' file(s) is : <b>'.$total_process_time.'</b>';
+ echo '<br />'."\r\n".'The average time taken to process each file is : <b>'.($total_process_time/($key+1)).'</b>';
+ echo '</body></html>'; \ No newline at end of file
diff --git a/libraries/phpvideotoolkit/examples/php5/example02.php b/libraries/phpvideotoolkit/examples/php5/example02.php
new file mode 100644
index 0000000..ed629a0
--- /dev/null
+++ b/libraries/phpvideotoolkit/examples/php5/example02.php
@@ -0,0 +1,139 @@
+<?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.
+ */
+
+ echo '<html><head><link type="text/css" rel="stylesheet" href="../common/styles.css"><meta name="author" content="Oliver Lillie"></head><body>';
+ echo '<a class="backtoexamples" href="../index.php#examples">&larr; Back to examples list</a><br /><br />';
+ echo '<strong>This example shows you how to extract frames from a movie.</strong><br />';
+
+// load the examples configuration
+ require_once '../example-config.php';
+
+// require the library
+ require_once '../../phpvideotoolkit.'.$use_version.'.php';
+
+ echo '<span class="alert"><strong>Note; </strong>This example should work correctly, however it\'s not. I don\'t currently understand why it\'s not producing the expected thumbnails. I\'m currently looking into it and the example will be updated when this process is fixed.</span><br /><br />';
+
+// temp directory
+ $tmp_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'tmp'.DS;
+
+// input movie files
+ $files_to_process = array(
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'MOV00007.3gp',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'Video000.3gp',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'cat.mpeg'
+ );
+
+// output files dirname has to exist
+ $thumbnail_output_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'processed'.DS.'thumbnails'.DS;
+
+// log dir
+ $log_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'logs'.DS;
+
+// start PHPVideoToolkit class
+ $toolkit = new PHPVideoToolkit($tmp_dir);
+
+// set PHPVideoToolkit class to run silently
+ $toolkit->on_error_die = FALSE;
+
+// the number of frames to extract per second
+ $extraction_frame_rate = 5;
+
+// start the timer collection
+ $total_process_time = 0;
+
+// loop through the files to process
+ foreach($files_to_process as $key=>$file)
+ {
+// get the filename parts
+ $filename = basename($file);
+ $filename_minus_ext = substr($filename, 0, strrpos($filename, '.'));
+ echo '<strong>Extracting '.$filename.'</strong><br />';
+
+// set the input file
+ $ok = $toolkit->setInputFile($file, $extraction_frame_rate);
+// check the return value in-case of error
+ if(!$ok)
+ {
+// if there was an error then get it
+ echo '<b>'.$toolkit->getLastError()."</b><br />\r\n";
+ $toolkit->reset();
+ continue;
+ }
+
+// set the output dimensions
+ $toolkit->setVideoOutputDimensions(160, 120);
+
+// extract thumbnails from the third second of the video, but we only want to limit the number of frames to 10
+ $info = $toolkit->getFileInfo();
+ echo 'We are extracting frames at a rate of '.$extraction_frame_rate.'/second so for this file we should have '.ceil($info['duration']['seconds']*$extraction_frame_rate).' frames below.<br />';
+ $toolkit->extractFrames('00:00:00', false, $extraction_frame_rate, false, '%hh:%mm:%ss');
+
+// set the output details
+ $ok = $toolkit->setOutput($thumbnail_output_dir, $filename_minus_ext.'[%timecode].jpg', PHPVideoToolkit::OVERWRITE_EXISTING);
+// $ok = $toolkit->setOutput($thumbnail_output_dir, $filename_minus_ext.'[%12index].jpg', PHPVideoToolkit::OVERWRITE_EXISTING);
+// check the return value in-case of error
+ if(!$ok)
+ {
+// if there was an error then get it
+ echo '<b>'.$toolkit->getLastError()."</b><br />\r\n";
+ $toolkit->reset();
+ continue;
+ }
+
+// execute the ffmpeg command
+ $result = $toolkit->execute(false, true);
+
+// get the last command given
+// $command = $toolkit->getLastCommand();
+// echo $command."<br />\r\n";
+
+// check the return value in-case of error
+ if($result !== PHPVideoToolkit::RESULT_OK)
+ {
+// move the log file to the log directory as something has gone wrong
+ $toolkit->moveLog($log_dir.$filename_minus_ext.'.log');
+// if there was an error then get it
+ echo '<b>'.$toolkit->getLastError()."</b><br />\r\n";
+ $toolkit->reset();
+ continue;
+ }
+
+// get the process time of the file
+ $process_time = $toolkit->getLastProcessTime();
+ $total_process_time += $process_time;
+
+ $files = $toolkit->getLastOutput();
+
+ echo 'Frames grabbed in '.$process_time.' seconds... <b>'.$thumbnail_output_dir.array_pop($files).'</b><br />'."\r\n";
+ foreach($files as $key=>$file)
+ {
+ echo '<img src="../working/processed/thumbnails/'.$file.'" alt="" border="0" /> ';
+ }
+ echo '<br /><br />';
+
+// reset
+ $toolkit->reset();
+
+ }
+
+ echo ''."\r\n".'The total time taken to process all '.($key+1).' file(s) is : <b>'.$total_process_time.'</b>';
+ echo '<br />'."\r\n".'The average time taken to process each file is : <b>'.($total_process_time/($key+1)).'</b>';
+ echo '</body></html>'; \ No newline at end of file
diff --git a/libraries/phpvideotoolkit/examples/php5/example03.php b/libraries/phpvideotoolkit/examples/php5/example03.php
new file mode 100644
index 0000000..76d5110
--- /dev/null
+++ b/libraries/phpvideotoolkit/examples/php5/example03.php
@@ -0,0 +1,114 @@
+<?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.
+ */
+
+ echo '<html><head><link type="text/css" rel="stylesheet" href="../common/styles.css"><meta name="author" content="Oliver Lillie"></head><body>';
+ echo '<a class="backtoexamples" href="../index.php#examples">&larr; Back to examples list</a><br /><br />';
+ echo '<strong>This example shows you how to compile a movie from multiple jpegs.</strong><br />';
+
+// load the examples configuration
+ require_once '../example-config.php';
+
+// require the library
+ require_once '../../phpvideotoolkit.'.$use_version.'.php';
+
+// output files dirname has to exist
+ $tmp_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'tmp'.DS;
+
+// input movie files
+ $files_to_process = array(
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'mov02596-1.jpg',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'mov02596-2.jpg',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'mov02596-3.jpg',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'mov02596-4.jpg',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'mov02596-5.jpg',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'mov02596-6.jpg',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'mov02596-7.jpg',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'mov02596-8.jpg',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'mov02596-9.jpg',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'mov02596-10.jpg',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'mov02596-11.jpg',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'mov02596-12.jpg',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'mov02596-13.jpg',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'mov02596-14.jpg'
+ );
+
+ $sound = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'Ballad_of_the_Sneak.mp3';
+
+// output files dirname has to exist
+ $video_output_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'processed'.DS.'videos'.DS;
+
+// log dir
+ $log_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'logs'.DS;
+
+// output filename
+ $output_filename = 'my-picture-movie.gif';
+// $output_filename = 'my-picture-movie.mpeg';
+
+// init PHPVideoToolkit class
+ $toolkit = new PHPVideoToolkit($tmp_dir);
+
+// compile the image to the tmp dir with an input frame rate of 2 per second
+ $ok = $toolkit->prepareImagesForConversionToVideo($files_to_process, 2);
+ if(!$ok)
+ {
+// if there was an error then get it
+ echo $toolkit->getLastError()."<br />\r\n";
+ exit;
+ }
+
+// set a different output size (this will shrink the images to a video that is smaller, the images are 320x240)
+ $toolkit->setVideoOutputDimensions(160, 120);
+
+// set endless looping
+ $toolkit->setGifLoops(0);
+// $toolkit->addAudio($sound);
+
+// set the output parameters
+ $ok = $toolkit->setOutput($video_output_dir, $output_filename, PHPVideoToolkit::OVERWRITE_EXISTING);
+ if(!$ok)
+ {
+// if there was an error then get it
+ echo $toolkit->getLastError()."<br />\r\n";
+ exit;
+ }
+
+// execute the ffmpeg command
+ $result = $toolkit->execute(false, true);
+
+// get the last command given
+// $command = $toolkit->getLastCommand();
+// echo $command."<br />\r\n<br />\r\n";
+
+// check the return value in-case of error
+ if($result !== PHPVideoToolkit::RESULT_OK)
+ {
+// move the log file to the log directory as something has gone wrong
+ $toolkit->moveLog($log_dir.'example03.log');
+// if there was an error then get it
+ echo $toolkit->getLastError()."<br />\r\n";
+ exit;
+ }
+ $toolkit->moveLog($log_dir.'example03.log');
+
+ $img = array_shift($toolkit->getLastOutput());
+ echo "Video created from images... <b>".basename($img)."</b><br />";
+ echo '<img src="../working/processed/videos/'.basename($img).'" border="0" /><br /><br />';
+ echo '</body></html>';
diff --git a/libraries/phpvideotoolkit/examples/php5/example04.php b/libraries/phpvideotoolkit/examples/php5/example04.php
new file mode 100644
index 0000000..dd7bffd
--- /dev/null
+++ b/libraries/phpvideotoolkit/examples/php5/example04.php
@@ -0,0 +1,171 @@
+<?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.
+ */
+
+ echo '<html><head><link type="text/css" rel="stylesheet" href="../common/styles.css"><script type="text/javascript" charset="utf-8" src="../common/pluginobject/pluginobject.js"></script><script>PO.Options.auto_load_prefix="../common/pluginobject/plugins/";</script><meta name="author" content="Oliver Lillie"></head><body>';
+ echo '<a class="backtoexamples" href="../index.php#examples">&larr; Back to examples list</a><br /><br />';
+ echo '<strong>This example shows you how to watermark a video. Please note; that in order to watermark a video FFmpeg has to have been compiled with vhooks enabled.</strong><br />';
+ echo '<span class="small">&bull; The media player is embedded using <a href="http://sourceforge.net/projects/pluginobject/">PluginObject</a> to embed the video examples. It is distributed under a BSD License.</span><br /><br />';
+
+// load the examples configuration
+ require_once '../example-config.php';
+
+// require the library
+ require_once '../../phpvideotoolkit.'.$use_version.'.php';
+
+// please replace xxxxx with the full absolute path to the files and folders
+// also please make the $thumbnail_output_dir read and writeable by the webserver
+
+// temp directory
+ $tmp_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'tmp'.DS;
+
+// input movie files
+ $video_to_process = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'cat.mpeg';
+ $watermark = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'watermark.png';
+// $watermark = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'watermark.gif';
+
+// output files dirname has to exist
+ $video_output_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'processed'.DS.'videos'.DS;
+
+// output files dirname has to exist
+ $thumbnail_output_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'processed'.DS.'thumbnails'.DS;
+
+// log dir
+ $log_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'logs'.DS;
+
+// start PHPVideoToolkit class
+ $toolkit = new PHPVideoToolkit($tmp_dir);
+
+ $use_vhook = !isset($_GET['gd']) || $_GET['gd'] == '0';
+ if($use_vhook)
+ {
+// check to see if vhook support is enabled
+ echo '<strong>Testing for vhook support...</strong><br />';
+ if(!$toolkit->hasVHookSupport())
+ {
+ echo '<span class="alert">You FFmpeg binary has NOT been compiled with vhook support, you can not watermark video, you can however watermark image outputs.</span><br /><a href="?gd=1">Click here</a> to run the watermark demo on images only.<br />';
+ exit;
+//<- exits
+ }
+ echo 'You FFmpeg binary has been compiled with vhook support.<br /><br />';
+ }
+ else
+ {
+ echo '<strong>GD watermarking only...</strong><br />';
+ echo '<span class="alert">Your FFmpeg binary has NOT been compiled with vhook support and we are only testing automated watermarking of images via GD now.</span><br /><a href="?gd=0">Click here</a> to go back to the vhook watermarking demo.<br /><br />';
+ }
+
+// set ffmpeg class to run silently
+ $toolkit->on_error_die = FALSE;
+
+// get the filename parts
+ $filename = basename($video_to_process);
+ $filename_minus_ext = substr($filename, 0, strrpos($filename, '.'));
+
+// set the input file
+ $ok = $toolkit->setInputFile($video_to_process);
+// check the return value in-case of error
+ if(!$ok)
+ {
+// if there was an error then get it
+ echo '<b>'.$toolkit->getLastError()."</b><br />\r\n";
+ exit;
+ }
+
+// set the output dimensions
+ $toolkit->setVideoOutputDimensions(PHPVideoToolkit::SIZE_SAS);
+
+// are we vhooking the videos?
+ if($use_vhook)
+ {
+ $toolkit->addWatermark($watermark);
+ $ok = $toolkit->setOutput($video_output_dir, $filename_minus_ext.'-watermarked.3gp', PHPVideoToolkit::OVERWRITE_EXISTING);
+ }
+// or just outputting images with watermarks?
+ else
+ {
+ $toolkit->addGDWatermark($watermark, array('x-offset'=>-15, 'y-offset'=>-15, 'position'=>'center-middle'));
+// extract a single frame
+ $toolkit->extractFrame('00:00:03.5');
+ $ok = $toolkit->setOutput($thumbnail_output_dir, $filename_minus_ext.'-watermarked.jpeg', PHPVideoToolkit::OVERWRITE_EXISTING);
+ }
+
+// set the output details
+// check the return value in-case of error
+ if(!$ok)
+ {
+// if there was an error then get it
+ echo '<b>'.$toolkit->getLastError()."</b><br />\r\n";
+ exit;
+ }
+
+// execute the ffmpeg command
+ $result = $toolkit->execute(false, true);
+
+// get the last command given
+// $command = $toolkit->getLastCommand();
+// echo $command."<br />\r\n";
+
+// check the return value in-case of error
+ if($result !== PHPVideoToolkit::RESULT_OK)
+ {
+// move the log file to the log directory as something has gone wrong
+ $toolkit->moveLog($log_dir.$filename_minus_ext.'.log');
+// if there was an error then get it
+ echo '<b>'.$toolkit->getLastError()."</b><br />\r\n";
+ $toolkit->reset();
+ exit;
+ }
+
+ $file = array_shift($toolkit->getLastOutput());
+ $filename = basename($file);
+ if($use_vhook)
+ {
+ $filename_hash = md5($filename);
+
+ echo 'Video watermarked... <b>'.$filename.'</b><br /><br />
+<div id="'.$filename_hash.'"></div>
+<script type="text/javascript" charset="utf-8">
+ PluginObject.embed("../working/processed/videos/'.$filename.'", {
+ width : 320,
+ height: 240,
+ force_plugin:PluginObject.Plugins.Quicktime,
+ force_into_id:"'.$filename_hash.'",
+ params: {
+ autoplay: false
+ }
+ });
+</script><br />'."\r\n";
+ }
+ else
+ {
+ echo 'Frame watermarked... <b>'.$filename.'</b><br />'."\r\n";
+// $files = $toolkit->getLastOutput();
+// foreach($files as $key=>$file)
+// {
+// echo '<img src="../working/processed/thumbnails/'.$file.'" alt="" border="0" /> ';
+// }
+ echo '<img src="../working/processed/thumbnails/'.$filename.'" alt="" border="0" /> ';
+ }
+
+// reset
+ $toolkit->reset();
+
+ echo '</body></html>';
diff --git a/libraries/phpvideotoolkit/examples/php5/example05.php b/libraries/phpvideotoolkit/examples/php5/example05.php
new file mode 100644
index 0000000..46399e6
--- /dev/null
+++ b/libraries/phpvideotoolkit/examples/php5/example05.php
@@ -0,0 +1,84 @@
+<?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.
+ */
+
+ echo '<html><head><link type="text/css" rel="stylesheet" href="../common/styles.css"><meta name="author" content="Oliver Lillie"></head><body>';
+ echo '<a class="backtoexamples" href="../index.php#examples">&larr; Back to examples list</a><br /><br />';
+ echo '<strong>This example shows you how to access media metadata without using the ffmpeg-php library.</strong><br />';
+
+// load the examples configuration
+ require_once '../example-config.php';
+
+// require the library
+ require_once '../../phpvideotoolkit.'.$use_version.'.php';
+
+// please replace xxxxx with the full absolute path to the files and folders
+// also please make the $video_output_dir read and writeable by the webserver
+
+// temp directory
+ $tmp_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'tmp'.DS;
+
+// input movie files
+ $files_to_process = array(
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'MOV00007.3gp',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'Video000.3gp',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'cat.mpeg'
+ );
+
+// output files dirname has to exist
+ $video_output_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'processed'.DS.'videos'.DS;
+
+// bit rate of audio (valid vaues are 16,32,64)
+ $bitrate = 64;
+
+// sampling rate (valid values are 11025, 22050, 44100)
+ $samprate = 44100;
+
+// start PHPVideoToolkit class
+ $toolkit = new PHPVideoToolkit($tmp_dir);
+
+// set PHPVideoToolkit class to run silently
+ $toolkit->on_error_die = FALSE;
+
+// loop through the files to process
+ foreach($files_to_process as $file)
+ {
+ echo '<strong>Information for : '.$file."</strong><br />\r\n";
+// set the input file
+ $ok = $toolkit->setInputFile($file);
+// check the return value in-case of error
+ if(!$ok)
+ {
+// if there was an error then get it
+ echo $toolkit->getLastError()."<br />\r\n";
+ $toolkit->reset();
+ continue;
+ }
+ $data = $toolkit->getFileInfo();
+
+ echo '<pre>';
+ print_r($data);
+ echo '</pre>';
+
+// reset
+ $toolkit->reset();
+ }
+
+ echo '</body></html>'; \ No newline at end of file
diff --git a/libraries/phpvideotoolkit/examples/php5/example06.php b/libraries/phpvideotoolkit/examples/php5/example06.php
new file mode 100644
index 0000000..1d4ad63
--- /dev/null
+++ b/libraries/phpvideotoolkit/examples/php5/example06.php
@@ -0,0 +1,147 @@
+<?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.
+ */
+
+ echo '<html><head><link type="text/css" rel="stylesheet" href="../common/styles.css"><script type="text/javascript" charset="utf-8" src="../common/pluginobject/pluginobject.js"></script><script>PO.Options.auto_load_prefix="../common/pluginobject/plugins/";</script><meta name="author" content="Oliver Lillie"></head><body>';
+ echo '<a class="backtoexamples" href="../index.php#examples">&larr; Back to examples list</a><br /><br />';
+ echo '<strong>This example shows you how to extract audio from video.</strong><br />';
+ echo '<span class="small">&bull; The media player used below is Jeroen Wijering\'s excellent <a href="http://www.jeroenwijering.com/?item=JW_FLV_Media_Player">Flash Media Player</a>. Although bundled with this package the Flash Media Player has a <a href="http://creativecommons.org/licenses/by-nc-sa/2.0/">Creative Commons Attribution-Noncommercial-Share Alike 2.0 Generic</a> license.</span><br />';
+ echo '<span class="small">&bull; The media player is embedded using <a href="http://sourceforge.net/projects/pluginobject/">PluginObject</a> to embed the examples. It is distributed under a BSD License.</span><br />';
+
+// load the examples configuration
+ require_once '../example-config.php';
+
+// require the library
+ require_once '../../phpvideotoolkit.'.$use_version.'.php';
+
+// temp directory
+ $tmp_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'tmp'.DS;
+
+// input movie files
+ $files_to_process = array(
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'red5RecordDemo_266.flv',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'on2_flash8_w_audio.flv',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'MOV00007.3gp',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'cat.mpeg'
+ );
+
+// output files dirname has to exist
+ $audio_output_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'processed'.DS.'audio'.DS;
+
+// log dir
+ $log_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'logs'.DS;
+
+// bit rate of audio (valid vaues are 16,32,64)
+ $bitrate = 64;
+
+// sampling rate (valid values are 11025, 22050, 44100)
+ $samprate = 44100;
+
+// start PHPVideoToolkit class
+ $toolkit = new PHPVideoToolkit($tmp_dir);
+
+// set PHPVideoToolkit class to run silently
+ $toolkit->on_error_die = FALSE;
+
+// start the timer collection
+ $total_process_time = 0;
+
+// loop through the files to process
+ foreach($files_to_process as $key=>$file)
+ {
+// get the filename parts
+ $filename = basename($file);
+ $filename_minus_ext = substr($filename, 0, strrpos($filename, '.'));
+ echo '<strong>Processing '.$filename.'</strong><br />';
+
+// set the input file
+ $ok = $toolkit->setInputFile($file);
+// check the return value in-case of error
+ if(!$ok)
+ {
+// if there was an error then get it
+ echo $toolkit->getLastError()."<br /><br />\r\n";
+ $toolkit->reset();
+ continue;
+ }
+
+// set the audio extraction settings
+ $toolkit->extractAudio(PHPVideoToolkit::FORMAT_MP3, $samprate, $bitrate);
+
+// set the output details and overwrite if nessecary
+ $ok = $toolkit->setOutput($audio_output_dir, $filename_minus_ext.'.mp3', PHPVideoToolkit::OVERWRITE_EXISTING);
+// check the return value in-case of error
+ if(!$ok)
+ {
+// if there was an error then get it
+ echo $toolkit->getLastError()."<br /><br />\r\n";
+ $toolkit->reset();
+ continue;
+ }
+
+// execute the ffmpeg command and log the calls and ffmpeg results
+ $result = $toolkit->execute(false, true);
+
+// get the last command given
+ $command = $toolkit->getLastCommand();
+ echo $command."<br />\r\n";
+
+// check the return value in-case of error
+ if($result !== PHPVideoToolkit::RESULT_OK)
+ {
+// move the log file to the log directory as something has gone wrong
+ $toolkit->moveLog($log_dir.$filename_minus_ext.'.log');
+// if there was an error then get it
+ echo $toolkit->getLastError()."<br /><br />\r\n";
+ $toolkit->reset();
+ continue;
+ }
+
+// get the process time of the file
+ $process_time = $toolkit->getLastProcessTime();
+ $total_process_time += $process_time;
+
+ $file = array_shift($toolkit->getLastOutput());
+ $filename = basename($file);
+ $filename_hash = md5($filename);
+
+ echo 'Audio extracted in '.$process_time.' seconds...<br />
+<div id="'.$filename_hash.'"></div>
+<script type="text/javascript" charset="utf-8">
+ PluginObject.embed("../working/processed/audio/'.$filename.'", {
+ width : 350,
+ height: 20,
+ player: "../common/mediaplayer/player.swf",
+ force_plugin:PluginObject.Plugins.FlashMedia,
+ auto_adjust_height:false,
+ force_into_id:"'.$filename_hash.'",
+ params: {
+ autoplay: false
+ }
+ });
+</script><br />'."\r\n";
+
+// reset
+ $toolkit->reset();
+ }
+
+ echo "\r\n".'The total time taken to process all '.($key+1).' file(s) is : <b>'.$total_process_time.'</b>';
+ echo '<br />'."\r\n".'The average time taken to process each file is : <b>'.($total_process_time/($key+1)).'</b>';
+ echo '</body></html>'; \ No newline at end of file
diff --git a/libraries/phpvideotoolkit/examples/php5/example07.php b/libraries/phpvideotoolkit/examples/php5/example07.php
new file mode 100644
index 0000000..e015c16
--- /dev/null
+++ b/libraries/phpvideotoolkit/examples/php5/example07.php
@@ -0,0 +1,120 @@
+<?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.
+ */
+
+ echo '<html><head><link type="text/css" rel="stylesheet" href="../common/styles.css"><script type="text/javascript" charset="utf-8" src="../common/pluginobject/pluginobject.js"></script><script>PO.Options.auto_load_prefix="../common/pluginobject/plugins/";</script><meta name="author" content="Oliver Lillie"></head><body>';
+ echo '<a class="backtoexamples" href="../index.php#examples">&larr; Back to examples list</a><br /><br />';
+ echo '<strong>This example shows you how to join multiple videos together.<br />Please note that this example while valid code does not work yet within the PHPVideoToolkit class.</strong><br />';
+ exit;
+
+// load the examples configuration
+ require_once '../example-config.php';
+
+// require the library
+ require_once '../../phpvideotoolkit.'.$use_version.'.php';
+
+// temp directory
+ $tmp_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'tmp'.DS;
+
+// input movie files
+ $files_to_process = array(
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'MOV02820.MPG',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'MOV02832.MPG'// ,
+ // PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'MOV02820.MPG'
+ );
+
+// output files dirname has to exist
+ $video_output_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'processed'.DS.'videos'.DS;
+
+// log dir
+ $log_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'logs'.DS;
+
+// bit rate of audio (valid vaues are 16,32,64)
+ $bitrate = 64;
+
+// sampling rate (valid values are 11025, 22050, 44100)
+ $samprate = 44100;
+
+// start PHPVideoToolkit class
+ $toolkit = new PHPVideoToolkit($tmp_dir);
+
+// set PHPVideoToolkit class to run silently
+ $toolkit->on_error_die = FALSE;
+
+ $input_file = array_pop($files_to_process);
+// get the filename parts
+ $filename = basename($input_file);
+ $filename_minus_ext = substr($filename, 0, strrpos($filename, '.'));
+
+// set the input file
+ $ok = $toolkit->setInputFile($input_file);
+// check the return value in-case of error
+ if(!$ok)
+ {
+// if there was an error then get it
+ echo $toolkit->getLastError()."<br />\r\n";
+ $toolkit->reset();
+ exit;
+ }
+// $toolkit->setFormat(PHPVideoToolkit::FORMAT_MPEGVIDEO);
+ $toolkit->setVideoOutputDimensions(PHPVideoToolkit::SIZE_QVGA);
+
+// loop through the files to process
+ foreach($files_to_process as $file)
+ {
+ $toolkit->addVideo($file);
+ }
+
+// set the output details and overwrite if nessecary
+ $ok = $toolkit->setOutput($video_output_dir, $filename_minus_ext.'-joined.mpeg', PHPVideoToolkit::OVERWRITE_EXISTING);
+// check the return value in-case of error
+ if(!$ok)
+ {
+// if there was an error then get it
+ echo $toolkit->getLastError()."<br />\r\n";
+ $toolkit->reset();
+ exit;
+ }
+
+// execute the ffmpeg command and log the calls and PHPVideoToolkit results
+ $result = $toolkit->execute(false, true);
+
+// get the last command given
+// $command = $toolkit->getLastCommand();
+// echo $command[0]."<br />\r\n";
+// echo $command[1]."<br />\r\n";
+
+// check the return value in-case of error
+ if($result !== PHPVideoToolkit::RESULT_OK)
+ {
+// move the log file to the log directory as something has gone wrong
+ $toolkit->moveLog($log_dir.$filename_minus_ext.'.log');
+// if there was an error then get it
+ echo $toolkit->getLastError()."<br />\r\n";
+ $toolkit->reset();
+ exit;
+ }
+
+ echo 'Videos joined... <b>'.array_shift($toolkit->getLastOutput()).'</b><br />'."\r\n";
+
+// reset
+ $toolkit->reset();
+
+ echo '</body></html>';
diff --git a/libraries/phpvideotoolkit/examples/php5/example08.php b/libraries/phpvideotoolkit/examples/php5/example08.php
new file mode 100644
index 0000000..723b256
--- /dev/null
+++ b/libraries/phpvideotoolkit/examples/php5/example08.php
@@ -0,0 +1,191 @@
+<?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.
+ */
+
+ echo '<html><head><link type="text/css" rel="stylesheet" href="../common/styles.css"><script type="text/javascript" charset="utf-8" src="../common/pluginobject/pluginobject.js"></script><script>PO.Options.auto_load_prefix="../common/pluginobject/plugins/";</script><meta name="author" content="Oliver Lillie"></head><body>';
+ echo '<a class="backtoexamples" href="../index.php#examples">&larr; Back to examples list</a><br /><br />';
+ echo '<strong>This example shows you how to convert videos to common formats simply by using the simple adapters.</strong><br />';
+ echo '<span class="small">&bull; The flash media player used below is Jeroen Wijering\'s excellent <a href="http://www.jeroenwijering.com/?item=JW_FLV_Media_Player">Flash Media Player</a>. Although bundled with this package the Flash Media Player has a <a href="http://creativecommons.org/licenses/by-nc-sa/2.0/">Creative Commons Attribution-Noncommercial-Share Alike 2.0 Generic</a> license.</span><br />';
+ echo '<span class="small">&bull; The media is embedded using <a href="http://sourceforge.net/projects/pluginobject/">PluginObject</a> to embed the examples. It is distributed under a BSD License.</span><br /><br />';
+
+// load the examples configuration
+ require_once '../example-config.php';
+
+// require the library
+ require_once '../../phpvideotoolkit.'.$use_version.'.php';
+ require_once '../../adapters/videoto.php';
+
+// temp directory
+ $tmp_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'tmp'.DS;
+
+// processed file output directory
+ $output_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'processed'.DS.'videos'.DS;
+
+// input movie files
+ $files_to_process = array(
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'MOV00007.3gp',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'Video000.3gp',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'cat.mpeg'
+ );
+
+// loop through the files to process
+ foreach($files_to_process as $file)
+ {
+ echo '<strong>Processing '.basename($file).'</strong><br />';
+
+ $info = PHPVideoToolkit::getFileInfo($file);
+
+// convert the video to a gif format
+ $result = VideoTo::gif($file, array(
+ 'width' => $info['video']['dimensions']['width'],
+ 'height' => $info['video']['dimensions']['height'],
+ 'temp_dir' => $tmp_dir,
+ 'output_dir' => $output_dir,
+ 'output_file' => '#filename-gif.#ext',
+ 'die_on_error' => false,
+ 'overwrite_mode' => PHPVideoToolkit::OVERWRITE_EXISTING
+ ));
+// check for an error
+ if($result !== PHPVideoToolkit::RESULT_OK)
+ {
+ echo VideoTo::getError().'<br />'."\r\n";
+ echo 'Please check the log file generated as additional debug info may be contained.<br />'."\r\n";
+ }
+ else
+ {
+ $output = VideoTo::getOutput();
+ echo 'Coverted to Gif...<br /><img src="../working/processed/videos/'.basename($output[0]).'" width="'.$info['video']['dimensions']['width'].'" height="'.$info['video']['dimensions']['height'].'" /><br /><br />'."\r\n";
+ }
+
+// convert the video to a psp mp4
+ $result = VideoTo::PSP($file, array(
+ 'width' => $info['video']['dimensions']['width'],
+ 'height' => $info['video']['dimensions']['height'],
+ 'temp_dir' => $tmp_dir,
+ 'output_dir' => $output_dir,
+ 'output_file' => '#filename-psp.#ext',
+ 'die_on_error' => false,
+ 'overwrite_mode' => PHPVideoToolkit::OVERWRITE_EXISTING
+ ));
+// check for an error
+ if($result !== PHPVideoToolkit::RESULT_OK)
+ {
+ echo VideoTo::getError().'<br />'."\r\n";
+ echo 'Please check the log file generated as additional debug info may be contained.<br />'."\r\n";
+ }
+ else
+ {
+ $output = VideoTo::getOutput();
+ $filename = basename($output[0]);
+ $filename_hash = md5($filename);
+ echo 'Coverted to PSP mp4...<br />
+<div id="'.$filename_hash.'"></div>
+<script type="text/javascript" charset="utf-8">
+ PluginObject.embed("../working/processed/videos/'.$filename.'", {
+ no_cache : true,
+ width : '.$info['video']['dimensions']['width'].',
+ height: '.$info['video']['dimensions']['height'].',
+ force_plugin:PluginObject.Plugins.Quicktime,
+ force_into_id:"'.$filename_hash.'",
+ params: {
+ autoplay: false
+ }
+ });
+</script><br />'."\r\n";
+ }
+
+// convert the video to flv
+ $result = VideoTo::FLV($file, array(
+ 'width' => $info['video']['dimensions']['width'],
+ 'height' => $info['video']['dimensions']['height'],
+ 'temp_dir' => $tmp_dir,
+ 'output_dir' => $output_dir,
+ 'die_on_error' => false,
+ 'overwrite_mode' => PHPVideoToolkit::OVERWRITE_EXISTING
+ ));
+// check for an error
+ if($result !== PHPVideoToolkit::RESULT_OK)
+ {
+ echo VideoTo::getError().'<br />'."\r\n";
+ echo 'Please check the log file generated as additional debug info may be contained.<br />'."\r\n";
+ }
+ else
+ {
+ $output = VideoTo::getOutput();
+ $filename = basename($output[0]);
+ $filename_hash = md5($filename);
+ echo 'Coverted to Flash Video (flv)...<br />
+<div id="'.$filename_hash.'"></div>
+<script type="text/javascript" charset="utf-8">
+ PluginObject.embed("../working/processed/videos/'.$filename.'", {
+ no_cache : true,
+ width : '.$info['video']['dimensions']['width'].',
+ height: '.$info['video']['dimensions']['height'].',
+ force_plugin:PluginObject.Plugins.FlashMedia,
+ player: "../common/mediaplayer/player.swf",
+ force_into_id:"'.$filename_hash.'",
+ overstretch:true,
+ params: {
+ autoplay: false
+ }
+ });
+</script><br />'."\r\n";
+ }
+
+// convert the video to an ipod mp4
+ $result = VideoTo::iPod($file, array(
+ 'width' => $info['video']['dimensions']['width'],
+ 'height' => $info['video']['dimensions']['height'],
+ 'temp_dir' => $tmp_dir,
+ 'output_dir' => $output_dir,
+ 'die_on_error' => false,
+ 'output_file' => '#filename-ipod.#ext',
+ 'overwrite_mode' => PHPVideoToolkit::OVERWRITE_EXISTING
+ ));
+// check for an error
+ if($result !== PHPVideoToolkit::RESULT_OK)
+ {
+ echo VideoTo::getError().'<br />'."\r\n";
+ echo 'Please check the log file generated as additional debug info may be contained.<br /><br />'."\r\n";
+ }
+ else
+ {
+ $output = VideoTo::getOutput();
+ $filename = basename($output[0]);
+ $filename_hash = md5($filename);
+ echo 'Coverted to iPod mp4...<br />
+<div id="'.$filename_hash.'"></div>
+<script type="text/javascript" charset="utf-8">
+ PluginObject.embed("../working/processed/videos/'.$filename.'", {
+ no_cache : true,
+ width : '.$info['video']['dimensions']['width'].',
+ height: '.$info['video']['dimensions']['height'].',
+ force_plugin:PluginObject.Plugins.Quicktime,
+ force_into_id:"'.$filename_hash.'",
+ params: {
+ autoplay: false
+ }
+ });
+</script><br />'."\r\n";
+ }
+
+ }
+
+ echo '</body></html>'; \ No newline at end of file
diff --git a/libraries/phpvideotoolkit/examples/php5/example09.php b/libraries/phpvideotoolkit/examples/php5/example09.php
new file mode 100644
index 0000000..b1b77b0
--- /dev/null
+++ b/libraries/phpvideotoolkit/examples/php5/example09.php
@@ -0,0 +1,92 @@
+<?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.
+ */
+
+ echo '<html><head><link type="text/css" rel="stylesheet" href="../common/styles.css"><meta name="author" content="Oliver Lillie"></head><body>';
+ echo '<a class="backtoexamples" href="../index.php#examples">&larr; Back to examples list</a><br /><br />';
+ echo '<strong>This example shows you how to access the information about your ffmpeg installation.</strong><br />';
+ echo '<span class="small">Note: This compiles the data gathered from your ffmpeg install into the specified temp directory so it does not need to be read and processed on each subsequent request.</span><br /><br />';
+
+ $ignore_demo_files = true;
+
+// load the examples configuration
+ require_once '../example-config.php';
+
+// require the library
+ require_once '../../phpvideotoolkit.'.$use_version.'.php';
+
+// temp directory
+ $tmp_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'tmp'.DS;
+
+// start ffmpeg class
+ $toolkit = new PHPVideoToolkit($tmp_dir);
+
+// get the ffmpeg info, whilst using the cache. Set true to false to disable the cache read.
+ $info = $toolkit->getFFmpegInfo(true);
+
+// determine the type of support for ffmpeg-php
+ echo '<strong>FFMpeg Info</strong><br />';
+ if($info['reading_from_cache'] === true)
+ {
+ echo 'This data is read from cache. It will expire on '.(date('d.m.Y H:i:s', $info['_cache_date']+2678400)).'.';
+ }
+ else
+ {
+ echo 'This data is uncached.';
+ }
+
+// determine the type of support for ffmpeg-php
+ echo '<br /><br /><strong>FFmpeg-PHP Support</strong><br />';
+
+// determine if ffmpeg-php is supported
+ $has_ffmpeg_php_support = $toolkit->hasFFmpegPHPSupport();
+// you can also determine if it has ffmpeg php support with below
+// $has_ffmpeg_php_support = $info['ffmpeg-php-support'];
+
+ switch($has_ffmpeg_php_support)
+ {
+ case 'module' :
+ echo 'Congratulations you have the FFmpeg-PHP module installed.';
+ break;
+
+ case 'emulated' :
+ echo 'You haven\'t got the FFmpeg-PHP module installed, however you can use the PHPVideoToolkit\'s adapter\'s to emulate FFmpeg-PHP.<br />In order to make use of the FFmpeg-PHP adapter class all you need to do is add the following, replacing xxxx with the path to the files, then use FFmpeg-PHP as normal.
+<br /><pre>if(!class_exists(\'ffmpeg_movie\'))
+{
+ require_once \'xxxx/adapters/ffmpeg-php/ffmpeg_movie.php\';
+ require_once \'xxxx/adapters/ffmpeg-php/ffmpeg_frame.php\';
+ require_once \'xxxx/adapters/ffmpeg-php/ffmpeg_animated_gif.php\';
+}</pre><strong>Note:</strong> It is recommended that if you heavily use FFmpeg-PHP that you install the module.
+';
+ break;
+ case false :
+ echo 'You have no support at all for FFmpeg-PHP.';
+ break;
+ }
+
+// output data
+ echo '<br /><br /><strong>This is the information that is accessible about your install of FFmpeg.</strong><br />';
+ echo '<span class="small">You may also wish to see <a href="example14.php">example 14</a> which gives you an encode/decode lookup table.</span>';
+ echo '<pre>';
+ unset($info['raw']);
+ print_r($info);
+ echo '</pre>';
+ echo '</body></html>';
+ \ No newline at end of file
diff --git a/libraries/phpvideotoolkit/examples/php5/example10.php b/libraries/phpvideotoolkit/examples/php5/example10.php
new file mode 100644
index 0000000..0d21731
--- /dev/null
+++ b/libraries/phpvideotoolkit/examples/php5/example10.php
@@ -0,0 +1,128 @@
+<?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.
+ */
+
+ echo '<html><head><link type="text/css" rel="stylesheet" href="../common/styles.css"><meta name="author" content="Oliver Lillie"></head><body>';
+ echo '<a class="backtoexamples" href="../index.php#examples">&larr; Back to examples list</a><br /><br />';
+ echo '<strong>This example shows you how to extract a specific frame from a movie</strong>.<br />';
+
+// load the examples configuration
+ require_once '../example-config.php';
+
+// require the library
+ require_once '../../phpvideotoolkit.'.$use_version.'.php';
+
+// please replace xxxxx with the full absolute path to the files and folders
+// also please make the $thumbnail_output_dir read and writeable by the webserver
+
+// temp directory
+ $tmp_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'tmp'.DS;
+
+// input movie files
+ $files_to_process = array(
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'MOV00007.3gp',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'Video000.3gp',
+ PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'cat.mpeg'
+ );
+
+// output files dirname has to exist
+ $thumbnail_output_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'processed'.DS.'thumbnails'.DS;
+
+// log dir
+ $log_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'logs'.DS;
+
+// start phpvideotoolkit class
+ $toolkit = new PHPVideoToolkit('c:/ffmpeg/ffmpeg.exe',$tmp_dir);
+
+// set phpvideotoolkit class to run silently
+ $toolkit->on_error_die = FALSE;
+
+// start the timer collection
+ $total_process_time = 0;
+
+// loop through the files to process
+ foreach($files_to_process as $key=>$file)
+ {
+// get the filename parts
+ $filename = basename($file);
+ $filename_minus_ext = substr($filename, 0, strrpos($filename, '.'));
+
+// set the input file
+ $ok = $toolkit->setInputFile($file);
+// check the return value in-case of error
+ if(!$ok)
+ {
+// if there was an error then get it
+ echo '<b>'.$toolkit->getLastError()."</b><br />\r\n";
+ $toolkit->reset();
+ continue;
+ }
+
+// set the output dimensions
+ $toolkit->setVideoOutputDimensions(PHPVideoToolkit::SIZE_SQCIF);
+
+// extract a thumbnail from the fifth frame two seconds into the video
+ $toolkit->extractFrame('00:00:02.5');
+
+// set the output details
+ $ok = $toolkit->setOutput($thumbnail_output_dir, $filename_minus_ext.'.jpg', PHPVideoToolkit::OVERWRITE_EXISTING);
+// check the return value in-case of error
+ if(!$ok)
+ {
+// if there was an error then get it
+ echo '<b>'.$toolkit->getLastError()."</b><br />\r\n";
+ $toolkit->reset();
+ continue;
+ }
+
+// execute the ffmpeg command
+ $result = $toolkit->execute(false, true);
+
+// get the last command given
+// $command = $toolkit->getLastCommand();
+// echo $command."<br />\r\n";
+// check the return value in-case of error
+ if($result !== PHPVideoToolkit::RESULT_OK)
+ {
+// move the log file to the log directory as something has gone wrong
+ $toolkit->moveLog($log_dir.$filename_minus_ext.'.log');
+// if there was an error then get it
+ echo '<b>'.$toolkit->getLastError()."</b><br />\r\n";
+ $toolkit->reset();
+ continue;
+ }
+
+// get the process time of the file
+ $process_time = $toolkit->getLastProcessTime();
+ $total_process_time += $process_time;
+
+ $file = array_shift($toolkit->getLastOutput());
+
+ echo 'Frame grabbed in '.$process_time.' seconds... <b>'.$thumbnail_output_dir.$file.'</b><br />'."\r\n";
+ echo '<img src="../working/processed/thumbnails/'.$file.'" alt="" border="0" /><br /><br />';
+
+// reset
+ $toolkit->reset();
+
+ }
+
+ echo '<br />'."\r\n".'The total time taken to process all '.($key+1).' file(s) is : <b>'.$total_process_time.'</b>';
+ echo '<br />'."\r\n".'The average time taken to process each file is : <b>'.($total_process_time/($key+1)).'</b><br /><br />';
+ echo '</body></html>';
diff --git a/libraries/phpvideotoolkit/examples/php5/example11.php b/libraries/phpvideotoolkit/examples/php5/example11.php
new file mode 100644
index 0000000..f453829
--- /dev/null
+++ b/libraries/phpvideotoolkit/examples/php5/example11.php
@@ -0,0 +1,162 @@
+<?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.
+ */
+
+ echo '<html><head><link type="text/css" rel="stylesheet" href="../common/styles.css"><meta name="author" content="Oliver Lillie"></head><body>';
+ echo '<a class="backtoexamples" href="../index.php#examples">&larr; Back to examples list</a><br /><br />';
+ echo '<strong>This example shows you how to use the ffmpeg-php adaptor scripts. <br />NOTE: Please note whenever possible you should use ffmpeg-php as it is much more efficient than this pure PHP emulation.</strong><br />';
+
+// load the examples configuration
+ require_once '../example-config.php';
+
+ echo '<strong>NOTE; The FFmpeg-PHP adapter makes use of <a href="http://code.google.com/p/php-reader/">PHP-Reader</a> and <a href="http://www.phpclasses.org/browse/package/3163.html" target="_blank">GifEncoder</a>, which for convenience have both been bundled with PHPVideoToolkit. PHP-Reader v1.5 has been distributed along with this package. It is subject to the New BSD license. Previously getID3 was used, however the getID3 license was incompatible with the PHP Video Toolkit BSD license. The FFmpeg-PHP adapter classes can now be distributed in commercial applications (as of 24.09.2008).</strong><br /><br />';
+
+ require_once '../../phpvideotoolkit.'.$use_version.'.php';
+
+// get the ffmpeg adaptors
+ if(!class_exists('ffmpeg_movie'))
+ {
+ require_once '../../adapters/ffmpeg-php/ffmpeg_movie.php';
+ require_once '../../adapters/ffmpeg-php/ffmpeg_frame.php';
+ require_once '../../adapters/ffmpeg-php/ffmpeg_animated_gif.php';
+ }
+ else
+ {
+ echo '<strong>You currently have ffmpeg-php installed on your server, and the module is loaded, therefore this example will not use the PHPVideoToolkit ffmpeg-php adapter. It will use the actual ffmpeg-php module.</strong><br /><br />';
+ }
+
+// temp directory
+ $tmp_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'tmp'.DS;
+
+// the frame number to retrieve
+ $frame_number = 15;
+
+// input movie files
+// $file = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'mp3.mp3';
+ $file = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'MOV00007.3gp';
+ $file_info = pathinfo($file);
+
+// output files dirname has to exist
+ $thumbnail_output_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'processed'.DS.'thumbnails'.DS;
+
+// load the movie
+ $ffmpeg_movie = new ffmpeg_movie($file, false, $tmp_dir);
+// get the 20th frame from the movie
+ $frame = $ffmpeg_movie->getFrame($frame_number);
+// check the frame has been returned
+ if($frame === false)
+ {
+ echo 'The frame, '.$frame_number.' does not exist.';
+ }
+ else
+ {
+
+// create the same size thumbnail
+ $gd_resource = $frame->toGDImage();
+ $orig_width = $frame->getWidth();
+ $orig_height = $frame->getHeight();
+
+ imagejpeg($gd_resource, PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'processed'.DS.'thumbnails'.DS.$file_info['filename'].'-samesize.jpg', 80);
+
+ echo '<strong>Plain Frame Grab of Movie</strong>.<br />';
+ echo 'This is a frame grab at the same resolution as the video.<br />';
+ echo '<img src="../working/processed/thumbnails/'.$file_info['filename'].'-samesize.jpg" alt="" width="'.$frame->getWidth().'" height="'.$frame->getHeight().'" border="0" /><br /><br />';
+
+// crop the thumbnail
+ $frame->crop(20, 20, 20, 20);
+ $gd_resource = $frame->toGDImage();
+ imagejpeg($gd_resource, PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'processed'.DS.'thumbnails'.DS.$file_info['filename'].'-cropped.jpg', 80);
+
+ echo '<strong>Cropped Frame Grab of Movie</strong>.<br />';
+ echo 'This is a frame grab that has been cropped.<br />';
+ echo '<img src="../working/processed/thumbnails/'.$file_info['filename'].'-cropped.jpg" alt="" width="'.$frame->getWidth().'" height="'.$frame->getHeight().'" border="0" /><br /><br />';
+
+// resize the thumbnail
+ $frame->resize(50, 50);
+ $gd_resource = $frame->toGDImage();
+ imagejpeg($gd_resource, PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'processed'.DS.'thumbnails'.DS.$file_info['filename'].'-resized.jpg', 80);
+ $small_width = $frame->getWidth();
+ $small_height = $frame->getHeight();
+
+ echo '<strong>Cropped and Resized Frame Grab of Movie</strong>.<br />';
+ echo 'This is a frame grab that has been cropped then resized.<br />';
+ echo '<img src="../working/processed/thumbnails/'.$file_info['filename'].'-resized.jpg" alt="" width="'.$small_width.'" height="'.$small_height.'" border="0" /><br /><br />';
+
+// create 2 animated gifs, one normal size, one small
+// create the normal one
+ $ffmpeg_gif = new ffmpeg_animated_gif(PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'processed'.DS.'thumbnails'.DS.$file_info['filename'].'-animated.gif', $orig_width, $orig_height, 5, 0);
+// create the small one
+ $ffmpeg_gif_small = new ffmpeg_animated_gif(PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'processed'.DS.'thumbnails'.DS.$file_info['filename'].'-animated-small.gif', $small_width, $small_height, 5, 0);
+ for ($i = 1, $a = $ffmpeg_movie->getFrameCount(), $inc = $ffmpeg_movie->getFrameRate()/2; $i < $a; $i += $inc)
+ {
+// get the required frame
+ $ffmpeg_frame = $ffmpeg_movie->getFrame($i);
+ if($ffmpeg_frame !== false)
+ {
+// add the frame to the gif
+ $result = $ffmpeg_gif->addFrame($ffmpeg_frame);
+ if(!$result)
+ {
+ 'There was an error adding frame '.$i.' to the gif.<br />';
+ }
+ }
+// get the required frame
+ $ffmpeg_frame_small = $ffmpeg_movie->getFrame($i);
+ if($ffmpeg_frame_small !== false)
+ {
+// crop and resize the frame
+ $ffmpeg_frame_small->resize(50, 50, 20, 20, 20, 20);
+// then add it to the small one
+ $result = $ffmpeg_gif_small->addFrame($ffmpeg_frame_small);
+ if(!$result)
+ {
+ 'There was an error adding frame '.$i.' to the gif.<br />';
+ }
+ }
+ }
+ echo '<strong>Animated Gif of Movie</strong>.<br />';
+ $result = $ffmpeg_gif->saveNow($tmp_dir);
+ if(!$result)
+ {
+ echo 'It was not possible to save the animated gif for some reason.<br />';
+ }
+ else
+ {
+ echo 'This is an animated gif extracted from the movie.<br />';
+ echo '<img src="../working/processed/thumbnails/'.$file_info['filename'].'-animated.gif" alt="" width="'.$orig_width.'" height="'.$orig_height.'" border="0" /><br /><br />';
+ }
+
+ echo '<strong>Cropped and Resized Animated Gif of Movie</strong>.<br />';
+ $result = $ffmpeg_gif_small->saveNow($tmp_dir);
+ if(!$result)
+ {
+ echo 'It was not possible to save the animated gif for some reason.<br />';
+ }
+ else
+ {
+ echo 'This is an animated gif extracted from the movie but <i>cropped and then resized</i>.<br />';
+ echo '<img src="../working/processed/thumbnails/'.$file_info['filename'].'-animated-small.gif" alt="" width="'.$small_width.'" height="'.$small_height.'" border="0" /><br /><br />';
+ }
+ }
+
+ echo '</body></html>';
+
+
+
diff --git a/libraries/phpvideotoolkit/examples/php5/example12.php b/libraries/phpvideotoolkit/examples/php5/example12.php
new file mode 100644
index 0000000..8ada5fe
--- /dev/null
+++ b/libraries/phpvideotoolkit/examples/php5/example12.php
@@ -0,0 +1,236 @@
+<?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.
+ */
+
+ echo '<html><head><link type="text/css" rel="stylesheet" href="../common/styles.css"><meta name="author" content="Oliver Lillie"></head><body>';
+ echo '<a class="backtoexamples" href="../index.php#examples">&larr; Back to examples list</a><br /><br />';
+ echo '<strong>This example shows you how to manipulate/format timecode strings.</strong><br /><br />';
+ $ignore_demo_files = true;
+
+// load the examples configuration
+ require_once '../example-config.php';
+
+// require the library
+ require_once '../../phpvideotoolkit.'.$use_version.'.php';
+
+// temp directory
+ $tmp_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'tmp'.DS;
+
+
+// set the time to examine / format
+ if(isset($_POST['hours']))
+ {
+// capture timecode and framerate
+ $timecode = str_pad(intval($_POST['hours']), 2, '0', STR_PAD_LEFT).':'.str_pad(intval($_POST['mins']), 2, '0', STR_PAD_LEFT).':'.str_pad(intval($_POST['secs']), 2, '0', STR_PAD_LEFT).'.'.str_pad(intval($_POST['millisecs']), 2, '0', STR_PAD_LEFT);
+ $frame_rate = intval($_POST['framerate']);
+ }
+ else
+ {
+// set the frame rate for the timecodes and default time
+ $timecode = '01:14:32.59';
+ $frame_rate = 25;
+ }
+ $timecode_format = '%hh:%mm:%ss.%ms';
+
+// * default '%hh:%mm:%ss'
+// * - %hh (hours) representative of hours
+// * - %mm (minutes) representative of minutes
+// * - %ss (seconds) representative of seconds
+// * - %fn (frame number) representative of frames (of the current second, not total frames)
+// * - %ms (milliseconds) representative of milliseconds (of the current second, not total milliseconds) (rounded to 3 decimal places)
+// * - %ft (frames total) representative of total frames (ie frame number)
+// * - %st (seconds total) representative of total seconds (rounded).
+// * - %sf (seconds floored) representative of total seconds (floored).
+// * - %sc (seconds ceiled) representative of total seconds (ceiled).
+// * - %mt (milliseconds total) representative of total milliseconds. (rounded to 3 decimal places)
+
+
+// start ffmpeg class
+ $toolkit = new PHPVideoToolkit($tmp_dir);
+
+ echo '<strong>Timecode Format Placeholders</strong><br />';
+ echo 'When you format a timecode or format a number of seconds into a timecode you can use the following placeholders to contain different time and frame values<br /><br />';
+ echo '<table border="0" cellspacing="0" cellpadding="2">
+ <tr>
+ <td style="width:50px;border-bottom:1px solid #ccc;">
+ <strong>%hh</strong>
+ </td>
+ <td style="border-bottom:1px solid #ccc;">
+ hours
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <strong>%mm</strong>
+ </td>
+ <td>
+ minutes
+ </td>
+ </tr>
+ <tr>
+ <td style="border-bottom:1px solid #ccc;">
+ &nbsp;
+ </td>
+ <td class="light small" style="border-bottom:1px solid #ccc;">
+ NOTE: Smart Value Warning. By default if %hh (hours) aren\'t used in the format then this will give the total number of minutes.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <strong>%ss</strong>
+ </td>
+ <td>
+ seconds
+ </td>
+ </tr>
+ <tr>
+ <td style="border-bottom:1px solid #ccc;">
+ &nbsp;
+ </td>
+ <td class="light small" style="border-bottom:1px solid #ccc;">
+ NOTE: Smart Value Warning. By default if %hh (hours) or %mm (mins) aren\'t used in the format then this will give the total number of seconds.
+ </td>
+ </tr>
+ <tr>
+ <td style="border-bottom:1px solid #ccc;">
+ <strong>%fn</strong>
+ </td>
+ <td style="border-bottom:1px solid #ccc;">
+ frame number
+ </td>
+ </tr>
+ <tr>
+ <td style="border-bottom:1px solid #ccc;">
+ <strong>%ms</strong>
+ </td>
+ <td style="border-bottom:1px solid #ccc;">
+ milliseconds
+ </td>
+ </tr>
+ <tr>
+ <td style="border-bottom:1px solid #ccc;">
+ <strong>%ft</strong>
+ </td>
+ <td style="border-bottom:1px solid #ccc;">
+ frames total
+ </td>
+ </tr>
+ <tr>
+ <td style="border-bottom:1px solid #ccc;">
+ <strong>%st</strong>
+ </td>
+ <td style="border-bottom:1px solid #ccc;">
+ seconds total
+ </td>
+ </tr>
+ <tr>
+ <td style="border-bottom:1px solid #ccc;">
+ <strong>%sf</strong>
+ </td>
+ <td style="border-bottom:1px solid #ccc;">
+ seconds floored
+ </td>
+ </tr>
+ <tr>
+ <td style="border-bottom:1px solid #ccc;">
+ <strong>%sc</strong>
+ </td>
+ <td style="border-bottom:1px solid #ccc;">
+ seconds ceiled
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <strong>%mt</strong>
+ </td>
+ <td>
+ milliseconds total
+ </td>
+ </tr>
+ </table>';
+ echo '<br />';
+ echo 'With regards to the Smart Value Warnings, you can turn off smart values by setting the $use_smart_values argument to false when formatting a timecode.<br /><br />';
+
+ echo '<strong>Original Timecode</strong><br />';
+ echo $timecode.'<br /><br />';
+
+ echo '<strong>Timecode conversion to seconds</strong><br />';
+ echo 'Frame seconds (rounded) -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%st', $frame_rate).'<br />';
+ echo 'Frame seconds (rounded down) -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%sf', $frame_rate).'<br />';
+ echo 'Frame seconds (rounded up) -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%sc', $frame_rate).'<br />';
+ echo 'Frame seconds -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%mt', $frame_rate).'<br /><br />';
+
+ echo '<strong>Timecode conversion to frames</strong><br />';
+ echo 'Frame number (in current second) -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%fn', $frame_rate).'<br />';
+ echo 'Frame number (in video) -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%ft', $frame_rate).'<br /><br />';
+
+ echo '<strong>Timecode conversion to other timecodes</strong><br />';
+ echo 'hh:mm -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%hh:%mm', $frame_rate).'<br />';
+ echo 'hh:mm:ss -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%hh:%mm:%ss', $frame_rate).'<br />';
+ echo 'hh:mm:ss.fn -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%hh:%mm:%ss.%fn', $frame_rate).'<br />';
+ echo 'hh:mm:ss.ms -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%hh:%mm:%ss.%ms', $frame_rate).'<br />';
+ echo 'mm:ss (smart minutes) -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%mm:%ss', $frame_rate).'<br />';
+ echo 'mm:ss.fn (smart minutes) -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%mm:%ss.%fn', $frame_rate).'<br />';
+ echo 'ss.ms (smart seconds) -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%ss.%ms', $frame_rate).'<br /><br />';
+
+ // output the timecode form, remembering to disable smart values
+ $use_smart_values = false;
+ echo '<strong>Change Timecode</strong><br />';
+ echo '<form action="example12.php" method="post"><table border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td class="small" style="padding-left:4px;">
+ Hours
+ </td>
+ <td class="small" style="padding-left:4px;">
+ Mins
+ </td>
+ <td class="small" style="padding-left:4px;">
+ Secs
+ </td>
+ <td class="small" style="padding-left:4px;">
+ Milli
+ </td>
+ <td class="small" style="padding-left:4px;" colspan="2">
+ Frame Rate
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <input type="text" name="hours" value="'.$toolkit->formatTimecode($timecode, $timecode_format, '%hh', $frame_rate, $use_smart_values).'" id="hours" style="width:35px;margin-right:3px;" />:
+ </td>
+ <td>
+ <input type="text" name="mins" value="'.$toolkit->formatTimecode($timecode, $timecode_format, '%mm', $frame_rate, $use_smart_values).'" id="mins" style="width:35px;margin:0 3px 0 3px;" />:
+ </td>
+ <td>
+ <input type="text" name="secs" value="'.$toolkit->formatTimecode($timecode, $timecode_format, '%ss', $frame_rate, $use_smart_values).'" id="secs" style="width:35px;margin:0 3px 0 3px;" />:
+ </td>
+ <td>
+ <input type="text" name="millisecs" value="'.$toolkit->formatTimecode($timecode, $timecode_format, '%ms', $frame_rate, $use_smart_values).'" id="millisecs" style="width:35px;margin:0 3px 0 3px;" />/
+ </td>
+ <td>
+ <input type="text" name="framerate" value="'.$frame_rate.'" id="framerate" style="width:35px;margin:0 3px 0 3px;" />
+ </td>
+ <td>
+ <input type="submit" value="Update" style="margin:0 0 0 10px;" />
+ </td>
+ </tr>
+</table></form><br />';
+
+ echo '</body></html>';
diff --git a/libraries/phpvideotoolkit/examples/php5/example13.php b/libraries/phpvideotoolkit/examples/php5/example13.php
new file mode 100644
index 0000000..8263c89
--- /dev/null
+++ b/libraries/phpvideotoolkit/examples/php5/example13.php
@@ -0,0 +1,111 @@
+<?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.
+ * @see JEROEN WIJERING Flash Media Player,
+ * - @link http://www.jeroenwijering.com/?item=JW_FLV_Media_Player
+ * - @author Jeroen Wijering.
+ */
+
+// set the packet details as we are restricting the bandwidth
+// the default details set here mean 5kb per second, ie dialup speed.
+ $packet_size = isset($_GET['packet_size']) ? intval($_GET['packet_size']) : (isset($_COOKIE['packet_size']) ? intval($_COOKIE['packet_size']) : 5);
+ $packet_interval = 1;
+ setcookie('packet_size', $packet_size, time()+7200, '/');
+
+ if(!isset($_GET['file']))
+ {
+ echo '<html><head><link type="text/css" rel="stylesheet" href="../common/styles.css"><script type="text/javascript" charset="utf-8" src="../common/pluginobject/pluginobject.js"></script><script>PO.Options.auto_load_prefix="../common/pluginobject/plugins/";</script><meta name="author" content="Oliver Lillie"></head><body>';
+ echo '<a class="backtoexamples" href="../index.php#examples">&larr; Back to examples list</a><br /><br />';
+ echo '<strong>This example shows how to simply create an FLV stream script.</strong><br />';
+ echo '<span class="small">&bull; The flash media player used below is Jeroen Wijering\'s excellent <a href="http://www.jeroenwijering.com/?item=JW_FLV_Media_Player">Flash Media Player</a>. Although bundled with this package the Flash Media Player has a <a href="http://creativecommons.org/licenses/by-nc-sa/2.0/">Creative Commons Attribution-Noncommercial-Share Alike 2.0 Generic</a> license.</span><br />';
+ echo '<span class="small">&bull; The media is embedded using <a href="http://sourceforge.net/projects/pluginobject/">PluginObject</a> to embed the examples. It is distributed under a BSD License.</span><br /><br />';
+ }
+
+// load the examples configuration
+ $ignore_config_output = true;
+ require_once '../example-config.php';
+
+// set the flv file
+ $flv = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'rickroll.flv';
+
+// require the library
+ require_once '../../phpvideotoolkit.'.$use_version.'.php';
+// temp directory
+ $tmp_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'tmp'.DS;
+// start ffmpeg class
+ $toolkit = new PHPVideoToolkit($tmp_dir);
+
+ if(isset($_GET['file']))
+ {
+// set the flv input
+ $toolkit->setInputFile($flv);
+// get the incoming stream position
+ $stream_pos = isset($_GET['pos']) ? $_GET['pos'] : 0;
+// in this example we will enable bandwidth limiting at the extreme and is not really practicle for live purposes
+// it will only release 100 bytes of the file every second, thus it should take roughly 5 minutes to release a 29Mb file
+// it will also prevent the browser cache from retaining the file.
+ $toolkit->flvStreamSeek($stream_pos, array('active'=>true, 'packet_size'=>$packet_size, 'packet_interval'=>$packet_interval), false);
+ exit;
+//<- exits
+ }
+
+ $size = filesize($flv);
+ echo '<strong>Bandwidth Restrictions and Download Rate.</strong><br />';
+ echo 'The flv media is '.$size.' bytes, using the bandwidth speed limit of '.$packet_size.' kb/s media should be completely loaded in roughly '.$toolkit->formatSeconds(round($size/($packet_interval*1024*$packet_size*2), 1), '%hh hours, %mm minutes, %ss.%ms seconds').'.<br />';
+ echo 'This may not appear to be the case in the player as the player will buffer the contents, You should notice that after a while the player will re-buffer the file. This is because the file was not loaded directly but through this script which buffered the release of the flv.<br />';
+ echo 'However you can test this better by downloading <a href="example13.php?file=../working/to-be-processed/rickroll.flv&pos=0&packet_size='.$packet_size.'">this link</a>.<br />';
+ echo 'You should notice that the file is downloading as a normal file off the internet, however the flv will download at a extremely slowed rate (more like dial-up speed than broadband or DSL) even if you are testing this script on your localhost.<br />';
+ echo '<br />';
+ echo '<strong>Change the example bandwidth restriction.</strong><br />';
+ echo '<select onchange="document.location.href=\''.$_SERVER['PHP_SELF'].'?packet_size=\'+this.value">
+<option label="5 kb/s (Dialup)" value="5"'.($packet_size == '5' ? ' selected' : '').'>5 kb/s (Dialup)</option>
+<option label="10 kb/s" value="10"'.($packet_size == '10' ? ' selected' : '').'>10 kb/s</option>
+<option label="20 kb/s" value="20"'.($packet_size == '20' ? ' selected' : '').'>20 kb/s</option>
+<option label="40 kb/s" value="40"'.($packet_size == '40' ? ' selected' : '').'>40 kb/s</option>
+<option label="80 kb/s" value="80"'.($packet_size == '80' ? ' selected' : '').'>80 kb/s</option>
+<option label="160 kb/s" value="160"'.($packet_size == '160' ? ' selected' : '').'>160 kb/s</option>
+</select><br />
+<br />
+<div id="embed-div"></div>
+<script type="text/javascript" charset="utf-8">
+PluginObject.embed("../../working/to-be-processed/rickroll.flv", {
+ width : 400,
+ height: 320,
+ force_plugin:PluginObject.Plugins.FlashMedia,
+ player: "../common/mediaplayer/player.swf",
+ force_into_id:"embed-div",
+ auto_fix_path:false,
+ variables: {
+ bufferlength : 3,
+ streamer: "../../php5/example13.php",
+ autostart: true
+ }
+});
+</script><br />
+</body></html>';
+
+
+
+// echo '<embed
+// src="mediaplayer/mediaplayer.swf"
+// width="400"
+// height="320"
+// allowfullscreen="true"
+// flashvars="width=400&height=320&autostart=true&file=example13.php?file=to-be-processed/rickroll.flv&searchbar=false&streamscript=../example13.php"
+// />';
diff --git a/libraries/phpvideotoolkit/examples/php5/example14.php b/libraries/phpvideotoolkit/examples/php5/example14.php
new file mode 100644
index 0000000..a9b8768
--- /dev/null
+++ b/libraries/phpvideotoolkit/examples/php5/example14.php
@@ -0,0 +1,183 @@
+<?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.
+ */
+
+ echo '<html><head><link type="text/css" rel="stylesheet" href="../common/styles.css"><meta name="author" content="Oliver Lillie"></head><body>';
+ echo '<a class="backtoexamples" href="../index.php#examples">&larr; Back to examples list</a><br /><br />';
+ echo '<strong>This example gives you an encode/decode lookup table so you can see which formats can be encoded and/or decoded with your version of FFmpeg, whilst showing you how to easily check for different codecs..</strong><br /><br />';
+ $ignore_demo_files = true;
+
+// load the examples configuration
+ require_once '../example-config.php';
+
+// require the library
+ require_once '../../phpvideotoolkit.'.$use_version.'.php';
+
+// get the ffmpeg info
+ $formats = PHPVideoToolkit::getAvailableFormats();
+ $audio_codecs = PHPVideoToolkit::getAvailableCodecs('audio');
+ $video_codecs = PHPVideoToolkit::getAvailableCodecs('video');
+ $subtitle_codecs = PHPVideoToolkit::getAvailableCodecs('subtitle');
+
+ echo '<table border="0" cellspacing="0" cellpadding="5">
+ <tr>
+ <td>
+ Format Information
+ </td>
+ <td>
+ Codec Information
+ </td>
+ </tr>
+ <tr>
+ <td style="padding-right:20px;" valign="top">
+ <table border="0" cellspacing="0" cellpadding="5">
+ <tr>
+ <td style="width:125px;">
+ Format
+ </td>
+ <td style="width:75px;">
+ Mux
+ </td>
+ <td style="width:75px;">
+ Demux
+ </td>
+ </tr>';
+
+// loop and check availability
+ foreach ($formats as $format)
+ {
+ echo ' <tr>
+ <td style="border-bottom:1px solid #ccc">
+ '.$format.'
+ </td>
+ <td style="border-bottom:1px solid #ccc">
+ '.(PHPVideoToolkit::canFormatBeMuxed($format) ? 'YES' : '&nbsp;').'
+ </td>
+ <td style="border-bottom:1px solid #ccc">
+ '.(PHPVideoToolkit::canFormatBeDemuxed($format) ? 'YES' : '&nbsp;').'
+ </td>
+ </tr>';
+ }
+ echo ' </table>
+ </td>
+ <td valign="top">
+ <strong>Audio Codecs</strong>
+ <table border="0" cellspacing="0" cellpadding="5">
+ <tr>
+ <td style="width:125px;">
+ Format
+ </td>
+ <td style="width:75px;">
+ Encode
+ </td>
+ <td style="width:75px;">
+ Decode
+ </td>
+ </tr>';
+
+// loop and check availability
+ foreach ($audio_codecs as $codec)
+ {
+ echo ' <tr>
+ <td style="border-bottom:1px solid #ccc">
+ '.$codec.'
+ </td>
+ <td style="border-bottom:1px solid #ccc">
+ '.(PHPVideoToolkit::canCodecBeEncoded('audio', $codec) ? 'YES' : '&nbsp;').'
+ </td>
+ <td style="border-bottom:1px solid #ccc">
+ '.(PHPVideoToolkit::canCodecBeDecoded('audio', $codec) ? 'YES' : '&nbsp;').'
+ </td>
+ </tr>';
+ }
+ echo ' </table>
+ <br />
+ <br />
+ <strong>Video Codecs</strong>
+ <table border="0" cellspacing="0" cellpadding="5">
+ <tr>
+ <td style="width:125px;">
+ Format
+ </td>
+ <td style="width:75px;">
+ Encode
+ </td>
+ <td style="width:75px;">
+ Decode
+ </td>
+ </tr>';
+
+// loop and check availability
+ foreach ($video_codecs as $codec)
+ {
+ echo ' <tr>
+ <td style="border-bottom:1px solid #ccc">
+ '.$codec.'
+ </td>
+ <td style="border-bottom:1px solid #ccc">
+ '.(PHPVideoToolkit::canCodecBeEncoded('video', $codec) ? 'YES' : '&nbsp;').'
+ </td>
+ <td style="border-bottom:1px solid #ccc">
+ '.(PHPVideoToolkit::canCodecBeDecoded('video', $codec) ? 'YES' : '&nbsp;').'
+ </td>
+ </tr>';
+ }
+ echo ' </table>
+ <br />
+ <br />
+ <strong>Subtitle Codecs</strong>
+ <table border="0" cellspacing="0" cellpadding="5">
+ <tr>
+ <td style="width:125px;">
+ Codec
+ </td>
+ <td style="width:75px;">
+ Encode
+ </td>
+ <td style="width:75px;">
+ Decode
+ </td>
+ </tr>';
+
+// loop and check availability
+ foreach ($subtitle_codecs as $codec)
+ {
+ echo ' <tr>
+ <td style="border-bottom:1px solid #ccc">
+ '.$codec.'
+ </td>
+ <td style="border-bottom:1px solid #ccc">
+ '.(PHPVideoToolkit::canCodecBeEncoded('subtitle', $codec) ? 'YES' : '&nbsp;').'
+ </td>
+ <td style="border-bottom:1px solid #ccc">
+ '.(PHPVideoToolkit::canCodecBeDecoded('subtitle', $codec) ? 'YES' : '&nbsp;').'
+ </td>
+ </tr>';
+ }
+ echo ' </table>
+ </td>
+ </tr>
+ </table>';
+
+
+// loop the codecs
+
+ echo '</body></html>';
+ \ No newline at end of file
diff --git a/libraries/phpvideotoolkit/examples/php5/example15.php b/libraries/phpvideotoolkit/examples/php5/example15.php
new file mode 100644
index 0000000..3de796a
--- /dev/null
+++ b/libraries/phpvideotoolkit/examples/php5/example15.php
@@ -0,0 +1,41 @@
+<?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.
+ */
+
+ echo '<html><head><link type="text/css" rel="stylesheet" href="../common/styles.css"><meta name="author" content="Oliver Lillie"></head><body>';
+ echo '<a class="backtoexamples" href="../index.php#examples">&larr; Back to examples list</a><br /><br />';
+ echo '<strong>This example determines if FFmpeg is available at the location you specified in the example configs.</strong><br /><br />';
+ $ignore_demo_files = true;
+
+// load the examples configuration
+ require_once '../example-config.php';
+
+// require the library
+ require_once '../../phpvideotoolkit.'.$use_version.'.php';
+
+// get the ffmpeg info
+ PHPVideoToolkit::getFFmpegInfo();
+
+ echo PHPVideoToolkit::$ffmpeg_found === true ? 'FFmpeg is available' : 'FFmpeg is not available';
+
+// loop the codecs
+
+ echo '</body></html>';
+ \ No newline at end of file