<?php
/* SVN FILE: $Id$ */
/**
* @author Oliver Lillie (aka buggedcom) <
[email protected]>
*
* @license BSD
* @copyright Copyright (c) 2008 Oliver Lillie <http://www.buggedcom.co.uk>
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
* is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* @package PHPVideoToolkit (was called ffmpeg)
* @version 0.1.5
* @changelog SEE CHANGELOG
* @abstract This class can be used in conjunction with several server binary libraries to manipulate video and audio
* through PHP. It is not intended to solve any particular problems, however you may find it useful. This php class
* is in no way associated with the actual FFmpeg releases. Any mistakes contained in this php class are mine and mine
* alone.
*
* Please Note: There are several prerequisites that are required before this class can be used as an aid to manipulate
* video and audio. You must at the very least have FFMPEG compiled on your server. If you wish to use this class for FLV
* manipulation you must compile FFMPEG with LAME and Ruby's FLVTOOL2. I cannot answer questions regarding the install of
* the server binaries needed by this class. I had too learn the hard way and it isn't easy, however it is a good learning
* experience. For those of you who do need help read the install.txt file supplied along side this class. It wasn't written
* by me however I found it useful when installing ffmpeg for the first time. The original source for the install.txt file
* is located http://www.luar.com.hk/blog/?p=669 and the author is Lunar.
*
* @see install.txt
*
* @uses ffmpeg http://ffmpeg.sourceforge.net/
* @uses lame http://lame.sourceforge.net/
* @uses flvtool2 http://www.inlet-media.de/flvtool2 (and ruby http://www.ruby-lang.org/en/)
*
* @config examples/example-config.php Please edit this files in order for the examples to work.
* @example examples/example01.php Converts video to Flash Video (ie FLV).
* @example examples/example02.php Screen grabs video frames.
* @example examples/example03.php Compile a movie from multiple jpegs
* @example examples/example04.php Watermark a video.
* @example examples/example05.php Access media metadata without using the ffmpeg-php library.
* @example examples/example06.php Extract audio from video.
* @example examples/example07.php Join multiple videos together.
* @example examples/example08.php Easy video conversion to common formats using the adapters.
* @example examples/example09.php Shows you how to access the information about your ffmpeg installation.
* @example examples/example10.php Shows you how to extract a specific frame from a movie.
* @example examples/example11.php Shows you how to use the ffmpeg-php adapters to provide a pure php emulation of ffmpeg-php.
* @example examples/example12.php Shows you how to manipulate/format timecode strings.
* @example examples/example13.php This demonstrates how to simply create a FLV stream script.
*/
/**
* Set the ffmpeg binary path
*/
if(!defined('PHPVIDEOTOOLKIT_FFMPEG_BINARY'))
{
define('PHPVIDEOTOOLKIT_FFMPEG_BINARY', '/usr/local/bin/ffmpeg');
}
/**
* Set the flvtool2 binary path
*/
if(!defined('PHPVIDEOTOOLKIT_FLVTOOLS_BINARY'))
{
define('PHPVIDEOTOOLKIT_FLVTOOLS_BINARY', '/usr/bin/flvtool2');
}
/**
* Set the watermark vhook path
*/
if(!defined('PHPVIDEOTOOLKIT_FFMPEG_WATERMARK_VHOOK'))
{
define('PHPVIDEOTOOLKIT_FFMPEG_WATERMARK_VHOOK', '/usr/local/lib/vhook/watermark.so');
}
/**
* Set the memcoder path
*/
if(!defined('PHPVIDEOTOOLKIT_MENCODER_BINARY'))
{
define('PHPVIDEOTOOLKIT_MENCODER_BINARY', '/usr/local/bin/mencoder');
}
/**
* Codec support constants
*/
define('PHPVIDEOTOOLKIT_ENCODE', 'encode');
define('PHPVIDEOTOOLKIT_DECODE', 'decode');
/**
* Process Results from PHPVideoToolkit::execute
*/
// any return value with this means everything is ok
define('PHPVIDEOTOOLKIT_RESULT_OK', true);
// any return value with this means the file has been processed/converted ok however it was
// not able to be written to the output address. If this occurs you will need to move the
// processed file manually from the temp location
define('PHPVIDEOTOOLKIT_RESULT_OK_BUT_UNWRITABLE', -1);
/**
* Overwrite constants used in setOutput
*/
define('PHPVIDEOTOOLKIT_OVERWRITE_FAIL', 'fail');
define('PHPVIDEOTOOLKIT_OVERWRITE_PRESERVE', 'preserve');
define('PHPVIDEOTOOLKIT_OVERWRITE_EXISTING', 'existing');
define('PHPVIDEOTOOLKIT_OVERWRITE_UNIQUE', 'unique');
/**
* Formats supported
* 3g2 3gp2 format
* 3gp 3gp format
* aac ADTS AAC
* aiff Audio IFF
* amr 3gpp amr file format
* asf asf format
* avi avi format
* flv flv format
* gif GIF Animation
* mov mov format
* mov,mp4,m4a,3gp,3g2,mj2 QuickTime/MPEG4/Motion JPEG 2000 format
* mp2 MPEG audio layer 2
* mp3 MPEG audio layer 3
* mp4 mp4 format
* mpeg MPEG1 System format
* mpeg1video MPEG video
* mpeg2video MPEG2 video
* mpegvideo MPEG video
* psp psp mp4 format
* rm rm format
* swf Flash format
* vob MPEG2 PS format (VOB)
* wav wav format
* jpeg mjpeg format
* yuv4mpegpipe yuv4mpegpipe format
*/
define('PHPVIDEOTOOLKIT_FORMAT_3GP2', '3g2');
define('PHPVIDEOTOOLKIT_FORMAT_3GP', '3gp');
define('PHPVIDEOTOOLKIT_FORMAT_AAC', 'aac');
define('PHPVIDEOTOOLKIT_FORMAT_AIFF', 'aiff');
define('PHPVIDEOTOOLKIT_FORMAT_AMR', 'amr');
define('PHPVIDEOTOOLKIT_FORMAT_ASF', 'asf');
define('PHPVIDEOTOOLKIT_FORMAT_AVI', 'avi');
define('PHPVIDEOTOOLKIT_FORMAT_FLV', 'flv');
define('PHPVIDEOTOOLKIT_FORMAT_GIF', 'gif');
define('PHPVIDEOTOOLKIT_FORMAT_MJ2', 'mj2');
define('PHPVIDEOTOOLKIT_FORMAT_MP2', 'mp2');
define('PHPVIDEOTOOLKIT_FORMAT_MP3', 'mp3');
define('PHPVIDEOTOOLKIT_FORMAT_MP4', 'mp4');
define('PHPVIDEOTOOLKIT_FORMAT_MPEG4', 'mpeg4');
define('PHPVIDEOTOOLKIT_FORMAT_M4A', 'm4a');
define('PHPVIDEOTOOLKIT_FORMAT_MPEG', 'mpeg');
define('PHPVIDEOTOOLKIT_FORMAT_MPEG1', 'mpeg1video');
define('PHPVIDEOTOOLKIT_FORMAT_MPEG2', 'mpeg2video');
define('PHPVIDEOTOOLKIT_FORMAT_MPEGVIDEO', 'mpegvideo');
define('PHPVIDEOTOOLKIT_FORMAT_PSP', 'psp');
define('PHPVIDEOTOOLKIT_FORMAT_RM', 'rm');
define('PHPVIDEOTOOLKIT_FORMAT_SWF', 'swf');
define('PHPVIDEOTOOLKIT_FORMAT_VOB', 'vob');
define('PHPVIDEOTOOLKIT_FORMAT_WAV', 'wav');
define('PHPVIDEOTOOLKIT_FORMAT_JPG', 'mjpeg');
define('PHPVIDEOTOOLKIT_FORMAT_Y4MP', 'yuv4mpegpipe');
/**
* Size Presets
*/
define('PHPVIDEOTOOLKIT_SIZE_SAS', 'SameAsSource');
define('PHPVIDEOTOOLKIT_SIZE_SQCIF', '128x96');
define('PHPVIDEOTO