Ubuntu20.4下x264、x265、fdk-aac和FFmpeg4.3源码编译安装

依赖安装

pt-get install make cmake g++ nasm yasm diffutils pkg-config -y

编译安装x264

克隆x264源码

git config --global http.sslVerify false
git clone https://code.videolan.org/videolan/x264.git

指定配置项,指定安装在/usr下

./configure --enable-shared --prefix=/usr/

编译

make

安装

sudo make install

libx264.so动态库被安装在了/usr/lib下,显示如下

install -d /usr//bin
install x264 /usr//bin
install -d /usr//include
install -d /usr//lib/pkgconfig
install -m 644 ./x264.h x264_config.h /usr//include
install -m 644 x264.pc /usr//lib/pkgconfig
install -d /usr//lib
ln -f -s libx264.so.164 /usr//lib/libx264.so
install -m 755 libx264.so.164 /usr//lib
install -d /usr/share/bash-completion/completions
install -m 644 ./tools/bash-autocomplete.sh /usr/share/bash-completion/completions/x264

至此,x264编译完成

编译安装x265

下载x265

wget http://ftp.videolan.org/pub/videolan/x265/x265_3.2.tar.gz

解压

tar -zxvf x265_3.2.tar.gz 

进入build目录

cd x265_3.2/build/linux

执行生成Makefile脚本

./make-Makefiles.bash

可以看到检测到nasm,并生成了Makefile文件

-- Found nasm: /usr/bin/nasm (found version "2.14.02") 
-- Found Nasm 2.14.02 to build assembly primitives
-- x265 version 3.2
-- The ASM_NASM compiler identification is NASM
-- Found assembler: /usr/bin/nasm
-- Looking for strtok_r
-- Looking for strtok_r - found
-- Looking for include file getopt.h
-- Looking for include file getopt.h - found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/chen/liumeiti/package/x265_3.2/build/linux

编译

make -j2

安装

sudo make install

安装目录

Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/lib/libx265.a
-- Installing: /usr/local/include/x265.h
-- Installing: /usr/local/include/x265_config.h
-- Installing: /usr/local/lib/libx265.so.179
-- Installing: /usr/local/lib/libx265.so
-- Installing: /usr/local/lib/pkgconfig/x265.pc
-- Installing: /usr/local/bin/x265
-- Set runtime path of "/usr/local/bin/x265" to ""

复制库文件到/usr/lib文件夹下

cp /usr/local/lib/libx265.* /usr/lib

安装fdk-aac

克隆一份fdk-aac源码

https://gitee.com/xhh936/fdk-aac.git

进入源码文件夹生成configure

./autogen.sh 

设置安装到/usr路径下,动态链接,生成Makefile文件

./configure --prefix=/usr/ --enable-shared

configure失败参考这个:
https://blog.csdn.net/jinbaippdpdpdpdpd/article/details/63251756
然后重新执行./autogen.sh

编译

make -j4

然后安装

sudo make install

显示安装到了/usr/lib文件夹下

Libraries have been installed in:
   /usr/lib

安装ffmpeg

从官网下载好源码后,解压

tar -zxvf ffmpeg-4.3.tar.gz 

执行configure,生成Makefile

./configure --prefix=/usr/ --enable-shared --enable-libx264 --enable-gpl --enable-libfdk-aac --enable-nonfree --enable-libx265

编译

make -j4

安装

sudo make install

测试

执行FFmpeg命令

root@ubuntu:~#ffmpeg
ffmpeg version 4.3 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
  configuration: --prefix=/usr/ --enable-shared --enable-libx264 --enable-gpl --enable-libfdk-aac --enable-nonfree --enable-libx265 --disable-ffplay --disable-ffprobe
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

显示已经加载上x264,x265,fdk-aac库
测试FFmpeg代码如下:

#include <iostream>
using namespace std;
extern "C"{
#include <libavcodec/avcodec.h>
}
int main(int argc,char* argv[])
{
        cout<<avcodec_configuration()<<endl;
        return 0;
}

显示如下代表FFmpeg安装成功

--prefix=/usr/ --enable-shared --enable-libx264 --enable-gpl --enable-libfdk-aac --enable-nonfree --enable-libx265 --disable-ffplay --disable-ffprobe

Next

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值