1.环境
centos 7 ffmpeg version 2.8.15 Copyright
2.centos7安装ffmpeg
centos7安装ffmpeg
sudo rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
sudo yum install ffmpeg ffmpeg-devel -y
【Ubuntu安装ffmpeg】
sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next
sudo apt-get update
sudo apt-get install ffmpeg
查看环境变量是否配置成功 ffmpeg -version
3.项目安装ffmpeg包
composer require php-ffmpeg/php-ffmpeg
github链接https://github.com/PHP-FFMpeg/PHP-FFMpeg
4.php代码
<?php
include '../vendor/autoload.php';
use FFMpeg\FFMpeg;
class MyFfmpeg
{
public function run()
{
$file_path = __DIR__ . '/' . uniqid() . '.jpg';
$ffmpeg = FFMpeg::create([
'ffmpeg.binaries' => '/usr/bin/ffmpeg',
'ffprobe.binaries' => '/usr/bin/ffprobe'
]);
$video = $ffmpeg->open('1.mp4');
$video->frame(\FFMpeg\Coordinate\TimeCode::fromSeconds(1))->save($file_path);
}
}
$a = new MyFfmpeg();
$a->run();
|