我是 Laravel 4 的新手。我已经安装php-ffmpeg
在本地 Laravel 设置中,但是我需要有关如何将此 ffmpeg 与 Laravel 4 一起使用的帮助?
问问题
3555 次
1 回答
0
假设您已经ffmpeg
在 localhost 服务器上安装了,那么在 Laravel 中,您需要设置ffmpeg和ffprobe二进制文件的路径,如下所示:
$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
));
通过这样做,您可以:
// 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');
github上的 PHP-FFMpeg 文档中提供了更多示例
于 2014-11-28T16:54:30.480 回答