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/php5/example01.php | 158 ++++++++++++++ .../phpvideotoolkit/examples/php5/example02.php | 139 ++++++++++++ .../phpvideotoolkit/examples/php5/example03.php | 114 ++++++++++ .../phpvideotoolkit/examples/php5/example04.php | 171 +++++++++++++++ .../phpvideotoolkit/examples/php5/example05.php | 84 ++++++++ .../phpvideotoolkit/examples/php5/example06.php | 147 +++++++++++++ .../phpvideotoolkit/examples/php5/example07.php | 120 +++++++++++ .../phpvideotoolkit/examples/php5/example08.php | 191 +++++++++++++++++ .../phpvideotoolkit/examples/php5/example09.php | 92 ++++++++ .../phpvideotoolkit/examples/php5/example10.php | 128 +++++++++++ .../phpvideotoolkit/examples/php5/example11.php | 162 ++++++++++++++ .../phpvideotoolkit/examples/php5/example12.php | 236 +++++++++++++++++++++ .../phpvideotoolkit/examples/php5/example13.php | 111 ++++++++++ .../phpvideotoolkit/examples/php5/example14.php | 183 ++++++++++++++++ .../phpvideotoolkit/examples/php5/example15.php | 41 ++++ 15 files changed, 2077 insertions(+) create mode 100644 libraries/phpvideotoolkit/examples/php5/example01.php create mode 100644 libraries/phpvideotoolkit/examples/php5/example02.php create mode 100644 libraries/phpvideotoolkit/examples/php5/example03.php create mode 100644 libraries/phpvideotoolkit/examples/php5/example04.php create mode 100644 libraries/phpvideotoolkit/examples/php5/example05.php create mode 100644 libraries/phpvideotoolkit/examples/php5/example06.php create mode 100644 libraries/phpvideotoolkit/examples/php5/example07.php create mode 100644 libraries/phpvideotoolkit/examples/php5/example08.php create mode 100644 libraries/phpvideotoolkit/examples/php5/example09.php create mode 100644 libraries/phpvideotoolkit/examples/php5/example10.php create mode 100644 libraries/phpvideotoolkit/examples/php5/example11.php create mode 100644 libraries/phpvideotoolkit/examples/php5/example12.php create mode 100644 libraries/phpvideotoolkit/examples/php5/example13.php create mode 100644 libraries/phpvideotoolkit/examples/php5/example14.php create mode 100644 libraries/phpvideotoolkit/examples/php5/example15.php (limited to 'libraries/phpvideotoolkit/examples/php5') 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 @@ + + * @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 + $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()."

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

\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/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 @@ + + * @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/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 @@ + + * @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/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 @@ + + * @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/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 @@ + + * @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/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 @@ + + * @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.'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 '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."
\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/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 @@ + + * @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/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 @@ + + * @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'; + +// 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 'Processing '.basename($file).'
'; + + $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().'
'."\r\n"; + echo 'Please check the log file generated as additional debug info may be contained.
'."\r\n"; + } + else + { + $output = VideoTo::getOutput(); + echo 'Coverted to Gif...


'."\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().'
'."\r\n"; + echo 'Please check the log file generated as additional debug info may be contained.
'."\r\n"; + } + else + { + $output = VideoTo::getOutput(); + $filename = basename($output[0]); + $filename_hash = md5($filename); + echo 'Coverted to PSP mp4...
+
+
'."\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().'
'."\r\n"; + echo 'Please check the log file generated as additional debug info may be contained.
'."\r\n"; + } + else + { + $output = VideoTo::getOutput(); + $filename = basename($output[0]); + $filename_hash = md5($filename); + echo 'Coverted to Flash Video (flv)...
+
+
'."\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().'
'."\r\n"; + echo 'Please check the log file generated as additional debug info may be contained.

'."\r\n"; + } + else + { + $output = VideoTo::getOutput(); + $filename = basename($output[0]); + $filename_hash = md5($filename); + echo 'Coverted to iPod mp4...
+
+
'."\r\n"; + } + + } + + echo ''; \ 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 @@ + + * @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.
'; + echo '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.

'; + + $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 'FFMpeg Info
'; + 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 '

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; + } + +// output data + 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 '
';
+	unset($info['raw']);
+	print_r($info);
+	echo '
'; + echo ''; + \ 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 @@ + + * @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('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 ''.$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/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 @@ + + * @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 'NOTE; The FFmpeg-PHP adapter makes use of PHP-Reader and GifEncoder, 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).

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

'; + } + +// 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 'Plain Frame Grab of Movie.
'; + echo 'This is a frame grab at the same resolution as the video.
'; + echo '

'; + +// 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 'Cropped Frame Grab of Movie.
'; + echo 'This is a frame grab that has been cropped.
'; + echo '

'; + +// 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 'Cropped and Resized Frame Grab of Movie.
'; + echo 'This is a frame grab that has been cropped then resized.
'; + echo '

'; + +// 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.
'; + } + } +// 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.
'; + } + } + } + echo 'Animated Gif of Movie.
'; + $result = $ffmpeg_gif->saveNow($tmp_dir); + if(!$result) + { + echo 'It was not possible to save the animated gif for some reason.
'; + } + else + { + echo 'This is an animated gif extracted from the movie.
'; + echo '

'; + } + + echo 'Cropped and Resized Animated Gif of Movie.
'; + $result = $ffmpeg_gif_small->saveNow($tmp_dir); + if(!$result) + { + echo 'It was not possible to save the animated gif for some reason.
'; + } + else + { + echo 'This is an animated gif extracted from the movie but cropped and then resized.
'; + echo '

'; + } + } + + echo ''; + + + 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 @@ + + * @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/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 @@ + + * @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/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 @@ + + * @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'; + +// get the ffmpeg info + $formats = PHPVideoToolkit::getAvailableFormats(); + $audio_codecs = PHPVideoToolkit::getAvailableCodecs('audio'); + $video_codecs = PHPVideoToolkit::getAvailableCodecs('video'); + $subtitle_codecs = PHPVideoToolkit::getAvailableCodecs('subtitle'); + + echo ' + + + + + + + + +
+ Format Information + + Codec Information +
+ + + + + + '; + +// loop and check availability + foreach ($formats as $format) + { + echo ' + + + + '; + } + echo '
+ Format + + Mux + + Demux +
+ '.$format.' + + '.(PHPVideoToolkit::canFormatBeMuxed($format) ? 'YES' : ' ').' + + '.(PHPVideoToolkit::canFormatBeDemuxed($format) ? 'YES' : ' ').' +
+
+ Audio Codecs + + + + + + '; + +// loop and check availability + foreach ($audio_codecs as $codec) + { + echo ' + + + + '; + } + echo '
+ Format + + Encode + + Decode +
+ '.$codec.' + + '.(PHPVideoToolkit::canCodecBeEncoded('audio', $codec) ? 'YES' : ' ').' + + '.(PHPVideoToolkit::canCodecBeDecoded('audio', $codec) ? 'YES' : ' ').' +
+
+
+ Video Codecs + + + + + + '; + +// loop and check availability + foreach ($video_codecs as $codec) + { + echo ' + + + + '; + } + echo '
+ Format + + Encode + + Decode +
+ '.$codec.' + + '.(PHPVideoToolkit::canCodecBeEncoded('video', $codec) ? 'YES' : ' ').' + + '.(PHPVideoToolkit::canCodecBeDecoded('video', $codec) ? 'YES' : ' ').' +
+
+
+ Subtitle Codecs + + + + + + '; + +// loop and check availability + foreach ($subtitle_codecs as $codec) + { + echo ' + + + + '; + } + echo '
+ Codec + + Encode + + Decode +
+ '.$codec.' + + '.(PHPVideoToolkit::canCodecBeEncoded('subtitle', $codec) ? 'YES' : ' ').' + + '.(PHPVideoToolkit::canCodecBeDecoded('subtitle', $codec) ? 'YES' : ' ').' +
+
'; + + +// loop the codecs + + echo ''; + \ 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 @@ + + * @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 + PHPVideoToolkit::getFFmpegInfo(); + + echo PHPVideoToolkit::$ffmpeg_found === true ? 'FFmpeg is available' : 'FFmpeg is not available'; + +// loop the codecs + + echo ''; + \ No newline at end of file -- cgit v1.2.3