PHP code example of olaferlandsen / ffmpeg-php-class
1. Go to this page and download the library: Download olaferlandsen/ffmpeg-php-class library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
olaferlandsen / ffmpeg-php-class example snippets
$FFmpeg = new FFmpeg;
$FFmpeg->input( '/var/media/original.mp4' )->output( '/var/media/new.3gp' )->ready();
$FFmpeg = new FFmpeg;
$FFmpeg->input( '/var/media/original.mp4' )->frameRate( '30000/1001' )->output( '/var/media/new.3gp' )->ready();
$FFmpeg = new FFmpeg;
$FFmpeg->i( '/var/media/original.mp4' )->r( '30000/1001' )->output( '/var/media/new.3gp' )->ready();
$FFmpeg = new FFmpeg;
$FFmpeg->input( '/var/media/original.mp4' )->transpose( 2 )->output( '/var/media/new.3gp' )->ready();
$FFmpeg = new FFmpeg;
$FFmpeg->input( '/var/media/original.mp4' )->rotate( 2 )->output( '/var/media/new.3gp' )->ready();
$FFmpeg = new FFmpeg;
$FFmpeg->input( '/var/media/original.mp4' )->forceFormat( '3gp' )->output( '/var/media/new.3gp' )->ready();
$FFmpeg = new FFmpeg;
$FFmpeg->input( '/var/media/original.mp4' )->output( '/var/media/new.3gp' , '3gp' )->ready();
$FFmpeg = new FFmpeg;
$FFmpeg->input( '/var/media/original.mp4' )->output( '/var/media/new.3gp' )->command;
$FFmpeg = new FFmpeg;
$FFmpeg->input( '/var/media/original.mp4' )->output( '/var/media/new.3gp' )->ready();
$FFmpeg = new FFmpeg;
$FFmpeg->input( '/var/media/original.mp4' )->grayScale()->output( '/var/media/new.3gp' )->ready();
$key = 'acodec';
$value = 'AAC';
$FFmpeg = new FFmpeg;
$FFmpeg->input( '/var/media/original.mp4' )->set($key,$value)->output( '/var/media/new.3gp' )->ready();
$key = 'acodec';
$FFmpeg = new FFmpeg;
$FFmpeg->input( '/var/media/original.mp4' )->unset($key)->output( '/var/media/new.3gp' )->ready();
$FFmpeg = new FFmpeg;
$FFmpeg->input( '/var/media/original.mp4' )->sameq()->output( '/var/media/new.3gp' )->ready();
$FFmpeg = new FFmpeg;
$FFmpeg->input( '/var/media/original.mp4' )->flip( 'v' )->output( '/var/media/new.3gp' )->ready();
$FFmpeg = new FFmpeg;
$FFmpeg->input( '/var/media/original.mp4' )->hflip()->output( '/var/media/new.3gp' )->ready();
$FFmpeg = new FFmpeg;
$FFmpeg->input( '/var/media/original.mp4' )->vflip()->output( '/var/media/new.3gp' )->ready();
/**
* NAME(DIRNAME(__FILE__)).'/src/ffmpeg.class.php';
/**
* get options from database
**/
$options = array(
'duration' => 99,
'position' => 0,
'itsoffset' => 2,
);
/**
* Create command
*/
$FFmpeg = new FFmpeg( '/usr/local/bin/ffmpeg' );
$FFmpeg->input( '/var/media/original.avi' );
$FFmpeg->transpose( 0 )->vflip()->grayScale()->vcodec('h264')->frameRate('30000/1001');
$FFmpeg->acodec( 'aac' )->audioBitrate( '192k' );
foreach( $options AS $option => $values )
{
$FFmpeg->call( $option , $values );
}
$FFmpeg->output( '/var/media/new.mp4' , 'mp4' );
print($FFmpeg->command);
$FFmpeg = new FFmpeg('/bin/ffmpeg','/var/media/original.mp4')->vflip()->output( '/var/media/new.3gp' )->clear()->input( '/var/www/file.3gp' );
$size = '100x100';
$start = 1;
$frames = 10;
$FFmpeg = new FFmpeg;
$FFmpeg->input( '/var/www/video.mp4' )->thumb( $size , $start, $frames )->ready();
$FFmpeg = new FFmpeg;
$FFmpeg->input( '/var/www/images/pref%04d.png' )->frameRate( '29,97' )->size( '1920x1080' )->force('image2');
$FFmpeg->output( 'image2video.mp4' );
$FFmpeg->ready();
$FFmpeg = new FFmpeg( "C:\ffmpeg\bin\ffmpeg.exe" );
$FFmpeg->input( 'C:\xampp\input.mp4' )->output( 'output.3gp' );
$FFmpeg->ready();
$FFmpeg = new FFmpeg( "/etc/bin/ffmpeg" );
$FFmpeg->input( '/var/www/input.mp4' )->output( 'output.3gp' );
$FFmpeg->ready();
$FFmpeg = new FFmpeg;
$FFmpeg->input( '/var/www/input.mp4' )->loglevel("debug")->output( 'output.3gp' );
$FFmpeg->ready();