Linux CentOS 6.3安装ffmpeg

来源:互联网 发布:下载排卵期测算软件 编辑:程序博客网 时间:2024/06/10 04:35

最近用Python pydub库来处理音频文件,这个库封装了ffmpeg,需要先安装ffmpeg才能正常使用pydub。下面记录一下安装过程。

先安装yasm

yum install yasm

下载安装包

# http://ffmpeg.org/releases/wget http://ffmpeg.org/releases/ffmpeg-2.8.tar.gz

解压编译

tar zxf ffmpeg-2.8.tar.gzcd ./ffmpeg-2.8./configure --enable-shared --prefix=/usr/local/ffmpeg 
  • –prefix表示程序安装的目录,这里设为/usr/local/ffmpeg。

  • –enable-shared表示生成动态链接库,可以供以后编程使用,同时生成的可执行程序也依赖这些动态库。

make  # 这个过程比较耗时make install

环境配置

进入bin目录,执行 ./ffmpeg -version 查看当前版本的详细信息,默认情况下一般会报libavdevice.so.57: cannot open shared object file: No such file or directory,原因是lib目录未加载到链接到系统库中。
系统ld目录列表在/etc/ld.so.conf中,打开文件会发现,里面引用了/etc/ld.so.conf.d/下面所有的.conf文件。

# ls -altotal 36drwxr-xr-x.   2 root root  4096 Dec  5 17:15 .drwxr-xr-x. 105 root root 12288 Dec  5 17:31 ..-rw-r--r--    1 root root    22 Dec  5 17:31 ffmpeg.conf-r--r--r--.   1 root root   324 Sep  2  2013 kernel-2.6.32-279.23.1.mi5.el6.x86_64.conf-r--r--r--.   1 root root   324 Jun 22  2012 kernel-2.6.32-279.el6.x86_64.conf-rw-r--r--.   1 root root    17 Jun 22  2012 mysql-x86_64.conf-rw-r--r--    1 root root    22 Sep 24  2011 qt-x86_64.conf

添加ffmpeg conf

cd /etc/ld.so.conf.d/touch ffmpeg.conf echo '/usr/local/ffmpeg/lib' > ffmpeg.confldconfig 

执行 ldconfig 使配置生效,现在再次执行 ./ffmpeg -version 显示就正常了

添加环境变量

根据需要将bin目录添加至环境变量中以保证任何时候都能使用ffmpeg命令,可在.bash_profile中添加如下配置行。

PATH=$PATH:/usr/local/ffmpeg/bin

安装成功

ffmpegffmpeg version 2.8 Copyright (c) 2000-2015 the FFmpeg developers  built with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4)  configuration: --enable-shared --prefix=/usr/local/ffmpeg  libavutil      54. 31.100 / 54. 31.100  libavcodec     56. 60.100 / 56. 60.100  libavformat    56. 40.101 / 56. 40.101  libavdevice    56.  4.100 / 56.  4.100  libavfilter     5. 40.101 /  5. 40.101  libswscale      3.  1.101 /  3.  1.101  libswresample   1.  2.101 /  1.  2.101Hyper fast Audio and Video encoderusage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
原创粉丝点击