How to use php-FFMpeg in laravel 4?

I'm new to Laravel 4. I have installed Laravel php-ffmpeg

in my local setup, but I need help on how to use this ffmpeg with Laravel 4?

+3


source to share


1 answer


Assuming you already have ffmpeg

localhost installed on your server, then in Laravel you need to set paths for ffmpeg and ffprobe binaries like

$ffmpeg = FFMpeg\FFMpeg::create(array(
         'ffmpeg.binaries'  => '/usr/local/Cellar/ffmpeg/2.1.3/bin/ffmpeg', 
         'ffprobe.binaries' => '/usr/local/Cellar/ffmpeg/2.1.3/bin/ffprobe', 
         'timeout'          => 3600, // The timeout for the underlying process
         'ffmpeg.threads'   => 12,   // The number of threads that FFMpeg should use
));

      

Thus, you can:



// set the path of the video file, which you might consider to get the input from the user 
$video = $ffmpeg->open('video.mpg');

// apply filters to resize the clip 
$video
  ->filters()
  ->resize(new FFMpeg\Coordinate\Dimension(320, 240))
  ->synchronize();

// crop a frame from a particular timecode
$video
  ->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(10))
  ->save('frame.jpg');

// transcode clip
$video
  ->save(new FFMpeg\Format\Video\X264(), 'export-x264.mp4');

      

The PHP-FFMpeg documentation has more github examples

0


source







All Articles