如何为CentOS 6.5版服务器设置ffmpeg [英] How to setup ffmpeg for CentOS release 6.5 server
问题描述
我需要从视频中创建屏幕截图,
I need to create a screen shot from video,
我已遵循这教程在窗口8,php 5.3中进行初始设置
I have followed this tutorial to do the intial setup in window 8, php 5.3
1)我从这里下载了ffmpeg - [
http:// ffmpeg .zeranoe.com / builds / ],用于64位操作系统。
1) I downloaded the ffmpeg from here -[ http://ffmpeg.zeranoe.com/builds/ ] for 64 bit operating system.
2)我按照 https:/ /www.youtube.com/watch?v=gU49GiWGGAI ,视频和所有配置成功, phpinfo()
显示 ffmpeg
已安装。
2) I followed the https://www.youtube.com/watch?v=gU49GiWGGAI , video and did all configuration successfully and phpinfo()
shows that ffmpeg
has been installed.
3)然后我尝试了这以了解它是否工作,
3) Then I tried this to find out whether it is working or not,
它工作成功
4 )下一步我按照此处的视频教程,成功创建了缩略图。
4) Next I followed this video tutorial here and thumbnails were created successfully.
是我的代码
/**
* 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。如何在带有php 5.5的CentOS 6.5版本服务器中对ffmpeg进行配置。
Now above code works as expected in my local, in window machine , I need to do it in my server environment(Linux server) with php 5.5. How do I do the configuration for ffmpeg in CentOS release 6.5 server with php 5.5.
我已按照本教程将其安装在服务器中
I have followed this tutorial to install it in server
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文件我得到这个错误加载ffmpeg时出错
另外我检查了phpinfo(),它显示ffmpeg安装在我的本地,但不是在服务器。
But in server when I open my php file I am getting this error Error in loading ffmpeg
Also I have checked phpinfo(), It shows ffmpeg installed in my local but not in server.
在Cent Os 6.5 php 5.5中配置ffmpeg需要做什么。
What else I need to do to configure ffmpeg in Cent Os 6.5 php 5.5.
推荐答案
我找不到你的安装步骤或命令,你需要配置ffmpeg-php,
I could not find your installation steps or commands, You need to configure with 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
这篇关于如何为CentOS 6.5版服务器设置ffmpeg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!