Login   Register  
PHP Classes

File: examples/example12.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Oliver Lillie  >  PHP Video Toolkit  >  examples/example12.php  >  Download  
File: examples/example12.php
Role: Example script
Content type: text/plain
Description: Shows how to easily manipluate timecodes
Class: PHP Video Toolkit
Manipulate and convert videos with ffmpeg program
Author: By
Last change: Updated for version 0.1.5
Date: 6 years ago
Size: 4,000 bytes


Class file image Download

/* SVN FILE: $Id$ */
     * @author Oliver Lillie (aka buggedcom) <publicmail@buggedcom.co.uk>
     * @package PHPVideoToolkit
     * @license BSD
     * @copyright Copyright (c) 2008 Oliver Lillie <http://www.buggedcom.co.uk>
     * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
     * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
     * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
     * is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be
     * included in all copies or substantial portions of the Software.

echo '<html><head></head><body>';
'<a style="font-size:12px;" href="index.php#examples">&larr; Back to examples list</a><br /><br />';
'<strong>This example shows you how to manipulate/format timecode strings.</strong><br /><br />';
$ignore_demo_files true;
//     load the examples configuration
require_once 'example-config.php';
//     require the library
require_once '../phpvideotoolkit.'.$use_version.'.php';
//     temp directory
//     set the frame rate for the timecodes
$frame_rate 25;
//     set the time to examine / format
$timecode '01:14:32.59';
$timecode_format '%hh:%mm:%ss.%ms';
'<strong>Original Timecode</strong><br />';
$timecode.'<br /><br />';
//     start ffmpeg class
$toolkit = new PHPVideoToolkit($tmp_dir);
'<strong>Timecode conversion to seconds</strong><br />';
'Frame seconds (rounded) -> '.$toolkit->formatTimecode($timecode$timecode_format'%st'$frame_rate).'<br />';
'Frame seconds (rounded down) -> '.$toolkit->formatTimecode($timecode$timecode_format'%sf'$frame_rate).'<br />';
'Frame seconds (rounded up) -> '.$toolkit->formatTimecode($timecode$timecode_format'%sc'$frame_rate).'<br />';
'Frame seconds -> '.$toolkit->formatTimecode($timecode$timecode_format'%mt'$frame_rate).'<br /><br />';
'<strong>Timecode conversion to frames</strong><br />';
'Frame number (in current second) -> '.$toolkit->formatTimecode($timecode$timecode_format'%fn'$frame_rate).'<br />';
'Frame number (in video) -> '.$toolkit->formatTimecode($timecode$timecode_format'%ft'$frame_rate).'<br /><br />';
'<strong>Timecode conversion to other timecodes</strong><br />';
'hh:mm -> '.$toolkit->formatTimecode($timecode$timecode_format'%hh:%mm'$frame_rate).'<br />';
'hh:mm:ss -> '.$toolkit->formatTimecode($timecode$timecode_format'%hh:%mm:%ss'$frame_rate).'<br />';
'hh:mm:ss.fn -> '.$toolkit->formatTimecode($timecode$timecode_format'%hh:%mm:%ss.%fn'$frame_rate).'<br />';
'hh:mm:ss.ms -> '.$toolkit->formatTimecode($timecode$timecode_format'%hh:%mm:%ss.%ms'$frame_rate).'<br />';
'mm:ss (smart minutes) -> '.$toolkit->formatTimecode($timecode$timecode_format'%mm:%ss'$frame_rate).'<br />';
'mm:ss.fn (smart minutes) -> '.$toolkit->formatTimecode($timecode$timecode_format'%mm:%ss.%fn'$frame_rate).'<br />';
'ss.ms (smart seconds) -> '.$toolkit->formatTimecode($timecode$timecode_format'%ss.%ms'$frame_rate).'<br />';