如何在laravel 4中使用php-FFMpeg? [英] How can I use php-FFMpeg in laravel 4?
本文介绍了如何在laravel 4中使用php-FFMpeg?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Laravel 4的新手。我已经在我本地的Laravel设置中安装了 php-ffmpeg
,但是我需要如何使用这个ffmpeg和Laravel 4的帮助? / p>
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?
推荐答案
假设您已经在本地服务器上安装了 ffmpeg
在Laravel中,您需要设置 ffmpeg 和 ffprobe 二进制文件的路径,如下所示:
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
));
通过这样做,您可以:
// 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');
PHP-FFMpeg文档中有更多的示例在 github
There are more examples provided in the PHP-FFMpeg documentation on github
这篇关于如何在laravel 4中使用php-FFMpeg?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文