如何在php 5.5中使用Cent OS 6.5服务器中的ffmpeg php扩展

我需要从video创build一个截图。

我已经按照本教程在Windows 8,PHP 5.3中进行初始设置。

  1. 我从这里下载了64位操作系统的ffmpeg

  2. 我跟着这个video ,成功完成了所有configuration, phpinfo()显示已经安装了ffmpeg

  3. 然后,我试图找出它是否在工作。 它工作成功。

  4. 接下来,我跟着这个video教程,成功创build缩略图。

以下是我的代码:

 /** * FFMPEG-PHP Test Script * * Special thanks to http://www.sajithmr.me/ffmpeg-sample-code for this code example! * See the tutorial at http://myownhomeserver.com on how to install ffmpeg-php. */ error_reporting(1); error_reporting(E_ALL ^ E_NOTICE); // Check if the ffmpeg-php extension is loaded first extension_loaded('ffmpeg') or die('Error in loading ffmpeg'); // Determine the full path for our video $vid = realpath('./videos/myvideo.mp4'); $videosize = filesize($vid); $remoteVideo = 'http://video-js.zencoder.com/oceans-clip.mp4'; //ffmpeg $ffmpeg = dirname(__FILE__) . "\\ffmpeg\\bin\\ffmpeg"; $imageFile = "1.png"; $image2 = "2.png"; $size = "120x90"; $getfromsecond = 7; $cmd = "$ffmpeg -i $vid -an -ss $getfromsecond -s $size $imageFile"; $cmd2 = "$ffmpeg -i $remoteVideo -an -ss $getfromsecond -s $size $image2"; if(!shell_exec($cmd)){ echo "Thumbnail created"; }else{ echo "Error Creating thumbnail"; } if(!shell_exec($cmd2)){ echo "Thumbnail for remote url was created"; }else{ echo "Error Creating thumbnail for remote url "; } 

输出:

 Thumbnail created Thumbnail for remote url was created 

现在,上面的代码在我的Windows机器上本地运行。 我需要在我的服务器环境(Linux服务器)中使用php 5.5。

如何在CentOS 6.5版服务器上使用php 5.5进行ffmpeg的configuration。

我已经按照这些教程安装在服务器上:

  1. http://supportlobby.com/blog/ffmpeg-installation-on-centos-6-5/

  2. How to Install FFmpeg on Ubuntu 18.04 & 16.04

在控制台中输出:

 [root@BRANDWEB01D ~]# ffmpeg -version ffmpeg version 2.2.1 built on Apr 13 2014 13:00:18 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4) configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --enable-runtime-cpudetect --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --enable-pthreads --enable-x11grab --enable-vdpau --disable-avisynth --enable-frei0r --enable-libopencv --enable-libdc1394 --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --disable-stripping libavutil 52. 66.100 / 52. 66.100 libavcodec 55. 52.102 / 55. 52.102 libavformat 55. 33.100 / 55. 33.100 libavdevice 55. 10.100 / 55. 10.100 libavfilter 4. 2.100 / 4. 2.100 libswscale 2. 5.102 / 2. 5.102 libswresample 0. 18.100 / 0. 18.100 libpostproc 52. 3.100 / 52. 3.100 [root@BRANDWEB01D ~]# which ffmpeg /usr/bin/ffmpeg [root@BRANDWEB01D ~]# ffmpeg -formats ffmpeg version 2.2.1 Copyright (coffee) 2000-2014 the FFmpeg developers built on Apr 13 2014 13:00:18 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4) configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --enable-runtime-cpudetect --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --enable-pthreads --enable-x11grab --enable-vdpau --disable-avisynth --enable-frei0r --enable-libopencv --enable-libdc1394 --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --disable-stripping libavutil 52. 66.100 / 52. 66.100 libavcodec 55. 52.102 / 55. 52.102 libavformat 55. 33.100 / 55. 33.100 libavdevice 55. 10.100 / 55. 10.100 libavfilter 4. 2.100 / 4. 2.100 libswscale 2. 5.102 / 2. 5.102 libswresample 0. 18.100 / 0. 18.100 libpostproc 52. 3.100 / 52. 3.100 File formats: D. = Demuxing supported .E = Muxing supported 

但是,在服务器上,当我打开我的PHP文件,我得到以下错误:

加载ffmpeg时出错

我已经检查phpinfo() ,它显示ffmpeg安装在我的本地,但不是在服务器。

我还需要做什么才能在Cent Os 6.5和php 5.5中启用ffmpeg扩展?