Created: 16/10/2010
By: Abhijith Babu
Email: Abhijithbabu@gmail.com
Examples
<?php
// include class
include ("class/ffmpeg.class.php");
// instantiate
$ffmpegultimate = new FfmpegUltimate ();
?>
Make a fast forwarded preview of the video.
For example If you need a 20 second fast forwarded preview of video,This method can create an output video which is whole video fast forwarded to fit in 20 seconds.
You can supply input file location,Output folder location,Output filename,Duration of preview needed in seconds,Dimension of preview needed
<?php
include ("class/ffmpeg.class.php");
$ffmpegultimate = new FfmpegUltimate ();
$output = $ffmpegultimate->makeFastPreview ( "input/input.mp4", "output/", "full_preview.flv", 20, "160*120");
?>
Cut a part of video or audio.
For example if you want to cut a video or audio from 20th second onwards to 3rd minute,you can use this method.
You can supply input file location,Output folder location,Output filename,Start time of preview in seconds(hh:mm:ss[.xxx] is also supported),Duration of cut in seconds
<?php
include ("class/ffmpeg.class.php");
$ffmpegultimate = new FfmpegUltimate ();
$output = $ffmpegultimate->cutFile ( "input/input.mp4", "output/", "cut_video.flv", 0, 10 );
?>
Extract an image from any part of video in any dimension.
You can supply input file location,Output folder location,Output filename,Time in video to take picture (hh:mm:ss[.xxx] is also supported),Dimension of picture needed
<?php
include ("class/ffmpeg.class.php");
$ffmpegultimate = new FfmpegUltimate ();
$output = $ffmpegultimate->previewThumb ( "input/input.mp4", "output/", "output.jpg", 1, "160*120" );
?>
Convert A File From One Format To Another Format.Examples conversions are MP4 to FLV,FLV to MP4,MP4 to MP3,MP4 to AVI,AVI to MP4,WAV to MP3,AVI to FLV.
You can supply input file location,Output folder location,Output filename,And Format of output
<?php
include ("class/ffmpeg.class.php");
$ffmpegultimate = new FfmpegUltimate ();
$output = $ffmpegultimate->convertFile ( "input/input.mp4", "output/", "output_flv.flv", "flv" );// mp4 to flv
/*where input/input.mp4 is the input file,output/ is the output folder path
,output_flv.flv is the name of output file ,flv is the format to convert to*/
$output = $ffmpegultimate->convertFile ( "input/input.mp4", "output/", "output_mp3.mp3", "mp3" );// mp4 to mp3
/*where input/input.mp4 is the input file,output/ is the output folder path
,output_mp3.mp3 is the name of output file ,mp3 is the format to convert to*/
$output = $ffmpegultimate->convertFile ( "input/input_flv.flv", "output/", "output_mp4.mp4", "mp4" );// flv to mp4
/*where input/input_flv.flv is the input file,output/ is the output folder path
,output_mp4.mp4"is the name of output file ,mp4 is the format to convert to*/
$output = $ffmpegultimate->convertFile ( "input/input.mp4", "output/", "output_avi.avi", "avi" );// mp4 to avi
/*where input/input.mp4 is the input file,output/ is the output folder path
,output_avi.avi is the name of output file ,avi is the format to convert to*/
$output = $ffmpegultimate->convertFile ( "input/BusyTone.wav", "output/", "output_wavmp3.mp3", "mp3" );// wav to mp3
/*where input/BusyTone.wav is the input file,output/ is the output folder path
,output_wavmp3.mp3 is the name of output file ,mp3 is the format to convert to*/
?>
Add Audio File To A Video File.This will mix the audio to video file
You can supply input video file location,input audio file location,Output folder location,Output filename
<?php
include ("class/ffmpeg.class.php");
$ffmpegultimate = new FfmpegUltimate ();
$output = $ffmpegultimate->mixAudio ( "input/inputavi.avi", "input/killiye.mp3", "output/", "output_mixed.avi" );
?>
Join Two Videos,that is one video after another another
You can supply input video file location,input second video file location,Output folder location,Output filename
<?php
include ("class/ffmpeg.class.php");
$ffmpegultimate = new FfmpegUltimate ();
$output = $ffmpegultimate->appendVideo ( "input/inputavi.avi", "input/inputavi.avi", "output/", "output_joined.avi" );
?>
Get Information Of A File like bitrate, duration,video height, video width,audio hz,audio channels,file size
You can supply input file location.Output is an array with all information
<?php
include ("class/ffmpeg.class.php");
$ffmpegultimate = new FfmpegUltimate ();
$output = $ffmpegultimate->fileGetInfo ( "input/inputavi.avi" );
print_r ( $output );
?>
Remove a directory and its contents OR just the contents preserving the directory
You can supply folder name to delete and true if delete directory too false if just delete it contents
<?php
include ("class/ffmpeg.class.php");
$ffmpegultimate = new FfmpegUltimate ();
$output = $ffmpegultimate->removeDirConfirm ( "images", true );
print_r ( $output );
?>
Class Methods
Make fast forwarded preview of the video.The whole video will be fastforwarded to fit in supplied duration
The method needs 5inputs
a)input-which is the input file path
b)outfolder-which is the output folder path
c)outputname-which is the name of the outputname you want
d)wanted_time-time of preview in seconds
e)dimension-dimension of preview example 160*120
This method cuts a part of video or audio provided.
For example if you need to cut a part of video from 20th second onwards ,you can input start time 00:00:20 and duration to which cut to extend
The method needs 5 inputs
a)input-which is the input file path
b)outfolder-which is the output folder path
c)outputname-which is the name of the outputname you want
d)starttime- start time of cut (hh:mm:ss[.xxx] is also supported)
e) duration -duration of cut video
This methods helps you to take a picture from any part of video.
For example if you want a 640x480 image taken from 20th second you can input 00:00:20 for time and 640x480 for dimension
The method needs 5 inputs
a)input-which is the input file path
b)outfolder-which is the output folder path
c)outputname-which is the name of the outputname you want
d)time- time where image is to be taken(hh:mm:ss[.xxx] is also supported)
e)dimension- dimension of image
This methods helps you to convert video or audio from one format to another
Examples conversions are MP4 to FLV,FLV to MP4,MP4 to MP3,MP4 to AVI,AVI to MP4,WAV to MP3,AVI to FLV
The method needs 4 inputsa)input-which is the input file path
b)outfolder-which is the output folder path
c)outputname-which is the name of the outputname you want
d)format- format of output
This method helps you to add an audio file into a video file.It will mix audio file into video file
The method needs 4 inputs
a)input-which is the input video file path
b)input_audio-which is the input audio file path
c)outfolder-which is the output folder path
d)outputname-which is the name of the outputname you want
This method helps to join two videos one after the other
The method needs 4 inputs
a)input-which is the input video file path
b)input_second-which is the second input file path
c)outfolder-which is the output folder path
d)outputname-which is the name of the outputname you want
This method outputs an array with all information about a video or audio like bitrate, duration,video height, video width,audio hz,audio channels,file size
The method needs 1 inputs ,output is an array
a)input-which is the input file path
This function helps you to remove a directory.You can either remove directory and its contents OR just the contents preserving the directory
The method needs 2 inputs
a)dir-which is the input file path
b)deleteme-delete folder or not
Included Files And Folders
This is main ffmpeg ultimate class.You must include the class and instantiate class to call any methods
<?php
// include class
include ("class/ffmpeg.class.php");
// instantiate
$ffmpegultimate = new FfmpegUltimate ();
?>
This folder is used by example.php file
This folder is used by example.php file
Shows Sample usage
This is the documenation and assets used by documentation
Requirements
The code needs ffmpeg installed on server.Also please chmod your output folder with required permission to read and write