ffmpeg安装命令详解

ffmpeg安装命令详解

前言

ffmpeg是一个跨平台的转换视频音频的工具,在linux下一行简单的代码就可以实现视频/音频格式转换等功能.今天我使用它为了给视频截图一张

A complete, cross-platform solution to record, convert and stream audio and video. - 来自官网

安装ffmpeg

'* 下载 ffmpeg 源码包'
[root@localhost ~]$ wget https://ffmpeg.org/releases/ffmpeg-4.0.tar.bz2


100%[======================================>] 10,423,830  67.7KB/s 用时 2m 37s
---
'* 解压'
[root@localhost ~]$ tar -jxf ffmpeg-4.0.tar.bz2
---
'* 进入 ffmpeg-4.0 [这里文件根据你的版本不同名称是不同的]'
[root@localhost ~]$ cd ffmpeg-4.0
---
'* 配置并检测当前环境是否符合该工具的安装'
[root@localhost ffmpeg-4.0]$ ./configure --enable-shard --prefix=/usr/loacl/ffmpeg

nasm/yasm not found or too old. Use --disable-x86asm for a crippled build.
If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
---
'* 以为上面缺少nasm/yasm 扩展或者是因为版本过老所以需要 禁用或者安装这个扩展来配置,这里我选择安装'
[root@localhost ffmpeg-4.0]$ yum -y install yasm

...
已安装:
  yasm.x86_64 0:1.2.0-4.el7
---
'* 开始执行上面的配置(./configure ...)重新检测[这里时间有点长]'
[root@localhost ffmpeg-4.0]$ ./configure --enable-shard --prefix=/usr/local/ffmpeg

...
License: LGPL version 2.1 or later
---
'* 执行安装[此处需要的时间也不短]'
[root@localhost ffmpeg-4.0]$ make && make install 

...
此处出现了一大堆cc .....

'* 配置相关依赖包'
[root@localhost ffmpeg-4.0]$ cd 	/etc/ld.so.conf.d
[root@localhost ld.so.conf.d]$ touch ffmpeg.conf
[root@localhost ld.so.conf.d]$ echo "/usr/local/ffmpeg/lib" >> ffmpeg.conf
[root@localhost ld.so.conf.d]$ ldconfig
[root@localhost ld.so.conf.d]$ /usr/local/ffmpeg/bin/./ffmpeg

ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-16)
  configuration: --enable-shared --prefix=/usr/local/ffmpeg
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  ...
配置依赖包成功

'* 链接到执行目录'
[root@localhost ffmpeg-4.0]$ ln -s /usr/local/ffmpeg/bin/ffmpeg /usr/local/bin/
[root@localhost ffmpeg-4.0]$ ffmpeg -version

ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-16)
configuration: --enable-shared --prefix=/usr/local/ffmpeg
libavutil      56. 14.100 / 56. 14.100
libavcodec     58. 18.100 / 58. 18.100
libavformat    58. 12.100 / 58. 12.100
libavdevice    58.  3.100 / 58.  3.100
libavfilter     7. 16.100 /  7. 16.100
libswscale      5.  1.100 /  5.  1.100
libswresample   3.  1.100 /  3.  1.100

使用方法(其他的命令可以百度/谷歌,我只写出我用的命令并不做命令格式的详解)

  1. ffmpeg -i input.mp4 output.avi 将mp4 -> avi 格式 (取自官网)
  2. ffmpeg -i input.mp4 -y -f image2 -ss 8 -vframes 1 -s 640x360 ./output.jpg 取出视频8秒的时候并制作成jpg文件

我遇到的问题记录

错误(1):
nasm/yasm not found or too old. Use --disable-x86asm for a crippled build.

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
解决办法: 
按照他的说法 是因为 nasm/yasm 太老或者没有安装,我们有两个选择 
1. 在 ./configure 后面加上`--disable-x86asm` 
2. yum -y install yasm 
---
错误(2):
error while loading shared libraries: libavdevice.so.56: cannot open shared object file: No such file or directory
解决办法:
这是因为没有配置库文件的位置 我的库位置在 '/usr/local/ffmpeg/lib' ,所以我要在
'/etc/ld.so.conf.d' 文件夹中新建一个ffmpeg.conf文件并在里面写入 '/usr/local/ffmpeg/lib' 
然后使用 'ldconfig' 启动配置这时候就可以找到这个命令了
---
错误(3):
在安装之后会发现想在全局使用ffmpeg就只能打上全路径然后执行这不是我们想要的,
我们要配置一下当前的命令到系统指令
解决办法:
ln -s /usr/local/ffmpeg/bin/ffmpeg /usr/local/bin/

以上是我安装ffmpeg时候出现的问题以及安装步奏,不代表所有人都能按照我这个方法执行成功

# Linux  ffmpeg 

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×