FFMPEG Ulitmate Documentation by Abhijith Babu v1.0


FFMPEG Ultimate

Created: 16/10/2010
By: Abhijith Babu
Email: Abhijithbabu@gmail.com

Thank you for purchasing my code. If you have any questions that are beyond the scope of this help file, please feel free to email me. Thanks so much!


Examples

  1. Make Fast Forward Preview
  2. Cut A Part Of Video/Audio
  3. Take a picture from video
  4. Convert File From One Format To Another
  5. Add Audio To A Video
  6. Join Two Videos
  7. Get Information Of A File
  8. Remove a directory Completely Or Just It Contents

Class Methods

  1. makeFastPreview
  2. cutFile
  3. previewThumb
  4. convertFile
  5. mixAudio
  6. appendVideo
  7. fileGetInfo
  8. removeDirConfirm

Included Files And Folders

  1. class/ffmpeg.class.php
  2. input folder
  3. output folder
  4. example.php
  5. documentation.html and documentation_files folder

Requirements

  1. FFMPEG And Write Permission

Examples


FFMPEG Class must be included and instantiated before you can use any methods.Below code shows how to do it
<?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");
?> 
where input/input.mp4 is the input file,output/ is the output folder path,full_preview.flv is the name of output file,20 time of preview in seconds,160*120 is dimension of output file

B.Cut A Part Of Video/Audio

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"010 );
?> 
where input/input.mp4 is the input file,output/ is the output folder path,cut_video.flv is the name of output file,0 is start time (hh:mm:ss[.xxx] is also supported), 10 duration of cut in seconds

C.Take a picture from video

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" );
?> 
where input/input.mp4 is the input file,output/ is the output folder path,output.jpg is the name of output file,1 is time to take snap(hh:mm:ss[.xxx] is also supported), 160*120 is dimension of output image

D.Convert File From One Format To Another

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*/
?> 

E.Add Audio To A Video

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" );
?> 
where input/input.avi is the input file,input/killiye.mp3 is audio file,output/is the output folder path,output_mixed.avi is the name of output file

F.Join Two Videos

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" );
?> 
where input/input.avi is the input file,input/inputavi.avi is second file,output/ is the output folder path,output_joined.avi is the name of output file

G.Get Information Of A File

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 );
?> 
where iinput/inputavi.avi is the input file

H.Remove a directory Completely Or Just It Contents

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 );
?> 
where images is the directory to delete


Class Methods


A.makeFastPreview

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

B.cutFile

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

C.previewThumb

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

D.convertFile

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 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)format- format of output

E.mixAudio

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

F.appendVideo

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

G.fileGetInfo

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

 

H.removeDirConfirm

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


  1. class/ffmpeg.class.php
  2. 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 ();
    ?> 
  3. input folder
  4. This folder is used by example.php file

  5. output folder
  6. This folder is used by example.php file

  7. example.php
  8. Shows Sample usage

  9. documentation.html and documentation_files folder
  10. 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


Go To Table of Contents