栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

编译安装ffmpeg

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

编译安装ffmpeg

编译安装ffmpeg
  • 1 软件包
  • 2 基础配置
    • 2.1 关闭SELinux
    • 2.2 关闭防火墙或开放需要的业务端口
    • 2.3 调整max_open_files
    • 2.4 重启检查SELinux、firewalld和open files
  • 3 离线安装

1 软件包

ffmpeg工具环境.zip下载地址:
https://download.csdn.net/download/Zhuge_Dan/85364065

2 基础配置 2.1 关闭SELinux
[root@FFMPEG ~]# setenforce 0

[root@FFMPEG ~]# vi /etc/selinux/config
SELINUX=disabled								#将SELINUX设置为disabled

[root@FFMPEG ~]# getenforce 
Permissive
2.2 关闭防火墙或开放需要的业务端口
[root@FFMPEG ~]# systemctl stop firewalld								#关闭防火墙

[root@FFMPEG ~]# systemctl disable firewalld								#禁止防火墙开机自启
2.3 调整max_open_files
[root@FFMPEG ~]# echo '* soft nofile 65535' >> /etc/security/limits.conf

[root@FFMPEG ~]# echo '* hard nofile 65535' >> /etc/security/limits.conf

[root@FFMPEG ~]# cat /etc/security/limits.conf | tail -2
* soft nofile 65535
* hard nofile 65535

[root@FFMPEG ~]# echo 'ulimit -SHn 65535' >> /etc/rc.d/rc.local

[root@FFMPEG ~]# cat /etc/rc.d/rc.local | tail -1
ulimit -SHn 65535

[root@FFMPEG ~]# chmod +x /etc/rc.d/rc.local								#为rc.local增加可执行权限
2.4 重启检查SELinux、firewalld和open files
[root@FFMPEG ~]# reboot

[root@FFMPEG ~]# getenforce								#查看SELinux是否关闭成功
Disabled								#关闭成功

[root@FFMPEG ~]# systemctl status firewalld								#查看防火墙状态
● firewalld.service - firewalld - dynamic firewall daemon
    Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
    Active: inactive (dead)								#防火墙已关闭
      Docs: man:firewalld(1)

[root@FFMPEG ~]# systemctl is-enabled firewalld								#查看防火墙是否开机自启
disabled								#防火墙已禁止开机自启

[root@FFMPEG ~]# ulimit -a | grep open
open files                      (-n) 65535								#open files已调整为65535
3 离线安装

编译安装ffmpeg需要gcc环境。将gcc上传到服务器上,以上传到/usr/local/目录下为例:

[root@FFMPEG ~]# rpm -ivh /usr/local/gcc/*.rpm --force
warning: /usr/local/gcc/cpp-4.8.5-36.el7_6.2.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:libgcc-4.8.5-36.el7_6.2          ################################# [  7%]
   2:glibc-common-2.17-260.el7_6.5    ################################# [ 14%]
……
  10:kernel-headers-3.10.0-957.12.2.el################################# [ 71%]
  11:glibc-headers-2.17-260.el7_6.5   ################################# [ 79%]
  12:glibc-devel-2.17-260.el7_6.5     ################################# [ 86%]
  13:gcc-4.8.5-36.el7_6.2             ################################# [ 93%]
  14:gcc-c++-4.8.5-36.el7_6.2         ################################# [100%]

[root@FFMPEG ~]# rm -rf /usr/local/gcc/

违规取证视频转码时需要h264编码器。将x264.tar.gz上传到服务器,以上传到/usr/local/目录下为例:

[root@FFMPEG ~]# cd /usr/local/

[root@FFMPEG local]# tar -zxvf x264.tar.gz
x264/
x264/x264.c
x264/filters/
x264/tools/
x264/configure
……
x264/filters/video/select_every.c
x264/filters/video/video.h
x264/filters/video/fix_vfr_pts.c
x264/filters/video/source.c
x264/filters/video/cache.c

[root@FFMPEG local]# rm -f x264.tar.gz

[root@FFMPEG local]# cd x264

[root@FFMPEG x264]# ./configure --enable-shared --enable-static --disable-asm && make && make install
platform:      X86_64
byte order:    little-endian
system:        LINUX
cli:           yes
libx264:       internal
……
ln -f -s libx264.so.157 /usr/local/lib/libx264.so
install -m 755 libx264.so.157 /usr/local/lib
install -d /usr/local/lib
install -m 644 libx264.a /usr/local/lib
gcc-ranlib /usr/local/lib/libx264.a

[root@FFMPEG x264]# ln -s /usr/local/lib/libx264.so /usr/lib/libx264.so

[root@FFMPEG x264]# ln -s /usr/local/lib/libx264.so.157 /usr/lib/libx264.so.157

[root@FFMPEG x264]# ldconfig

违规取证视频打时间戳需要freetype支持。将freetype-2.10.0.tar.gz上传到服务器,以上传到/usr/local/目录下为例:

[root@FFMPEG ~]# cd /usr/local/

[root@FFMPEG local]# tar -zxvf freetype-2.10.0.tar.gz
freetype-2.10.0/
freetype-2.10.0/devel/
freetype-2.10.0/devel/ft2build.h
freetype-2.10.0/devel/ftoption.h
freetype-2.10.0/docs/
……
freetype-2.10.0/ChangeLog.20
freetype-2.10.0/ChangeLog.22
freetype-2.10.0/Makefile
freetype-2.10.0/ChangeLog.23
freetype-2.10.0/README.git

[root@FFMPEG local]# rm -f freetype-2.10.0.tar.gz

[root@FFMPEG local]# cd freetype-2.10.0

[root@FFMPEG freetype-2.10.0]# ./configure && make && make install

FreeType build system -- automatic system detection

The following settings are used:

  platform                    unix
……
          /usr/local/include/freetype2/freetype/config/ftoption.h
/usr/bin/install -c -m 644 ./builds/unix/freetype2.m4             
          /usr/local/share/aclocal/freetype2.m4
/usr/bin/install -c -m 644 ./builds/unix/freetype2.pc             
          /usr/local/lib/pkgconfig/freetype2.pc

添加freetype环境变量:ls

[root@FFMPEG ~]# echo 'export FREETYPE_CFLAGS="-I/usr/local/include/freetype2/freetype/"' >> /etc/profile

[root@FFMPEG ~]# echo 'export FREETYPE_LIBS="-L/usr/local/include/freetype2/freetype/ -lfreetype"' >> /etc/profile

[root@FFMPEG ~]# echo 'export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/' >> /etc/profile

[root@FFMPEG ~]# source /etc/profile

ffmpeg为了提高编译速度使用了汇编指令,需要安装yasm。将yasm-1.3.0.tar.gz上传到服务器,以上传到/usr/local/目录下为例:

[root@FFMPEG ~]# cd /usr/local/

[root@FFMPEG local]# tar -zxvf yasm-1.3.0.tar.gz
yasm-1.3.0/
yasm-1.3.0/libyasm/
yasm-1.3.0/libyasm/cmake-module.c
yasm-1.3.0/libyasm/bitvect.h
yasm-1.3.0/libyasm/section.h
……
yasm-1.3.0/config/depcomp
yasm-1.3.0/config/mkinstalldirs
yasm-1.3.0/config/config.guess
yasm-1.3.0/yasm_objfmts.7
yasm-1.3.0/ABOUT-NLS

[root@FFMPEG local]# rm -f yasm-1.3.0.tar.gz

[root@FFMPEG local]# cd yasm-1.3.0

[root@FFMPEG yasm-1.3.0]# ./configure && make && make install
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
……
 /usr/bin/mkdir -p '/usr/local/include'
 /usr/bin/install -c -m 644 libyasm-stdint.h '/usr/local/include'
make[3]: Leaving directory `/usr/local/yasm-1.3.0'
make[2]: Leaving directory `/usr/local/yasm-1.3.0'
make[1]: Leaving directory `/usr/local/yasm-1.3.0'

将ffmpeg-4.1.3.tar.gz上传到服务器,以上传到/usr/local/目录下为例:
解压缩:

[root@FFMPEG ~]# cd /usr/local/

[root@FFMPEG local]# tar -zxvf ffmpeg-4.1.3.tar.gz
./._ffmpeg-4.1.3
ffmpeg-4.1.3/
ffmpeg-4.1.3/._LICENSE.md
ffmpeg-4.1.3/LICENSE.md
ffmpeg-4.1.3/._libpostproc
……
ffmpeg-4.1.3/libpostproc/postprocess.h
ffmpeg-4.1.3/libpostproc/._postprocess_template.c
ffmpeg-4.1.3/libpostproc/postprocess_template.c
ffmpeg-4.1.3/libpostproc/._libpostproc.v
ffmpeg-4.1.3/libpostproc/libpostproc.v

[root@FFMPEG local]# rm -f ffmpeg-4.1.3.tar.gz

进入ffmpeg目录,编译安装:

[root@FFMPEG local]# cd ffmpeg-4.1.3

[root@FFMPEG ffmpeg-4.1.3]# ./configure --enable-libfreetype --enable-libx264 --enable-gpl
install prefix            /usr/local
source path               .
C compiler                gcc
C library                 glibc
ARCH                      x86 (generic)
……

Enabled outdevs:
fbdev                       oss                         v4l2

License: GPL version 2 or later

[root@FFMPEG ffmpeg-4.1.3]# make && make install
GEN     libavutil/libavutil.version
GEN     libswscale/libswscale.version
GEN     libswresample/libswresample.version
GEN     libpostproc/libpostproc.version
GEN     libavcodec/libavcodec.version
……
INSTALL libavutil/tea.h
INSTALL libavutil/lzo.h
INSTALL libavutil/avconfig.h
INSTALL libavutil/ffversion.h
INSTALL libavutil/libavutil.pc

[root@FFMPEG ffmpeg-4.1.3]# ffmpeg -version
ffmpeg version 4.1.3 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-36)
configuration: --enable-libfreetype --enable-libx264 --enable-gpl
libavutil      56. 22.100 / 56. 22.100
libavcodec     58. 35.100 / 58. 35.100
libavformat    58. 20.100 / 58. 20.100
libavdevice    58.  5.100 / 58.  5.100
libavfilter     7. 40.101 /  7. 40.101
libswscale      5.  3.100 /  5.  3.100
libswresample   3.  3.100 /  3.  3.100
libpostproc    55.  3.100 / 55.  3.100
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/884284.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号