Warning: file_get_contents() [function.file-get-contents]: SSL: fatal protocol error in /home/sandbox/public_html/convert/examples/index.php on line 33
Warning: strpos() [function.strpos]: Offset not contained in string. in /home/sandbox/public_html/convert/examples/index.php on line 50
PHPVideoToolkit, © Oliver Lillie 2012
PHPVideoToolkit © Oliver Lillie, 2008
1. About & Current Version
2. Most Recent Changes
3. Installation
4. Support & Feedback
5. Examples
6. License
7. Changes
About & Current Version
The version of PHPVideoToolkit you currently have is "0.1.5".
Your current version is up to date.
This class is a wrapper around the FFmpeg, FLVTools2 and Mencoder programs to allow PHP developers to manipulate and convert video files in any easy to use object oriented way. It also currently provides FFmpeg-PHP emulation in pure PHP so you wouldn't need to compile and install the module. Note, it isn't intended as a FFmpeg-PHP replacement, only an alternative solution and it is recommended that if you make heavy use of the FFmpeg-PHP functionality you should install the module as it is more efficient.
PHPVideoToolkit is pretty much the only video/audio class that you will need from now on. It performs several types of manipulation operations that include video format conversion, extract video frames into separate image files, assemble a video stream from a set of separate video images, extract audio from video, watermark videos and extracted frames. Several parameters can also be configured like the output video file format (which can be Flash video or any other supported by ffmpeg), video and audio bit rate and sample rate, video dimensions and aspect ratio. It can also retrieve information about the media file, such as duration, bitrate, framerate, format, dimensions, display aspect ratio, pixel aspect ratio, audio stereo, audio frequency and audio format, without any other additional library such as ffmpeg-php.
The home of PHPVideoToolkit is located at Sourceforge. Whilst I will make every effort to update the files at every location it is updated you should always check the Sourceforge repository for the latest version.
http://sourceforge.net/projects/phpvideotoolkit/
↑ Back to top
Most Recent Changes
[0.1.5] [06.06.2008]
- REMOVED dependancy on buffering the exec calls to a file, parsing the file and
then unlinking the file. Cuts down considerably of the impact of the class on
the server. Thanks Varon. http://www.buggedcom.co.uk/discuss/viewtopic.php?id=10
- FIXED check for liblamemp3 audio format problem.
- UPDATED example/index.php to correctly get the current release version, and
remove the php notices.
- UPDATED PHPVideoToolkit::getFileInfo() and PHPVideoToolkit::getFFmpegInfo() so
they can now be called statically.
- UPDATED example06.php to have the media embedded in the example.
- BUNDLED the Javascript PluginObject package with PHPVideoToolkit. It is an
end-all solution to embedding browser based plugins via javascript. It is
distributed under a BSD License. The full package can be downloaded from:
http://sourceforge.net/project/showfiles.php?group_id=223120
↑ Back to top
Installation
If you already have FFmpeg, and optionally FLVTools2 and Mencoder installed on your server then you will not have to install anything. However if you do not have these binaries then please read the following help file. Please be aware that I will not answer support requests for helping in installing FFmpeg or the other binaries as there is much information on the internet. If you are really stuck hire someone to do it, ie at rent-a-coder etc.
↑ Back to top
Support & Feedback
I am currently redesigning the website and ask that all bug reports go through the SourceForge forums/issue trackers. However you may post support or help requests in the PHP Video Toolkit Forum.
↑ Back to top
Examples
I have compiled a great number of examples to show you how to use PHPVideoToolkit. You can find links to the demo files and brief explanations about each below.
Please be sure to edit the example-config.php file located in the examples folder.
- Example 1, This example will show you how to quickly transcode a video into the commonly used Flash Video (FLV) format.
- Example 2, This will show you how to extract a series of frame grabs from a video source.
- Example 3, This shows you how to compile a movie from a series of images.
- Example 4, This will show you how to watermark videos if your FFmpeg binary has been compiled with --enable-vhook. It will also show you how to watermark a frame grab.
- Example 5, This will display metadata information about the audio or video files without the need for having installed FFmpeg-PHP.
- Example 6, This will show you how to extract audio from a video.
- Example 7, This will show you how to join multiple videos together. (not currently complete)
- Example 8, This example utilizes the PHPVideoToolkit 'VideoTo' adapter class, to show you how to quickly and simply convert video to some predetermined common formats.
- Example 9, This will show you how to access information about your FFmpeg binary.
- Example 10, This will demonstrate how to extract a specific frame from video.
- Example 11, This example utilizes the PHPVideoToolkit 'FFmpeg-PHP' adapters. It will demonstrate that it is possible to run an application/script without having to install the FFMmpeg-PHP module as the adapter classes provide a pure PHP based emulation of the module. Please note that these adapter classes require other libraries, getID3 and GifEncoder, which for convenience, have both been bundled (only with the SourceForge downloads, PHPClasses users will still have to download these packages or download the main package here) with the PHPVideoToolkit package. Note, both of the required libraries are subject to different licenses than that of PHPVideoToolkit.
- Example 12, Shows you how you can simply and easily manipulate timecode strings to get them into whatever format you desire.
- Example 13, This demonstrates how to simply create a FLV stream script.
↑ Back to top
License
The PHPVideoToolkit class, the VideoTo adapter class, the Toolkit adapter classes, the FFmpeg-PHP adapter classes and all associated examples are subject to the BSD style license laid out below.
PHPVideoToolkit 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.
↑ Back to top
Changes[0.1.5] [06.06.2008]
- REMOVED dependancy on buffering the exec calls to a file, parsing the file and
then unlinking the file. Cuts down considerably of the impact of the class on
the server. Thanks Varon. http://www.buggedcom.co.uk/discuss/viewtopic.php?id=10
- FIXED check for liblamemp3 audio format problem.
- UPDATED example/index.php to correctly get the current release version, and
remove the php notices.
- UPDATED PHPVideoToolkit::getFileInfo() and PHPVideoToolkit::getFFmpegInfo() so
they can now be called statically.
- UPDATED example06.php to have the media embedded in the example.
- BUNDLED the Javascript PluginObject package with PHPVideoToolkit. It is an
end-all solution to embedding browser based plugins via javascript. It is
distributed under a BSD License. The full package can be downloaded from:
http://sourceforge.net/project/showfiles.php?group_id=223120
[0.1.4] [10.04.2008]
- ADDED phpvideotoolkit.php4.php and renamed the php5 class
phpvideotoolkit.php5.php, however the adapter classes will remain php5 only
for the time being. Allow the adapters are php5 it would be very simple for
someone to convert them to php4. IF you do let me know and i'll include them
in the distribution.
- FIXED PHP Notice errors, googlecode issue #1, Thanks Rob Coenen.
- DEPRECIATED setVideoOutputDimensions for setVideoDimensions
- ADDED PHPVideoToolkit::flvStreamSeek() which acts as a php stream proxy for
flash flv files, can also limit bandwidth speed. See example13.php for more info.
- ADDED example13.php to demo how to use the new flv seeking function flvStreamSeek()
- DEPRECIATED setAudioFormat for setAudioCodec. setAudioFormat will be removed in
version 0.2.0
- DEPRECIATED setVideoFormat for setVideoCodec. setVideoFormat will be removed in
version 0.2.0
- REMOVED dependancy of the ffmpeg-PHP adapter on the getID3 library as is
incompatible with the BSD license. Now integrated with php-reader
http://code.google.com/p/php-reader/ which is licensed under a New BSD license.
[0.1.3] [04.04.2008]
- RENAMED primary class to PHPVideoToolkit to avoid any confusion with
ffmpeg-php
- THANKS to Istvan Szakacs, and Rob Coenen for providing some valuable feedback,
bug fixes and code contributions.
- ADDED note to example11.php to warn windows users about getID3's
helper files.
- ADDED example12.php which shows how to manipulate timecodes.
- CHANGED the behaviour of extractFrames and extractFrame to allow you
to specify specific frames and enter different types of timecodes as
params using the new $timecode_format argument.
- ADDED value PHPVideoToolkit::getFFmpegInfo()['ffmpeg-php-support']; Values are
- 'module' = ffmpeg-php is installed as a php module
- 'emulated' = ffmpeg-php is supported through the VideoToolkit adapter
classes (supplied with this package)
- false = ffmpeg-php is not supported in any way.
- ADDED PHPVideoToolkit::hasFFmpegPHPSupport() returns one of the values above,
dictating if ffmpeg-php is supported.
- ADDED PHPVideoToolkit::getFFmpegInfo()['compiler']['vhook-support'] that determines
if vhook support has been compiled into the ffmpeg binary.
- ADDED PHPVideoToolkit::hasVHookSupport() returns a boolean value to determine
if vhook support is enabled in the ffmpeg binary.
- FIXED path include bug in example08.php
- ADDED frame existence check to extractFrame and extractFrames, thanks to
Istvan Szakacs for suggesting the idea.
- ADDED an extra param to PHPVideoToolkit::setInputFile() and
PHPVideoToolkit::prepareImagesForConversion(), $input_frame_rate. by default it is
0 which means no input frame rate is set, if you set it to false for
setInputFile then the frame rate will retrieved, otherwise the input
frame rate will be set to whatever integer is set.
- ADDED frame_count to the duration field of the getFileInfo array.
- ADDED check for --enable-liblamemp3 which requires a different codec for
setting the audio format as mp3.
- ADDED width and height check in setVideoOutputDimensions, as apparently
the output dimensions have to be even numbers.
- REMOVED call-by-pass-time-reference dependance from _postProcess()
- ADDED vhook check to PHPVideoToolkit::addWatermark(), returns false if vhook is not
enabled.
- ADDED PHPVideoToolkit::addGDWatermark() to allow GD watermarking of outputted images.
- CHANGED the functionality of example04.php to show usage of addGDWatermark
if vhooking is not enabled.
[0.1.2] [03.04.2008]
- FIXED bug in PHPVideoToolkit::getFileInfo() that in some instances didn't return
the correct information, such as dimensions and frame rate. Thanks to
Istvan Szakacs for pointing out the error.
- CHANGED the way an image sequence is outputted. %d within the naming
of the output files is now for internal use only.
%index - is the old %d and it also accepts numerical padding.
%timecode - is the pattern for hh-mm-ss-fn, where fn is the frame
number.
- UPDATED example02.php to reflect the changes above.
- ADDED ffmpeg-php adapters to provide a pure PHP implementation of the
ffmpeg-php module.
- ADDED getID3 to the distribution.
- @link http://getid3.sourceforge.net/
- @author James Heinrich (et al)
- @license GPL and gCL (getID3 Commerical License).
- ADDED GifEncoder to the distribution.
@link http://www.phpclasses.org/browse/package/3163.html
@link http://phpclasses.gifs.hu/show.php?src=GIFEncoder.class.php
@author László Zsidi
@license Freeware.
- ADDED example11.php, example12.php to demonstrate the ffmpeg-php
adapters.
- CHANGED PHPVideoToolkit::getFileInfo()['audio']['frequency'] to
PHPVideoToolkit::getFileInfo()['audio']['sample_rate']
- CHANGED PHPVideoToolkit::getFileInfo()['audio']['format'] to
PHPVideoToolkit::getFileInfo()['audio']['codec']
- CHANGED PHPVideoToolkit::getFileInfo()['video']['format'] to
PHPVideoToolkit::getFileInfo()['video']['codec']
- ADDED PHPVideoToolkit::getFileInfo()['video']['pixel_format']
- ADDED PHPVideoToolkit::getFileInfo()['_raw_info'] which is the raw buffer output
- ADDED PHPVideoToolkit::getFileInfo()['duration']['start'] (re-added)
- UPDATED PHPVideoToolkit::extractFrame so in some instances it will be less cpu
intensive.
- UPDATED PHPVideoToolkit::_combineCommands so commands can be ordered in the exec
string.
[0.1.1] [29.03.2008]
- FIXED bug in the post processing of exporting a series of image frames.
With thanks to Rob Coenen.
- FIXED bug in PHPVideoToolkit::getFileInfo() that returned the incorrect frame
rate of videos.
- CHANGED functionality of PHPVideoToolkit::extractFrame(), to export a specific
frame based on the frame number, not just the hours, mins, secs timecode
- FIXED bug in ffmpeg.example9.php where the gif was incorrectly named.
- CHANGED functionality of PHPVideoToolkit::getFileInfo(), reorganised the way the
duration data is returned.
- CHANGED functionality of PHPVideoToolkit::getFileInfo(), so the timecode with
frame numbers instead of milliseconds is also returned in the value
duration.timecode.frames.exact, however this value is only available to
video files.
- REMOVED duration.start from the information returned by
PHPVideoToolkit::getFileInfo()
- CHANGED PHPVideoToolkit::$image_output_timecode's default value to true/
- ADDED PHPVideoToolkit::registerPostProcess() to provide a way to automate
callbacks docs so you can hook into post processing of the ffmpeg
output. See function for more info.
- CHANGED the way PHPVideoToolkit::setFormatToFLV() adds the meta data to the flv.
It now uses PHPVideoToolkit::registerPostProcess() to create a callback.
- FIXED average time mistakes in examples.
- FIXED overwrite mistakes in examples (it was set to true so the
overwrite mode defaulted to PHPVideoToolkit::OVERWRITE_EXISTING)
- ADDED internal caching of PHPVideoToolkit::getFileInfo(); so if the data is asked
to be generated more than one in the same script it only gets generated
once.
[0.1.0] [02.03.2008]
- ADDED new constant PHPVideoToolkit::SIZE_SAS. Which stands for Same As Source,
meaning ffmpeg will automatically convert the movie to a whatever format
but preserve the size of the original movie.
- CORRECTED error/comment spelling mistakes.
- CHANGED PHPVideoToolkit::getFileInfo(); to use preg_match so it's more reliable,
it also contains more information on the file.
- ADDED public function setVideoAspectRatio. Sets the video aspect ratio.
Takes one of three constants as an argument. PHPVideoToolkit::RATIO_STANDARD,
PHPVideoToolkit::RATIO_WIDE, PHPVideoToolkit::RATIO_CINEMATIC
- ADDED public function setVideoBitRate. Sets the video bitrate.
- ADDED public function setVideoFormat. Sets a video codec. It should not
be confused with PHPVideoToolkit::setFormat. It provides slightly different
advanced functionality, most simple usage can just use PHPVideoToolkit::setFormat
- ADDED public function setAudioFormat. Sets an audio codec.
- ADDED public function setConstantQuality. Sets a constant encoding
quality.
- ADDED public function getFFmpegInfo. Gets the available data from ffmpeg
and stores the output in PHPVideoToolkit::$ffmpeg_info (below).
- ADDED PHPVideoToolkit::$ffmpeg_info static var to hold the output of
PHPVideoToolkit::getFFmpegInfo();
- ADDED public function getLastProcessTime and getProcessTime to retrieve
the processing times of the ffmpeg calls.
- ADDED adapter classes to provide simple functionality for ffmpeg newbies
/ quick solutions. Each option set can be supplied in the second
argument as part of an array.
VideoTo::PSP(); - Converts video into the PSP mp4 video.
VideoTo::iPod(); - Converts video into the iPod mp4 video.
VideoTo::FLV(); - Converts video into the Flash video (flv).
VideoTo::Gif(); - Converts video into the animated gif.
(experimental as quality is poor)
- CHANGED the way the processing works. The file is processed to the
temp directory and is then checked for consistency before moving to
the output directory.
- CHANGED the return values of PHPVideoToolkit::execute(); It no longer returns
just true or false. See class docs for more info.
- CHANGED the third argument in PHPVideoToolkit::setOutput() from $overwrite to
$overwrite_mode. Instead of a boolean value, it now takes one of three
constants
ffmegp::OVERWRITE_FAIL - means that if a conflict exists the
process will result in and error.
ffmegp::OVERWRITE_PRESERVE - means that if a conflict exists the
process will preserve the existing
file and report with
PHPVideoToolkit::RESULT_OK_BUT_UNWRITABLE.
ffmegp::OVERWRITE_EXISTING - means that if a conflict exists the
process will overwrite any existing
file with the new file.
ffmegp::OVERWRITE_UNIQUE - means that every filename is
prepended with a unique hash to
preserve the existing filesystem.
- MOVED error messages into a class variable for easier
translation/changes.
- CHANGED moveLog functionality to use rename instead of copy and unlink.
[0.0.9] [12.02.2008]
- Added new definition FFMPEG_MENCODER_BINARY to point to the mencoder
binary.
- Changed the behavior of setVideoOutputDimensions. it now accepts class
constants as preset sizes.
- Added public function adjustVolume. Sets the audio volume.
- Added public function extractAudio. Extracts audio from video.
- Added public function disableAudio. Disables audio encoding.
- Added public function getFileInfo. Access information about the media
file.
Without using ffmpeg-php as it queries the binary directly.
- Added 2 arguments to excecute.
argument 1 - $multi_pass_encode (boolean). Determines if ffmpeg should
multipass encode. Can result in a better quality encode.
default false
argument 2 - $log (boolean). Determines if the output of the query to
the ffmpeg binary is logged. Note, any log file created
is destroyed unless moved with PHPVideoToolkit::moveLog upon
destruct of the ffmpeg instance or on PHPVideoToolkit::reset.
default false
- Added public function moveLog. Moves a log file.
- Added public function readLog. Reads a log file and returns the data.
- Changed external format definitions to internal class constants.
- Changed external use high quality join flag to internal class constant.
- Fixed bug in setFormat error message.
- Fixed bug in execute.
[0.0.8] [07.08.2007]
- Added public functions secondsToTimecode & timecodeToSeconds. Translates
seconds into a timecode and visa versa.
ie. 82 => 00:01:22 & 00:01:22 => 82
- Added public var image_output_timecode. Determines if any outputted
frames are re-stamped with the frames timecode if true.
- Fixed bug in setOutput.
[0.0.7] [01.08.2007]
- Added FFMPEG_FORMAT_Y4MP format (yuv4mpegpipe).
- Added extra information to install.txt
- Added public function hasCommand.
- Added public functions addVideo, addVideos
- Changed the behavior of setInputFile to take into account the addVideos
function. It now can take multiple input files for joining as well as
the high quality join flag 'FFMPEG_USE_HQ_JOIN'.
- Changed the behavior of setOutput. If the $output_name has a common
image extension then and no %d is found then an error is raised.
- Changed all booleans from upper to lower case.
[0.0.5] [12.03.2007]
- Added FFMPEG_FORMAT_JPG format (mjpeg). Thanks Matthias.
- Changed the behavior of extractFrames. It now accepts a boolean FALSE
argument for $extract_end_timecode.
If it is given then all frames are exported from the timecode specified
by $extract_begin_timecode. Thanks Matthias.
- Added extra definition 'FFMPEG_WATERMARK_VHOOK' for the path to the
watermark vhook.
- Added watermark support for both frames exports and videos. (Note: this
makes specific useage of vhook. If your ffmpeg binary has not been
compiled with --enable-vhook then this will not work.
[0.0.1] [02.03.2007]
- Initial version released
/* SVN FILE: $Id$ */
↑ Back to top