设为首页 收藏本站
查看: 1089|回复: 0

[经验分享] centos ubuntu 安装 ffmpeg php

[复制链接]

尚未签到

发表于 2018-12-21 10:33:06 | 显示全部楼层 |阅读模式
最近在做一个视频网站安装本地环境费了不少时间。本地是ubuntu 9.10 而服务器是redhat as4 所以到时候本人会把服务器安装过程和大家分享出来。本人环境如下

  • php —- 5.210
  • apache 2.2
  • ubuntu 9.10

  • ffmpeg 功能很强大包括视频抓图,视频信息,视频转换,在线视频录制,而且是免费的。所有一般的视频网站都会采用他。
  • 本人首先是采用编译安装,但是一直都没有成功。编译过程中出现了很多问题。安装要使用ffmpeg往往需要编译很多包。感觉很麻烦。这些包又依赖于很多其他包。安装顺序也有要求。所以放弃了。
  • 最终采用ubuntu 强大的 apt-get (使用dpkg进行安装) 进行安装(当然cenos,red hat这类使用rpm的系统都可以使用yum进行安装,具体的安装方法可以在本站进行查找).
  • apt-get 安装步骤如下:
    sudo apt-get update ##更新以下源
    sudo apt-get install ffmpeg
    sudo apt-get install php5-ffmpeg
    sudo apt-get install mencoder
    sudo apt-get install flvtool2 ##视频转换flv
    sudo apt-get install lame ##音频
    sudo apt-get install yasm
  • 编译安装ffmpeg 如下:
    从 http://ffmpeg.mplayerhq.hu 下载
    ./configure –help ##查看有那些参数
    ./configure–prefix=/usr–enable-gpl–enable-shared–enable-libmp3lame–enable-libamr_nb–enable-libogg–enable-libvorbis–enable-libxvid–enable-liba52–enable-liba52bin–enable-pp–enable-libfaad–enable-libfaadbin–enable-libfaac–enable-pthreads–disable-ffserver–enable-x11grab
    如果报错则安装该包,或者直接去掉该参数,只需要配置自己使用过程中需要使用到的就行了。
    make & make install
    其他的则一个一个的下载解压在编译就是了。
  • 具体参考本文:centos+zendce+red5+ffmpeg安装配置


  • 下面是php-ffmpeg 使用的api。功能是很少了。
  • 如果需要给视频抓图择需要使用shell脚本。也就是用到php当中的(system,exec,passthru)这类执行外部命令函数。
    往往很多服务器都将种类函数视为危险函数屏蔽掉了。所以想做视频网站对服务器的配置要求比较高。
    当然最好是自己的独立服务器。vps 也可以。随便你怎么整都可以。
$movie = new ffmpeg_movie(String path_to_media, boolean persistent)  Open a video or audio file and return it as an object.
path_to_media - File path of video or audio file to open.
persistent - Whether to open this media as a persistent resource. See the PHP documentation for more info about persistent resources
$movie->getDuration()  Return the duration of a movie or audio file in seconds.
$movie->getFrameCount()  Return the number of frames in a movie or audio file.
$movie->getFrameRate()  Return the frame rate of a movie in fps.
$movie->getFilename()  Return the path and name of the movie file or audio file.
$movie->getComment()  Return the comment field from the movie or audio file.
$movie->getTitle()  Return the title field from the movie or audio file.
$movie->getAuthor() alias $movie->getArtist()  Return the author field from the movie or the artist ID3 field from an mp3 file.
$movie->getCopyright()  Return the copyright field from the movie or audio file.
$movie->getArtist()  Return the artist ID3 field from an mp3 file.
$movie->getGenre()  Return the genre ID3 field from an mp3 file.
$movie->getTrackNumber()  Return the track ID3 field from an mp3 file.
$movie->getYear()  Return the year ID3 field from an mp3 file.
$movie->getFrameHeight()  Return the height of the movie in pixels.
$movie->getFrameWidth()  Return the width of the movie in pixels.
$movie->getPixelFormat()  Return the pixel format of the movie.
$movie->getBitRate()  Return the bit rate of the movie or audio file in bits per second.
$movie->getVideoBitRate()  Return the bit rate of the video in bits per second.
NOTE: This only works for files with constant bit rate.
$movie->getAudioBitRate()  Return the audio bit rate of the media file in bits per second.
$movie->getAudioSampleRate()  Return the audio sample rate of the media file in bits per second.
$movie->getFrameNumber()  Return the current frame index.
$movie->getVideoCodec()  Return the name of the video codec used to encode this movie as a string.
$movie->getAudioCodec()  Return the name of the audio codec used to encode this movie as a string.
$movie->getAudioChannels()  Return the number of audio channels in this movie as an integer.
$movie->hasAudio()  Return boolean value indicating whether the movie has an audio stream.
$movie->hasVideo()  Return boolean value indicating whether the movie has a video stream.
$movie->getFrame([Integer framenumber])  Returns a frame from the movie as an ffmpeg_frame object. Returns false if the frame was not found.
framenumber - Frame from the movie to return. If no framenumber is specified, returns the next frame of the movie.
$movie->getNextKeyFrame()  Returns the next key frame from the movie as an ffmpeg_frame object. Returns false if the frame was not found.








测试用例:ffmpeg-execute.php
安装过程出现错误解决:

  • make: *** [ffmpeg-php.lo] Error 1
    解决:.编译时加上 (php-config)路径:
    --with-php-config=/usr/local/php/bin/php-config

  • make: *** [ffmpeg_frame.lo] Error 1
    解决:mv ffmpeg_frame.loT ffmpeg_frame.lo
  • 其他问题请检查自己的php版本。和php-ffmpeg是否一致。
  • 还有其他问题可以在下面留言。
本文链接地址: ubuntu 安装 ffmpeg php-ffmpeg




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-653927-1-1.html 上篇帖子: 关于PHP读取HDFS的错误记录 下篇帖子: php笔试题汇总1
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表