• 欢迎访问显哥博客,本网站纯属学习技术,绝无商业用途,欢迎小伙伴们共同学习!研究技术!QQ:52249909 加我QQ
  • 世界75亿人,这么小的概率,能认识你,是我一生的幸运,不妨加个QQ接触一下:52249909 加我QQ

Centos7 编译安装ffmpeg带libx264 (附带源码包)【显哥出品,必为精品】

技术栈 lixian 4年前 (2020-09-17) 32330次浏览 1个评论 扫描二维码
文章目录[隐藏]

一、环境准备

yasm源码包下载: wget  https://download.lixian.fun/Linux_LNMP_packers/yasm-1.3.0.tar.gz
x264源码包下载: wget https://download.lixian.fun/Linux_LNMP_packers/x264.tar.gz
ffmpeg源码包下载: wget https://download.lixian.fun/Linux_LNMP_packers/ffmpeg-snapshot.tar.bz2
nasm源码包下载: wget https://download.lixian.fun/Linux_LNMP_packers/nasm-2.13.03.tar.gz

上面是本博客系统内的安装包,直接在终端 wget 下载即可,如果链接失效

执行官方的地址(下载较慢)

ffmpeg(官方的目前是4.1的压缩包)wget https://ffmpeg.org/releases/ffmpeg-4.1.tar.bz2
x264(官方的)git clone https://git.videolan.org/git/x264.git
nasm(官方的)wget https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.bz2
yasm(官方的)http://yasm.tortall.net/Download.html

依赖包安装

yum install -y autoconf automake cmake freetype-devel gcc gcc-c++ git libtool make mercurial nasm pkgconfig zlib-devel bzip2

二、编译安装yasm

#下载或者上传后解压
[root@ecs-7f06-10 ~]# tar xf yasm-1.3.0.tar.gz
[root@ecs-7f06-10 ~]# cd yasm-1.3.0/

[root@ecs-7f06-10 yasm-1.3.0]# ./configure --prefix=/usr/local/yasm

[root@ecs-7f06-10 yasm-1.3.0]# make && make install

三、编译安装nasm

编译x264库之前必须安装nasm组件,不然编译x264会失败

[root@ecs-7f06-10 ~]# tar xf nasm-2.13.03.tar.gz
[root@ecs-7f06-10 ~]# cd nasm-2.13.03
[root@ecs-7f06-10 ~/nasm-2.13.03]# ./configure
[root@ecs-7f06-10 ~/nasm-2.13.03]# make && make install

四、编译安装x264

[root@ecs-7f06-10 ~]# tar xf x264.tar.gz
[root@ecs-7f06-10 ~]# cd x264/
[root@ecs-7f06-10 x264]# ./configure --prefix=/usr/local/x264 --enable-shared --enable-static --enable-yasm
[root@ecs-7f06-10 x264]# make && make install

五、编译安装ffmpeg

[root@ecs-7f06-10 ~]# tar xf ffmpeg-snapshot.tar.bz2
[root@ecs-7f06-10 ~]# cd ffmpeg
[root@ecs-7f06-10 ~/ffmpeg]# ./configure --prefix=/usr/local/ffmpeg --enable-libx264 --enable-gpl --enable-shared  --extra-cflags=-I/usr/local/x264/include --extra-ldflags=-L/usr/local/x264/lib  --enable-pic
[root@ecs-7f06-10 ~/ffmpeg]# make && make install

六、配置环境变量

[root@ecs-7f06-10 ~]# vim /etc/profile
export PATH=$PATH:/usr/local/ffmpeg/bin:/usr/local/yasm/bin:/usr/local/x264/bin
[root@ecs-7f06-10 ~]# source /etc/profile

配置库路径

#编辑ld.so.conf文件,并且在最下面插入两行路径
[root@ecs-7f06-10 ~]# vim /etc/ld.so.conf
/usr/local/ffmpeg/lib
/usr/local/x264/lib
[root@ecs-7f06-10 ~]# ldconfig

七、运行FFmpeg

[root@ecs-7f06-10 ~]# ffmpeg -encoders | grep libx264
ffmpeg version N-99192-g161495a Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-39)
  configuration: --enable-libx264 --enable-gpl --enable-shared --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --enable-pic
  libavutil      56. 59.100 / 56. 59.100
  libavcodec     58.106.100 / 58.106.100
  libavformat    58. 56.100 / 58. 56.100
  libavdevice    58. 11.102 / 58. 11.102
  libavfilter     7. 87.100 /  7. 87.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
 V..... libx264              libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (codec h264)
 V..... libx264rgb           libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 RGB (codec h264)

本站博主 , 版权所有丨如未注明 , 均为原创
转载请注明原文链接:Centos7 编译安装ffmpeg带libx264 (附带源码包)【显哥出品,必为精品】
喜欢 (1)

您必须 登录 才能发表评论!

(1)个小伙伴在吐槽