在linux下安装ffmpeg

一、简介

FFmpeg是一套可以用来记录、转换数字音频、视频,并能将其转化为流的开源计算机程序。采用LGPL或GPL许可证。它提供了录制、转换以及流化音视频的完整解决方案。它包含了非常先进的音频/视频编解码库libavcodec,为了保证高可移植性和编解码质量,libavcodec里很多code都是从头开发的。

FFmpeg在Linux平台下开发,但它同样也可以在其它操作系统环境中编译运行,包括Windows、Mac OS X等。这个项目最早由Fabrice Bellard发起,2004年至2015年间由Michael Niedermayer主要负责维护。许多FFmpeg的开发人员都来自MPlayer项目,而且当前FFmpeg也是放在MPlayer项目组的服务器上。项目的名称来自MPEG视频编码标准,前面的"FF"代表"Fast Forward"。 [1] FFmpeg编码库可以使用GPU加速。

二、安装

前提需要安装yasm、libx264、pkg-config

1.安装yasm编译器

yum install yasm -y

如果没有安装yasm,在执行./configure --enable-libx264 --enable-gpl --prefix=/usr/local/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.libera.chat.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.

2.安装libx264

下载地址

https://code.videolan.org/videolan/x264/-/archive/master/x264-master.tar

解压X624

# tar jxvf x264-master.tar

进入解压目录

# cd x264-master

编译和安装

# ./configure --enable-shared
# make && make install

如果没有安装libx264,在使用ffmpeg会提示:Unknown encoder ‘libx264’

3.安装pkg-config

下载地址

https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz

解压X624

# tar jxvf pkg-config-0.29.2.tar.gz

进入解压目录

# cd pkg-config-0.29.2

编译和安装

# ./configure --with-internal-glib
# make
# make check
# make install

安装ffmpeg

下载解压

wget http://www.ffmpeg.org/releases/ffmpeg-5.0.tar.gz
tar -zxvf ffmpeg-5.0.tar.gz

解压后目录,输入如下命令:/usr/local/ffmpeg为自己指定的安装目录

# ./configure --enable-libx264 --enable-gpl --prefix=/usr/local/ffmpeg

安装,这个操作时间会比较长点

# make && make install

修改文件/etc/ld.so.conf

# vim /etc/ld.so.conf

添加两行:

/usr/local/ffmpeg/lib/
/usr/local/lib/

使修改的文件/etc/ld.so.conf生效

# ldconfig

查看安装结果

# ./ffmpeg -version

配置环境变量

# vim /etc/profile
export PATH=$PATH:/usr/local/ffmpeg/bin

使环境变量生效

# source /etc/profile

查看ffmpeg版本

# ffmpeg -version
发表评论
留言与评论(共有 0 条评论) “”
   
验证码:

相关文章

推荐文章