【问题标题】:How to setup ffmpeg for CentOS release 6.5 server如何为 CentOS 6.5 版服务器设置 ffmpeg
【发布时间】:2015-01-29 07:50:09
【问题描述】:

我需要从视频中创建一个屏幕截图,

我已按照this 教程在窗口 8,php 5.3 中进行初始设置

1) 我从这里下载了 ffmpeg -[ http://ffmpeg.zeranoe.com/builds/ ] 用于 64 位操作系统。

2)我按照https://www.youtube.com/watch?v=gU49GiWGGAI的视频,所有配置都成功了,phpinfo()显示ffmpeg已经安装好了。

3) 然后我尝试this 看看它是否有效,

成功了

4) 接下来我跟着这个视频教程here 并成功创建了缩略图。

下面是我的代码

/**
 * 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 ";
}

  OUTPUT
    Thumbnail created
    Thumbnail for remote url was created

现在上面的代码在我的本地窗口机器中按预期工作,我需要在我的服务器环境(Linux 服务器)中使用 php 5.5 进行。如何在 CentOS 6.5 版服务器中使用 php 5.5 配置 ffmpeg。

我已按照本教程将其安装在服务器中

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

2.http://tecadmin.net/install-ffmpeg-on-linux/

控制台输出

[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 文件时,我收到此错误 Error in loading ffmpeg

我还检查了 phpinfo(),它显示 ffmpeg 安装在我的本地但未安装在服务器中。

在 Cent Os 6.5 php 5.5 中配置 ffmpeg 还需要做什么。

【问题讨论】:

  • 你的 linux 机器有 root 访问权限吗?那里安装了什么 Linux?
  • 也许它已经安装了which ffmpeg的控制台检查它会给你ffmpeg的完整路径,所以只需替换你的$ffmpeg变量中的路径
  • 不,它没有安装我检查过
  • 对不起,我与团队核实了它是 CentOS 版本 6.5... 我收到错误 Error in loading ffmpeg
  • 它似乎已安装,但当我检查扩展程序 extension_loaded('ffmpeg') or die('Error in loading ffmpeg'); 时它会抛出错误 ....

标签: php video ffmpeg centos screenshot


【解决方案1】:

找不到你的安装步骤或命令,需要用ffmpeg-php配置,

#  git clone https://github.com/tony2001/ffmpeg-php.git
#  cd ffmpeg-php
#  make clean
#  phpize 
#  ./configure 
#  make
#  make install

# vim /usr/lib/php.ini 
[ffmpeg]
extension=ffmpeg.so

# pkill -9 httpd
#  /etc/init.d/httpd start

# php -i|grep ffmpeg

ffmpeg
ffmpeg-php version => 0.7.0

【讨论】:

    猜你喜欢
    • 2018-02-16
    • 2014-07-10
    • 2013-02-07
    • 1970-01-01
    • 1970-01-01
    • 2014-05-15
    • 1970-01-01
    • 1970-01-01
    • 2020-02-03
    相关资源
    最近更新 更多