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/example12.php | 236 +++++++++++++++++++++ 1 file changed, 236 insertions(+) create mode 100644 libraries/phpvideotoolkit/examples/php4/example12.php (limited to 'libraries/phpvideotoolkit/examples/php4/example12.php') 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 ''; -- cgit v1.2.3