FFmpeg is an amazing collection of open-source tools that can record and stream video and audio. However, it can also transcode video and audio (convert the files to different formats), and that is what has me so excited. There’s also a great PHP package calledffmpeg-php that allows for easy use of FFmpeg from inside PHP scripts. Today, I’m going to see if I can’t help you get both of these set up on your system.
Admittedly, it’s been a while since I’ve tried to install FFmpeg, about two years. I recently thought up some ideas on how I’d like to use FFmpeg, so I thought it was time to give it a try yet again. Today, I’m proud to say that installing FFmpeg is so much easier to install compared to the past, that I dare say it’s simple.
Here is my experience with installing FFmpeg on my server and how to fix the pitfalls that I encountered.
Preface
Note that I did all the following steps on a CentOS server. The specific version is CentOS x64 5.2.
These instructions can work for other distros with little or no modifications, but some distros will be completely different. For example, the DAG RPM Repository that I’m using (more info below) has support for the following distros: Red Hat Enterprise Linux, Fedora Core, Yellow Dog Linux, Aurora Linux, CentOS, Scientific Linux (they really need to get a verified SSL cert), TaoLinux, WhiteBox Linux, Lineox, and BLAG. Other distros will need to use a different repository.
If you successfully get FFmpeg running on another distro, please comment your changes here and I’ll update the post (and make sure you get credit of course).
Also note that I experienced some bumps in the road while installing everything. While many of you may not experience these issues, I found it important to document these problems and how I fixed them in case you encounter them.
Preparing
The first thing that you need to do is set up the DAG repository. This repository is an actively-maintained repository that provides a staggering number of packages with current or near current builds. Adding this repository is a great way to run the latest offerings of many packages.
Adding the DAG repository is simple. I’m using yum, so I did the following to add the repository:
- Create and open a new file called /etc/yum.repos.d/dag.repo. I ran “
vi /etc/yum.repos.d/dag.repo
“. - Add the following text to the file:
[dag]
name=DAG RPM Repository
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=1 - Finally, save and close the file.
In order to successfully use the DAG repository with tools such as yum, you need to add DAG’s GPG key. Failure to do so will result in an error like the following:
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 6b8d79e6
Public key for faac.x86_64.1.26-1.el5.rf.rpm is not installed
In order to add the GPG key for DAG, run the following:
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
The DAG: Frequently Asked Questions page has additional instructions on how to get the repository loaded and working on your distro.
Now that DAG is setup, it’s a good idea to update all your packages.
yum update
Depending on the packages you currently have installed, this could potentially upgrade, install, or replace numerous packages that may or may not be very important to you. Make sure you carefully look through that list and do any necessary preparations before telling yum that it can go ahead.
For example, yum told me that it was going to replace my current MySQL interface library for Perl with a new one. I added to my check list a note to verify that my Perl code functioned correctly after the install.
I ran into another hitch when I told yum to go ahead with the update. It informed me that my current version of Subversion conflicted with the new version it wanted to install. When this happens, you need to remove the old package before proceeding. This time, I made backups of all of my repositories and my /etc/sysconfig/svnserve file before proceeding just in case. I then removed Subversion “yum remove subversion
“, ran the update process “yum update
“, and installed Subversion again “yum install subversion
“.
Installing – FFmpeg
Now you are ready to install FFmpeg with yum. I wanted to install all the available FFmpeg packages, so I first asked yum what was available.
yum search ffmpeg
Searching through the results, I found that three packages need to be installed: ffmpeg, ffmpeg-devel, and ffmpeg-libpostproc.
yum install ffmpeg ffmpeg-devel ffmpeg-libpostproc
Note: If you install ffmpeg-libpostproc, the entire FFmpeg software library changes from the LGPL license to the GPL license.
After a couple of minutes, the packages and the packages that they depend on were installed.
I simply ran “ffmpeg
” from the command line, and I took the lack of threatening error or warning messages as a good sign that things were working.
Preparing for ffmpeg-php
I often work with programs through command line calls in code, but I wanted something more robust this time, so I looked around and found ffmpeg-php. Based on the API, it looks to be a great tool to interface PHP and FFmpeg.
There are four things that are required to successfully install and run ffmpeg-php; they are:
- ffmpeg-0.4.9_pre1 or higher
- php-4.3.0 or higher
- gd-2.0 or higher
- php-devel
PHP and FFmpeg should be good to go since at the time of this writing, DAG has PHP version 5.1.6 and FFmpeg version 0.4.9. GDand php-devel can be easily installed by running the following yum command:
yum install php-gd php-devel
In case you are wondering what php-devel is for, it installs the phpize program which is used to install ffmpeg-php.
Installing ffmpeg-php
Now we are ready to install ffmpeg-php. This can be done in six easy steps:
- Download the latest ffmpeg-php release
- Extract the archive:
tar -xjf ffmpeg-php-X.x.x.tbz2
cd ffmpeg-php-X.x.x/
phpize
./configure && make
sudo make install
Finishing Thoughts
This may seem like a lot of work when I earlier described this process as “simple,” but trust me that this is a thousand times easier than when I first tried installing FFmpeg. I think I spent three hours working on installing FFmpeg just to find out that it didn’t work the first time I tried.
Time and time again, package management has proven to be an extremely powerful tool. While I know the value of manually configuring and compiling code, the ease of simply using a package manager can reduce the time needed to install and manage software from hours or days to minutes.
I’m glad to see that FFmpeg has benefited from the use of these package managers and great repositories like the DAG RPM Repository.
相关推荐
ffmpeg库:ffmpeg-n5.1-latest-win64-gpl-shared-5.1
报错 Imageio: 'ffmpeg-win32-v3.2.4.exe' was not found on your computer; downloading it now. 因为代码会检测在C:\Users\Administrator\AppData\Local\imageio\ffmpeg 目录下有没有'fwmpeag-win32-v3.2.4.exe...
ffmpeg-n5.1.2-win64
ffmpeg-n4.4-4-gacb339bb88-win64-lgpl-shared-4.4.zip
FFmpeg sdk 3.2 ,音视频解码器,支持众多格式。内有文档。开发方便。
报错 Imageio: 'ffmpeg-win32-v3.2.4.exe' was not found on your computer; downloading it now. 因为代码会检测在C:\Users\Administrator\AppData\Local\imageio\ffmpeg 目录下有没有'fwmpeag-win32-v3.2.4....
ffmpeg 4.4版本,win64,share版 lgpl
ffmpeg-master-latest-win64-gpl.zip
MoviePy 是一个用于视频编辑的Python库,其所需要的ffmpeg的exe文件。 解决问题:Imageio: 'ffmpeg-win32-v3.2.4.exe' was not found on your computer; downloading it now.
ffmpeg-php 是一个php扩展,用来获取视频或音频信息,你可以用它从视频中截取图片、获取视频时长,视频的长、宽等。 下面介绍在windows环境下本扩展的安装,在安装本扩展之前你首先要确认你本地环境中已经安装好了...
赠送jar包:ffmpeg-5.0-1.5.7.jar; 赠送原API文档:ffmpeg-5.0-1.5.7-javadoc.jar; 赠送源代码:ffmpeg-5.0-1.5.7-sources.jar; 赠送Maven依赖信息文件:ffmpeg-5.0-1.5.7.pom; 包含翻译后的API文档:ffmpeg-5.0...
- install using conda: conda install ffmpeg -c conda-forge - download using the command: imageio_download_bin ffmpeg - download by calling (in Python): imageio.plugins.ffmpeg.download()
ffmpeg-win64,window10
赠送jar包:ffmpeg-4.3.2-1.5.5.jar; 赠送原API文档:ffmpeg-4.3.2-1.5.5-javadoc.jar; 赠送源代码:ffmpeg-4.3.2-1.5.5-sources.jar; 赠送Maven依赖信息文件:ffmpeg-4.3.2-1.5.5.pom; 包含翻译后的API文档:...
ffmpeg-4.0.2-win32-dev.zip ffmpeg-4.0.2-win32-shared.zip ffmpeg-4.0.2-win32-static.zip ffmpeg-4.0.2-win64-dev.zip ffmpeg-4.0.2-win64-shared.zip ffmpeg-4.0.2-win64-static.zip
Windows版本ffmpeg,ffmpeg-n4.3.1-20-g8a2acdc6da-win64-lgpl-4.3
ffmpeg-win32-v3.2.4.exe,视频采集,格式转换,帧流处理
赠送jar包:ffmpeg-4.3.2-1.5.5.jar; 赠送原API文档:ffmpeg-4.3.2-1.5.5-javadoc.jar; 赠送源代码:ffmpeg-4.3.2-1.5.5-sources.jar; 赠送Maven依赖信息文件:ffmpeg-4.3.2-1.5.5.pom; 包含翻译后的API文档:...
ffmpeg
ffmpeg-php扩展包,把php_ffmpeg.dll放在php的ext文件夹下,其他dll全部复制到window\system32下面,重启apache.