How can I use php-FFMpeg in laravel 4?

你。 提交于 2019-12-10 17:48:38

问题


I am new to Laravel 4. I have installed php-ffmpeg in my local Laravel setup, but I need help on how to use this ffmpeg with Laravel 4?


回答1:


Assuming that you already have ffmpeg installed on your localhost server, then in Laravel, you need to set the paths for the ffmpeg and ffprobe binaries, like so:

$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
));

By doing so, then 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');

There are more examples provided in the PHP-FFMpeg documentation on github



来源:https://stackoverflow.com/questions/26838135/how-can-i-use-php-ffmpeg-in-laravel-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!