当前位置: 首页 > 后端技术 > PHP

PHP-FFMpeg安装

时间:2023-03-29 18:59:13 PHP

安装FFMPEGwgethttp://download.bt.cn/install/ext/ffmpeg.sh&&shffmpeg.sh安装完成后可以输入以下命令查看ffmpeg是否安装成功-versiondeletedisablefunctionproc_open,exec,systeminstallPHP-FFMpegcomposerrequirephp-ffmpeg/php-ffmpegFAQExecutablenotfound,proposed:avprobe,ffprobephp-fpm执行FFMPEG时,找不到ffprobe和ffmpeg解决方法如下:command行解通过shell确定文件位置whereisffprobe/usr/local/bin/ffprobewhichffmpeg/usr/local/bin/ffmpeg在初始化时将文件位置写入$ffmpegFFMpeg=FFMpeg::create(['ffmpeg.binaries'=>'/usr/local/bin/ffmpeg','ffprobe.binaries'=>'/usr/local/bin/ffprobe',]);PHP代码直接解决//WriteWWW用户的环境变量putenv('PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:$PATH');//通过exec函数找到文件对应的位置$ffmpeg=FFMpeg::create(['ffmpeg.binaries'=>exec('whichffmpeg'),'ffprobe.binaries'=>exec('whichffprobe'),]);虽然看起来有两种方式,但其实解决方法是一样的,都需要指定ffmpeg和ffprobe文件的位置。理论上直接在服务器上的ffmpeg和ffprobe中添加www用户的环境变量也可以解决这个问题(没有测试,不保证一定有效,有兴趣的可以自行验证)。参考PHP-FFMpegExecutablenotfound,建议:avprobe,ffprobe一键安装ffmpeg命令