- 安装 ffmpeg
- ffmpeg的下载链接 http://ffmpeg.org/download.html
- 解压安装包
- tar -jxvf ffmpeg-x.x.tar.bz2
到这里就报错了
报错:file: file:///etc/yum.repos.d/dag.repo, line: 1
参考https://xiaojingjing.iteye.com/blog/2393165
rm -f /etc/yum.repos.d/CentOS-Base.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
最后我把dag.repo删了,
报错:
安装ffmpeg过程中,执行./configure时,报yasm/nasm not found or too old. Use --disable-yasm for a crippledbuild错误,分析、解决如下:
分析:yasm是汇编编译器,ffmpeg为了提高效率使用了汇编指令,如MMX和SSE等。所以系统中未安装yasm时,就会报上面错误。
解决:安装yasm编译器。安装方法如下:
在http://www.tortall.net/projects/yasm/releases下面找到适合自己平台的yasm版本。然后进行安装。举例如下:
1)下载:wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
2)解压:tar zxvf yasm-1.3.0.tar.gz
3)切换路径: cd yasm-1.3.0
4)执行配置: ./configure
5)编译:make
6)安装:make install
原文:https://blog.csdn.net/yzhang6_10/article/details/75635734
接着安装ffmpeg
进入目录
cd ffmpeg-x.x
编译安装
./configure --enable-shared && make && make install
又报错
ffmpeg: error while loading shared libraries: libavdevice.so.58: cannot open shared object file: No
解决办法:
vi /etc/ld.so.conf
第一种:加入:/usr/local/lib
第二种先 find / -name libavdevice.so.56 得到该文件的目录地址,
然后 vim /etc/ld.so.conf 将上述目录添加到最后一行并保存退出;
执行ldconfig
总算搞定
安装完成之后 执行 ffmpeg -version
[root@iZbp1esy3n96esf69makhbZ ffmpeg-4.1]# ffmpeg -version
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-28)
configuration: --enable-shared
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
[root@iZbp1esy3n96esf69makhbZ ffmpeg-4.1]#
yum -y install zip unzip
# unzip ffmpeg-php.zip
进入目录
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
到这一步出错了我。。。。
注意(如果make之后出现错误,那就是ffmpeg-php版本的问题,别再折腾了,换版本吧(或者降低php版本试试))。
在php的配置文件 php.ini中 添加
1 |
|
重启php。在 phpinfo()中查看有无ffmpeg信息。
有的话就OK
ffmpeg-php没安装成功,不影响使用
//这里的路径是对服务器的绝对路径 $input='/usr/local/nginx/html/xshoph/Data/UploadFiles/audio/20190110/5c36a9220522a.mp4'; $output='/usr/local/nginx/html/xshoph/Data/UploadFiles/123.jpg'; echo "Converting $input to $output<br />"; $command = "ffmpeg -v 0 -y -i $input -vframes 1 -ss 5 -vcodec mjpeg -f rawvideo -s 286x160 -aspect 16:9 $output "; echo "$command<br />"; shell_exec( $command ); echo "Converted<br />";