Linux ffmpeg编译安装

ffmpeg编译配置,以支持h264视频编码,支持avfilter增加水印

安装ffmpeg过程中,需要安装所需的依赖项:

  • nasm:汇编编译跨平台支持
  • x264:H264编解码
  • freetype2:ttf字体库支持
  • x264安装

下载x264https://www.videolan.org/developers/x264.html

git clone https://code.videolan.org/videolan/x264.git

配置 ./configure

eric@eric-PC:~/Documents/linux/x264$ ls
AUTHORS         config.guess  COPYING  example.c  input     tools       x264cli.h  x264res.manifest
autocomplete.c  config.sub    doc      extras     Makefile  version.sh  x264dll.c  x264res.rc
common          configure     encoder  filters    output    x264.c      x264.h
eric@eric-PC:~/Documents/linux/x264$ ./configure
Found no assembler
Minimum version is nasm-2.13
If you really want to compile without asm, configure with --disable-asm.

提示缺失nasm,执行sudo apt-get install nasm后,再进行配置

eric@eric-PC:~/Documents/linux/x264$ ./configure --enable-static --enable-shared
platform:       X86_64
byte order:     little-endian
system:         LINUX
cli:            yes
libx264:        internal
shared:         yes
static:         yes
bashcompletion: yes
asm:            yes
interlaced:     yes
avs:            avxsynth
lavf:           no
ffms:           no
mp4:            no
gpl:            yes
thread:         posix
opencl:         yes
filters:        crop select_every
lto:            no
debug:          no
gprof:          no
strip:          no
PIC:            yes
bit depth:      all
chroma format:  all

You can run 'make' or 'make fprofiled' now.

编译、安装x264

eric@eric-PC:~/Documents/linux/x264$ make
eric@eric-PC:~/Documents/linux/x264$ sudo make installinstall -d /usr/local/bin
install x264 /usr/local/bin
install -d /usr/local/include /usr/local/lib/pkgconfig
install -m 644 ./x264.h x264_config.h /usr/local/include
install -m 644 x264.pc /usr/local/lib/pkgconfig
install -d /usr/local/lib
ln -f -s libx264.so.161 /usr/local/lib/libx264.so
install -m 755 libx264.so.161 /usr/local/lib
install -d /usr/local/lib
install -m 644 libx264.a /usr/local/lib
gcc-ranlib /usr/local/lib/libx264.a
install -d /usr/share/bash-completion/completions
install -m 644 -T ./tools/bash-autocomplete.sh /usr/share/bash-completion/completions/x264
  • 安装ffmpeg

先安装freetype字体库,avfilter添加文字水印的依赖项;下载freetype:https://www.freetype.org/download.html

配置、编译、安装、读取版本信息

eric@eric-PC:~/Documents/linux/freetype-2.10.4$ ./configure 
eric@eric-PC:~/Documents/linux/freetype-2.10.4$ make
eric@eric-PC:~/Documents/linux/freetype-2.10.4$ sudo make install
eric@eric-PC:~/Documents/linux/freetype-2.10.4$ pkg-config --modversion freetype2 
23.4.17

下载ffmpeg

eric@eric-PC:~/Documents/linux-c$ git clone https://gitee.com/mirrors/ffmpeg.git
正克隆到 'ffmpeg'...
remote: Enumerating objects: 7513, done.
remote: Counting objects: 100% (7513/7513), done.
remote: Compressing objects: 100% (3603/3603), done.
remote: Total 610183 (delta 5174), reused 5268 (delta 3903), pack-reused 602670
接收对象中: 100% (610183/610183), 149.26 MiB | 2.55 MiB/s, 完成.
处理 delta 中: 100% (489283/489283), 完成.

配置、编译、安装ffmpeg
./configure --enable-static --enable-shared --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --enable-ffmpeg --enable-libx264 --enable-gpl --enable-libfreetype --enable-libopenjpeg

eric@eric-PC:~/Documents/linux-c/ffmpeg$ ./configure --enable-static --enable-shared --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --enable-ffmpeg --enable-libx264 --enable-gpl --enable-libfreetype
eric@eric-PC:~/Documents/linux-c/ffmpeg$ make
eric@eric-PC:~/Documents/linux-c/ffmpeg$ sudo make install

查看已经安装完成的ffmpeg

eric@eric-PC:/$ ffmpeg 
ffmpeg version N-99957-g837eb320b8 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 8 (Uos 8.3.0.3-3+rebuild)
  configuration: --enable-static --enable-shared --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --enable-ffmpeg --enable-libx264 --enable-gpl --enable-libfreetype
  libavutil      56. 60.100 / 56. 60.100
  libavcodec     58.112.103 / 58.112.103
  libavformat    58. 64.100 / 58. 64.100
  libavdevice    58. 11.102 / 58. 11.102
  libavfilter     7. 90.100 /  7. 90.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.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'



猜你喜欢

转载自blog.csdn.net/pyt1234567890/article/details/109921858