1 下载链接 http://ffmpeg.org/download.html
2 解压压进入 cd ffmpeg-x.x
4 编译安装 ./configure --enable-shared && make && make install
5 安装完成之后 执行 ffmpeg -version 如图所示 安装成功
ffmpeg version 3.3.9 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-36)
configuration: --enable-shared
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
4 安装ffmpeg-php 官网地址 https://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/
5 进入目录编译安装 ./configure --with-php-config=/usr/local/php/bin/php-config (地址改成自己php的安装目录)
6 make && make install 如果报错 请更换版本
7 php配置文件加入 extension=ffmpeg.so 启这两个函数proc_open,proc_get_status。找到 disable_functions 将里面的这两个函数去掉就行了(坑之所在)
8 重启php。在 phpinfo()中查看有无ffmpeg信息。
开始使用
//执行文件需要绝对路径
$path = [
'ffmpeg.binaries' => '/usr/local/bin/avconv',
'ffmpeg.binaries' => '/usr/local/bin/ffmpeg',
'ffprobe.binaries' => '/usr/local/bin/avprobe',
'ffprobe.binaries' => '/usr/local/bin/ffprobe',
];
$ffmpeg = FFMpeg::create($path);
$video = $ffmpeg->open($data['g_video']);
// 截取第二帧的图片
$frame = $video->frame(TimeCode::fromSeconds(2));
$str = rand(1111111,9999999).time();
$frame->save('upload/tumb/'.$str.'.jpg');
$data['g_img'] = config('set.http').'/upload/tumb/'.$str.'.jpg';
更多视频视频处理 http://www.4u4v.net/shi-yong-php-ffmpeg-cao-zuo-shi-pin-yin-pin-wen-jian.html