我是Laravel 4的新手。我已经在我当地的Laravel设置中安装了php-ffmpeg
,但我需要有关如何在Laravel 4中使用此ffmpeg的帮助?
答案 0 :(得分:0)
假设您已经在本地主机服务器上安装了ffmpeg
,那么在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');
上的PHP-FFMpeg文档中提供了更多示例