一、写在前面
记录FFMpeg PHP使用的点滴,它可以处理音视频(提取图片,进行转码,添加水印,旋转等等),对我们来说是一个强大的轮子。
二、安装步骤
1.添加包依赖,前提是composer已加载。
composer require php-ffmpeg/php-ffmpeg
requires
- php: ^5.3.9 || ^7.0
顺利的话,composer.json里已经有了:
"php-ffmpeg/php-ffmpeg": "^0.14",
2.此时如果使用官方例子来测试的话,可能会报错:Unable to load FFProbe,关于这个问题的讨论可以查看这里,我们需要了解下php-ffmpeg的服务端环境:这里列出了不同系统安装FFmpeg的方法(安装FFmpeg),我们以mac为例,使用brew来安装:
Press Command+Space and type Terminal and press enter/return key.
Run in Terminal app:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
and press enter/return key.
If the screen prompts you to enter a password, please enter your Mac's user password to continue. When you type the password, it won't be displayed on screen, but the system would accept it. So just type your password and press ENTER/RETURN key. Then wait for the command to finish.
Run:
brew install ffmpeg
Done! You can now use <