【问题标题】:How can I use php-FFMpeg in laravel 4?如何在 laravel 4 中使用 php-FFMpeg?
【发布时间】:2015-01-06 10:08:16
【问题描述】:

我是 Laravel 4 的新手。我在本地 Laravel 设置中安装了 php-ffmpeg,但我需要有关如何将此 ffmpeg 与 Laravel 4 一起使用的帮助?

【问题讨论】:

  • 感谢您的回复。如果你知道的话,请告诉我如何使用。
  • 现在自己解决了这个问题。我找到了这个命令,并用命令给出了路径。谢谢
  • 如果您添加解决方案作为答案并接受它会很好

标签: php laravel-4 ffmpeg ffmpeg-php


【解决方案1】:

假设你已经在 localhost 服务器上安装了ffmpeg,那么在 Laravel 中,你需要设置 ffmpegffprobe 二进制文件的路径,像这样:

$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 文档中提供了更多示例

【讨论】:

    猜你喜欢
    • 2018-10-20
    • 2013-02-23
    • 1970-01-01
    • 2013-06-15
    • 2012-01-16
    • 2013-07-05
    • 1970-01-01
    • 2021-01-10
    • 2012-12-25
    相关资源
    最近更新 更多