Как я могу использовать php-FFMpeg в laravel 4?

Я новичок в Laravel 4. Я установил php-ffmpeg в моей локальной настройке Laravel, но мне нужна помощь, как использовать этот ffmpeg с Laravel 4?

1 ответ

Предполагая, что у вас уже есть 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 на github приведено больше примеров.

Другие вопросы по тегам