From a435de089da4dd37c3c183f633a49107c720dd95 Mon Sep 17 00:00:00 2001 From: Dalyn Cessac Date: Wed, 16 Mar 2011 11:06:40 -0500 Subject: Added phpvideotoolkit transcoder and updates to the preset ui --- .../phpvideotoolkit/examples/php4/example01.php | 151 +++++++++++++ .../phpvideotoolkit/examples/php4/example02.php | 139 ++++++++++++ .../phpvideotoolkit/examples/php4/example03.php | 114 ++++++++++ .../phpvideotoolkit/examples/php4/example04.php | 171 +++++++++++++++ .../phpvideotoolkit/examples/php4/example05.php | 84 ++++++++ .../phpvideotoolkit/examples/php4/example06.php | 146 +++++++++++++ .../phpvideotoolkit/examples/php4/example07.php | 120 +++++++++++ .../phpvideotoolkit/examples/php4/example08.php | 32 +++ .../phpvideotoolkit/examples/php4/example09.php | 78 +++++++ .../phpvideotoolkit/examples/php4/example10.php | 128 +++++++++++ .../phpvideotoolkit/examples/php4/example11.php | 33 +++ .../phpvideotoolkit/examples/php4/example12.php | 236 +++++++++++++++++++++ .../phpvideotoolkit/examples/php4/example13.php | 111 ++++++++++ .../phpvideotoolkit/examples/php4/example14.php | 71 +++++++ .../phpvideotoolkit/examples/php4/example15.php | 42 ++++ 15 files changed, 1656 insertions(+) create mode 100644 libraries/phpvideotoolkit/examples/php4/example01.php create mode 100644 libraries/phpvideotoolkit/examples/php4/example02.php create mode 100644 libraries/phpvideotoolkit/examples/php4/example03.php create mode 100644 libraries/phpvideotoolkit/examples/php4/example04.php create mode 100644 libraries/phpvideotoolkit/examples/php4/example05.php create mode 100644 libraries/phpvideotoolkit/examples/php4/example06.php create mode 100644 libraries/phpvideotoolkit/examples/php4/example07.php create mode 100644 libraries/phpvideotoolkit/examples/php4/example08.php create mode 100644 libraries/phpvideotoolkit/examples/php4/example09.php create mode 100644 libraries/phpvideotoolkit/examples/php4/example10.php create mode 100644 libraries/phpvideotoolkit/examples/php4/example11.php create mode 100644 libraries/phpvideotoolkit/examples/php4/example12.php create mode 100644 libraries/phpvideotoolkit/examples/php4/example13.php create mode 100644 libraries/phpvideotoolkit/examples/php4/example14.php create mode 100644 libraries/phpvideotoolkit/examples/php4/example15.php (limited to 'libraries/phpvideotoolkit/examples/php4') diff --git a/libraries/phpvideotoolkit/examples/php4/example01.php b/libraries/phpvideotoolkit/examples/php4/example01.php new file mode 100644 index 0000000..8bdd52f --- /dev/null +++ b/libraries/phpvideotoolkit/examples/php4/example01.php @@ -0,0 +1,151 @@ + + * @package PHPVideoToolkit + * @license BSD + * @copyright Copyright (c) 2008 Oliver Lillie + * 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 ''; + echo '← Back to examples list

'; + echo 'This example shows you how to convert video to flash video (flv).
'; + echo '• The media player used below is Jeroen Wijering\'s excellent Flash Media Player. Although bundled with this package the Flash Media Player has a Creative Commons Attribution-Noncommercial-Share Alike 2.0 Generic license.
'; + echo '• The media player is embedded using PluginObject to embed the examples. It is distributed under a BSD License.

'; + +// 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 'Processing '.$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 $toolkit->getLastError()."

\r\n"; + $toolkit->reset(); + continue; + } + +// set the output dimensions + $toolkit->setVideoOutputDimensions(320, 240); + +// set the video to be converted to flv + $toolkit->setFormatToFLV($samprate, $bitrate); + +// 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()."

\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]."
\r\n"; +// echo $command[1]."
\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()."

\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... '.$file.'

+
+
'."\r\n"; + +// reset + $toolkit->reset(); + } + + echo ''."\r\n".'The total time taken to process all '.($key+1).' file(s) is : '.$total_process_time.''; + echo '
'."\r\n".'The average time taken to process each file is : '.($total_process_time/($key+1)).''; + echo ''; \ No newline at end of file diff --git a/libraries/phpvideotoolkit/examples/php4/example02.php b/libraries/phpvideotoolkit/examples/php4/example02.php new file mode 100644 index 0000000..345bcf4 --- /dev/null +++ b/libraries/phpvideotoolkit/examples/php4/example02.php @@ -0,0 +1,139 @@ + + * @package PHPVideoToolkit + * @license BSD + * @copyright Copyright (c) 2008 Oliver Lillie + * 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 ''; + echo '← Back to examples list

'; + echo 'This example shows you how to extract frames from a movie.
'; + +// load the examples configuration + require_once '../example-config.php'; + +// require the library + require_once '../../phpvideotoolkit.'.$use_version.'.php'; + + echo 'Note; 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.

'; + +// 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 'Extracting '.$filename.'
'; + +// 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 ''.$toolkit->getLastError()."
\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.
'; + $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 ''.$toolkit->getLastError()."
\r\n"; + $toolkit->reset(); + continue; + } + +// execute the ffmpeg command + $result = $toolkit->execute(false, true); + +// get the last command given +// $command = $toolkit->getLastCommand(); +// echo $command."
\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()."
\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... '.$thumbnail_output_dir.array_pop($files).'
'."\r\n"; + foreach($files as $key=>$file) + { + echo ' '; + } + echo '

'; + +// reset + $toolkit->reset(); + + } + + echo ''."\r\n".'The total time taken to process all '.($key+1).' file(s) is : '.$total_process_time.''; + echo '
'."\r\n".'The average time taken to process each file is : '.($total_process_time/($key+1)).''; + echo ''; \ No newline at end of file diff --git a/libraries/phpvideotoolkit/examples/php4/example03.php b/libraries/phpvideotoolkit/examples/php4/example03.php new file mode 100644 index 0000000..8e38e75 --- /dev/null +++ b/libraries/phpvideotoolkit/examples/php4/example03.php @@ -0,0 +1,114 @@ + + * @package PHPVideoToolkit + * @license BSD + * @copyright Copyright (c) 2008 Oliver Lillie + * 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 ''; + echo '← Back to examples list

'; + echo 'This example shows you how to compile a movie from multiple jpegs.
'; + +// 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()."
\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()."
\r\n"; + exit; + } + +// execute the ffmpeg command + $result = $toolkit->execute(false, true); + +// get the last command given +// $command = $toolkit->getLastCommand(); +// echo $command."
\r\n
\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()."
\r\n"; + exit; + } + $toolkit->moveLog($log_dir.'example03.log'); + + $img = array_shift($toolkit->getLastOutput()); + echo "Video created from images... ".basename($img)."
"; + echo '

'; + echo ''; diff --git a/libraries/phpvideotoolkit/examples/php4/example04.php b/libraries/phpvideotoolkit/examples/php4/example04.php new file mode 100644 index 0000000..36cb5a4 --- /dev/null +++ b/libraries/phpvideotoolkit/examples/php4/example04.php @@ -0,0 +1,171 @@ + + * @package PHPVideoToolkit + * @license BSD + * @copyright Copyright (c) 2008 Oliver Lillie + * 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 ''; + echo '← Back to examples list

'; + echo '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.
'; + echo '• The media player is embedded using PluginObject to embed the video examples. It is distributed under a BSD License.

'; + +// 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 'Testing for vhook support...
'; + if(!$toolkit->hasVHookSupport()) + { + echo 'You FFmpeg binary has NOT been compiled with vhook support, you can not watermark video, you can however watermark image outputs.
Click here to run the watermark demo on images only.
'; + exit; +//<- exits + } + echo 'You FFmpeg binary has been compiled with vhook support.

'; + } + else + { + echo 'GD watermarking only...
'; + echo 'Your FFmpeg binary has NOT been compiled with vhook support and we are only testing automated watermarking of images via GD now.
Click here to go back to the vhook watermarking demo.

'; + } + +// 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 ''.$toolkit->getLastError()."
\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 ''.$toolkit->getLastError()."
\r\n"; + exit; + } + +// execute the ffmpeg command + $result = $toolkit->execute(false, true); + +// get the last command given +// $command = $toolkit->getLastCommand(); +// echo $command."
\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()."
\r\n"; + $toolkit->reset(); + exit; + } + + $file = array_shift($toolkit->getLastOutput()); + $filename = basename($file); + if($use_vhook) + { + $filename_hash = md5($filename); + + echo 'Video watermarked... '.$filename.'

+
+
'."\r\n"; + } + else + { + echo 'Frame watermarked... '.$filename.'
'."\r\n"; +// $files = $toolkit->getLastOutput(); +// foreach($files as $key=>$file) +// { +// echo ' '; +// } + echo ' '; + } + +// reset + $toolkit->reset(); + + echo ''; diff --git a/libraries/phpvideotoolkit/examples/php4/example05.php b/libraries/phpvideotoolkit/examples/php4/example05.php new file mode 100644 index 0000000..46399e6 --- /dev/null +++ b/libraries/phpvideotoolkit/examples/php4/example05.php @@ -0,0 +1,84 @@ + + * @package PHPVideoToolkit + * @license BSD + * @copyright Copyright (c) 2008 Oliver Lillie + * 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 ''; + echo '← Back to examples list

'; + echo 'This example shows you how to access media metadata without using the ffmpeg-php library.
'; + +// 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 'Information for : '.$file."
\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()."
\r\n"; + $toolkit->reset(); + continue; + } + $data = $toolkit->getFileInfo(); + + echo '
';
+		print_r($data);
+		echo '
'; + +// reset + $toolkit->reset(); + } + + echo ''; \ No newline at end of file diff --git a/libraries/phpvideotoolkit/examples/php4/example06.php b/libraries/phpvideotoolkit/examples/php4/example06.php new file mode 100644 index 0000000..71f4822 --- /dev/null +++ b/libraries/phpvideotoolkit/examples/php4/example06.php @@ -0,0 +1,146 @@ + + * @package PHPVideoToolkit + * @license BSD + * @copyright Copyright (c) 2008 Oliver Lillie + * 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 ''; + echo '← Back to examples list

'; + echo 'This example shows you how to extract audio from video.
'; + echo '• The media player used below is Jeroen Wijering\'s excellent Flash Media Player. Although bundled with this package the Flash Media Player has a Creative Commons Attribution-Noncommercial-Share Alike 2.0 Generic license.
'; + echo '• The media player is embedded using PluginObject to embed the examples. It is distributed under a BSD License.
'; + +// 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.'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 'Processing '.$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 $toolkit->getLastError()."

\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()."

\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[0]."
\r\n"; +// echo $command[1]."
\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()."

\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...
+
+
'."\r\n"; + +// reset + $toolkit->reset(); + } + + echo "\r\n".'The total time taken to process all '.($key+1).' file(s) is : '.$total_process_time.''; + echo '
'."\r\n".'The average time taken to process each file is : '.($total_process_time/($key+1)).''; + echo ''; \ No newline at end of file diff --git a/libraries/phpvideotoolkit/examples/php4/example07.php b/libraries/phpvideotoolkit/examples/php4/example07.php new file mode 100644 index 0000000..a091565 --- /dev/null +++ b/libraries/phpvideotoolkit/examples/php4/example07.php @@ -0,0 +1,120 @@ + + * @package PHPVideoToolkit + * @license BSD + * @copyright Copyright (c) 2008 Oliver Lillie + * 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 ''; + echo '← Back to examples list

'; + echo 'This example shows you how to join multiple videos together.
Please note that this example while valid code does not work yet within the PHPVideoToolkit class.

'; + 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()."
\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()."
\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]."
\r\n"; +// echo $command[1]."
\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()."
\r\n"; + $toolkit->reset(); + exit; + } + + echo 'Videos joined... '.array_shift($toolkit->getLastOutput()).'
'."\r\n"; + +// reset + $toolkit->reset(); + + echo ''; diff --git a/libraries/phpvideotoolkit/examples/php4/example08.php b/libraries/phpvideotoolkit/examples/php4/example08.php new file mode 100644 index 0000000..116eab1 --- /dev/null +++ b/libraries/phpvideotoolkit/examples/php4/example08.php @@ -0,0 +1,32 @@ + + * @package PHPVideoToolkit + * @license BSD + * @copyright Copyright (c) 2008 Oliver Lillie + * 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 ''; + echo '← Back to examples list

'; + echo 'This example shows you how to convert videos to common formats simply by using the simple adapters.
'; + echo '• The flash media player used below is Jeroen Wijering\'s excellent Flash Media Player. Although bundled with this package the Flash Media Player has a Creative Commons Attribution-Noncommercial-Share Alike 2.0 Generic license.
'; + echo '• The media is embedded using PluginObject to embed the examples. It is distributed under a BSD License.

'; + +// load the examples configuration + require_once '../example-config.php'; + + echo 'You cannot use the VideoTo Adapter class in PHP4. I will NOT be offering a PHP4 alternative.

'; + echo ''; \ No newline at end of file diff --git a/libraries/phpvideotoolkit/examples/php4/example09.php b/libraries/phpvideotoolkit/examples/php4/example09.php new file mode 100644 index 0000000..93112b5 --- /dev/null +++ b/libraries/phpvideotoolkit/examples/php4/example09.php @@ -0,0 +1,78 @@ + + * @package PHPVideoToolkit + * @license BSD + * @copyright Copyright (c) 2008 Oliver Lillie + * 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 ''; + echo '← Back to examples list

'; + echo 'This example shows you how to access the information about your ffmpeg installation.

'; + $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 + $info = $toolkit->getFFmpegInfo(); + +// determine the type of support for ffmpeg-php + echo 'FFmpeg-PHP Support
'; + +// 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.
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. +
	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\';
+	}
Note: 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; + } + + echo '
This is the information that is accessible about your install of FFmpeg.
'; + echo 'You may also wish to see example 14 which gives you an encode/decode lookup table.'; + echo '
';
+	print_r($info);
+	echo '
'; + echo ''; + \ No newline at end of file diff --git a/libraries/phpvideotoolkit/examples/php4/example10.php b/libraries/phpvideotoolkit/examples/php4/example10.php new file mode 100644 index 0000000..76094cd --- /dev/null +++ b/libraries/phpvideotoolkit/examples/php4/example10.php @@ -0,0 +1,128 @@ + + * @package PHPVideoToolkit + * @license BSD + * @copyright Copyright (c) 2008 Oliver Lillie + * 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 ''; + echo '← Back to examples list

'; + echo 'This example shows you how to extract a specific frame from a movie.
'; + +// 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($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 ''.$toolkit->getLastError()."
\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 ''.$toolkit->getLastError()."
\r\n"; + $toolkit->reset(); + continue; + } + +// execute the ffmpeg command + $result = $toolkit->execute(false, true); + +// get the last command given +// $command = $toolkit->getLastCommand(); +// echo $command."
\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()."
\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... '.$thumbnail_output_dir.$file.'
'."\r\n"; + echo '

'; + +// reset + $toolkit->reset(); + + } + + echo '
'."\r\n".'The total time taken to process all '.($key+1).' file(s) is : '.$total_process_time.''; + echo '
'."\r\n".'The average time taken to process each file is : '.($total_process_time/($key+1)).'

'; + echo ''; diff --git a/libraries/phpvideotoolkit/examples/php4/example11.php b/libraries/phpvideotoolkit/examples/php4/example11.php new file mode 100644 index 0000000..2c403e2 --- /dev/null +++ b/libraries/phpvideotoolkit/examples/php4/example11.php @@ -0,0 +1,33 @@ + + * @package PHPVideoToolkit + * @license BSD + * @copyright Copyright (c) 2008 Oliver Lillie + * 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 ''; + echo '← Back to examples list

'; + echo 'This example shows you how to use the ffmpeg-php adaptor scripts. NOTE: Please note whenever possible you should use ffmpeg-php as it is much more efficient than this pure PHP emulation.
'; + +// load the examples configuration + require_once '../example-config.php'; + + echo 'You cannot use the FFmpeg-PHP Adapter class in PHP4. I will NOT be offering a PHP4 alternative.

'; + echo ''; + + + diff --git a/libraries/phpvideotoolkit/examples/php4/example12.php b/libraries/phpvideotoolkit/examples/php4/example12.php new file mode 100644 index 0000000..8ada5fe --- /dev/null +++ b/libraries/phpvideotoolkit/examples/php4/example12.php @@ -0,0 +1,236 @@ + + * @package PHPVideoToolkit + * @license BSD + * @copyright Copyright (c) 2008 Oliver Lillie + * 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 ''; + echo '← Back to examples list

'; + echo 'This example shows you how to manipulate/format timecode strings.

'; + $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 'Timecode Format Placeholders
'; + 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

'; + echo ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ %hh + + hours +
+ %mm + + minutes +
+   + + NOTE: Smart Value Warning. By default if %hh (hours) aren\'t used in the format then this will give the total number of minutes. +
+ %ss + + seconds +
+   + + 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. +
+ %fn + + frame number +
+ %ms + + milliseconds +
+ %ft + + frames total +
+ %st + + seconds total +
+ %sf + + seconds floored +
+ %sc + + seconds ceiled +
+ %mt + + milliseconds total +
'; + echo '
'; + 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.

'; + + echo 'Original Timecode
'; + echo $timecode.'

'; + + echo 'Timecode conversion to seconds
'; + echo 'Frame seconds (rounded) -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%st', $frame_rate).'
'; + echo 'Frame seconds (rounded down) -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%sf', $frame_rate).'
'; + echo 'Frame seconds (rounded up) -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%sc', $frame_rate).'
'; + echo 'Frame seconds -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%mt', $frame_rate).'

'; + + echo 'Timecode conversion to frames
'; + echo 'Frame number (in current second) -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%fn', $frame_rate).'
'; + echo 'Frame number (in video) -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%ft', $frame_rate).'

'; + + echo 'Timecode conversion to other timecodes
'; + echo 'hh:mm -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%hh:%mm', $frame_rate).'
'; + echo 'hh:mm:ss -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%hh:%mm:%ss', $frame_rate).'
'; + echo 'hh:mm:ss.fn -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%hh:%mm:%ss.%fn', $frame_rate).'
'; + echo 'hh:mm:ss.ms -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%hh:%mm:%ss.%ms', $frame_rate).'
'; + echo 'mm:ss (smart minutes) -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%mm:%ss', $frame_rate).'
'; + echo 'mm:ss.fn (smart minutes) -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%mm:%ss.%fn', $frame_rate).'
'; + echo 'ss.ms (smart seconds) -> '.$toolkit->formatTimecode($timecode, $timecode_format, '%ss.%ms', $frame_rate).'

'; + + // output the timecode form, remembering to disable smart values + $use_smart_values = false; + echo 'Change Timecode
'; + echo '
+ + + + + + + + + + + + + + + +
+ Hours + + Mins + + Secs + + Milli + + Frame Rate +
+ : + + : + + : + + / + + + + +

'; + + echo ''; diff --git a/libraries/phpvideotoolkit/examples/php4/example13.php b/libraries/phpvideotoolkit/examples/php4/example13.php new file mode 100644 index 0000000..4e97e65 --- /dev/null +++ b/libraries/phpvideotoolkit/examples/php4/example13.php @@ -0,0 +1,111 @@ + + * @package PHPVideoToolkit + * @license BSD + * @copyright Copyright (c) 2008 Oliver Lillie + * 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 ''; + echo '← Back to examples list

'; + echo 'This example shows how to simply create an FLV stream script.
'; + echo '• The flash media player used below is Jeroen Wijering\'s excellent Flash Media Player. Although bundled with this package the Flash Media Player has a Creative Commons Attribution-Noncommercial-Share Alike 2.0 Generic license.
'; + echo '• The media is embedded using PluginObject to embed the examples. It is distributed under a BSD License.

'; + } + +// 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 'Bandwidth Restrictions and Download Rate.
'; + 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').'.
'; + 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.
'; + echo 'However you can test this better by downloading this link.
'; + 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.
'; + echo '
'; + echo 'Change the example bandwidth restriction.
'; + echo '
+
+
+
+'; + + + +// echo ''; diff --git a/libraries/phpvideotoolkit/examples/php4/example14.php b/libraries/phpvideotoolkit/examples/php4/example14.php new file mode 100644 index 0000000..2d6c44c --- /dev/null +++ b/libraries/phpvideotoolkit/examples/php4/example14.php @@ -0,0 +1,71 @@ + + * @package PHPVideoToolkit + * @license BSD + * @copyright Copyright (c) 2008 Oliver Lillie + * 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 ''; + echo '← Back to examples list

'; + echo '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..

'; + $ignore_demo_files = true; + +// load the examples configuration + require_once '../example-config.php'; + +// require the library + require_once '../../phpvideotoolkit.'.$use_version.'.php'; + +// start ffmpeg class + $toolkit = new PHPVideoToolkit(); + +// get the ffmpeg info + $codecs = $toolkit->getAvailableCodecs(); + + echo ' + + + + + '; +// loop and check availability + foreach ($codecs as $codec) + { + echo ' + + + + '; + } + echo '
+ Codec + + Encode + + Decode +
+ '.$codec.' + + '.($toolkit->canCodecBeEncoded($codec) ? 'YES' : ' ').' + + '.($toolkit->canCodecBeDecoded($codec) ? 'YES' : ' ').' +
'; + +// loop the codecs + + echo ''; + \ No newline at end of file diff --git a/libraries/phpvideotoolkit/examples/php4/example15.php b/libraries/phpvideotoolkit/examples/php4/example15.php new file mode 100644 index 0000000..8f088cf --- /dev/null +++ b/libraries/phpvideotoolkit/examples/php4/example15.php @@ -0,0 +1,42 @@ + + * @package PHPVideoToolkit + * @license BSD + * @copyright Copyright (c) 2008 Oliver Lillie + * 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 ''; + echo '← Back to examples list

'; + echo 'This example determines if FFmpeg is available at the location you specified in the example configs.

'; + $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 + $toolkit = new PHPVideoToolkit(); + $toolkit->getFFmpegInfo(); + + echo $toolkit->ffmpeg_found === true ? 'FFmpeg is available' : 'FFmpeg is not available'; + +// loop the codecs + + echo ''; + \ No newline at end of file -- cgit v1.2.3