最近有一个demo项目在服务器(ubuntu16.04)需要用到FFMPEG,首次接触使用,做个记录。
1、下载
git clone https://git.ffmpeg.org/ffmpeg.git
2、编译安装
./configure --enable-nonfree --enable-gpl --enable-version3 --enable-shared --enable-postproc --enable-pthreads --prefix=/usr/local/ffmpeg --disable-x86asm
说明:
1)可查看./configure --help 根据需要自行选择需要的编译项。
2)在编译过程中,gcc: internal compiler error错误,Google说内存不足,但我没管,继续往下走,后来使用也没出现啥异常,好在是个demo,要的又急,后面有时间再研究。
3、make -j
4、make install
5、查看安装是否成功
/usr/local/bin/ffmpeg --version
error while loading shared libraries: libavdevice.so.58: cannot open shared object file: No such file or directory
继续Google 查到解决方案如下
step1:
sudo vim /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/ffmpeg/lib //这一行是新增,具体目录是我ffmpeg安装目录,根据你的安装目录改吧
step2:
cd /usr/local/lib
sudo ldconfig
step3: 测试OK
/usr/local/ffmpeg/bin/ffmpeg
ffmpeg version N-93562-g3e10223 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.5) 20160609
configuration: --enable-nonfree --enable-gpl --enable-version3 --enable-shared --enable-postproc --enable-pthreads --prefix=/usr/local/ffmpeg --disable-x86asm
libavutil 56. 26.100 / 56. 26.100
libavcodec 58. 50.100 / 58. 50.100
libavformat 58. 27.102 / 58. 27.102
libavdevice 58. 7.100 / 58. 7.100
libavfilter 7. 48.100 / 7. 48.100
libswscale 5. 4.100 / 5. 4.100
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
Use -h to get full help or, even better, run 'man ffmpeg'
6、设置环境变量
vim /etc/profile
加入以下内容:
export PATH="/usr/local/ffmpeg/bin:$PATH"
然后保存并运行source /etc/profile
参考