FFmpeg编译支持x264/openH264/dash

下载编译FFmpeg代码

git clone https://github.com/FFmpeg/FFmpeg.git

cd FFmpeg
mkdir out
cd out

../configure --enable-static --enable-shared --enable-libx264 --enable-gpl \
--enable-nonfree --enable-sdl --enable-ffplay --disable-optimizations --enable-debug \
--extra-cflags=-g --enable-libfdk-aac --enable-libopenh264 --enable-libx264 \
--enable-demuxer=dash --enable-libxml2 --enable-libmp3lame

sudo make -j8 install

这个configure项是已经解决了依赖问题,有些库可以直接安装dev库,有些需要自己编译,安装方法在后面。

这里建一个out目录,编译生成的临时文件都会放在out目录下,不会存在于代码目录,看着干净很多。

--extra-cflags=-g是为了生成debug信息,方便我随时使用vscode或者qtcreator进行调试跟踪代码。

安装依赖库

sudo apt install nasm
sudo apt install libsdl2-dev 
sudo apt install libsdl2-dev 
sudo apt install libxcb-dev
sudo apt install libxcb-xfixes0-dev
sudo apt install libxcb-shm0-dev 
sudo apt install lksctp-tools-dev
sudo apt install libsctp-dev
sudo apt install libfdk-aac-dev 
sudo apt install libx264-dev 
sudo apt install liblz-dev 
sudo apt install liblzma-dev 
sudo apt install libfdk-aac-dev 

enable dash demuxer

增加:--enable-demuxer=dash --enable-libxml2

--enable-static --enable-shared --enable-libx264 --enable-gpl --enable-nonfree --enable-sdl \
--enable-ffplay --disable-optimizations --enable-debug --extra-cflags=-g \
--enable-libfdk-aac --enable-libopenh264 --enable-libx264 --enable-demuxer=dash 

编译libx264依赖

git clone https://github.com/mirror/x264.git
cd x264
./configure
sudo make install

编译openh264依赖

git clone https://github.com/cisco/openh264.git
cd openh264
meson build
sudo ninja -C build/ install

编译libxml2依赖

git clone https://github.com/GNOME/libxml2.git
./autogen.sh
./configure
sudo make -j8 install

找不到pyton2.7

checking for PYTHON... no
configure: error: Package requirements (python-2.7) were not met:

No package 'python-2.7' found

发现ubuntu20.04上已经没有源能安装pyton2.7-dev,所以就找了下电脑上以后的,实际上开发项目比较多的话会有很多可以用的,不用自己安装了:

locate *.pc | grep "python-2.7.pc"
/home/hui/disk4t/codes/gstreamer/gst-open-source/build/android-ndk-18/prebuilt/\
linux-x86_64/lib/pkgconfig/python-2.7.pc

配置PKG_CONFIG_PATH后重新configure,然后再执行sudo make install(默认路径/usr/local/lib/pkgconfig/libxml-2.0.pc):

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/hui/disk4t/codes/gstreamer/\
gst-open-source/build/android-ndk-18\/prebuilt/linux-x86_64/lib/pkgconfig/

当然,还需要配置下cflags和ldflags,如下就可以了:

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:"/home/hui/disk4t/codes/gstreamer/\
gst-open-source/build/android-ndk-18\/prebuilt/linux-x86_64/lib/pkgconfig/"

export PYTHON27_INC="/home/hui/disk4t/codes/gstreamer/gst-open-source/build/\
android-ndk-18/prebuilt/linux-x86_64/include/python2.7"

export PYTHON27_LIBS="/home/hui/disk4t/codes/gstreamer/gst-open-source/build/\
android-ndk-18/prebuilt/linux-x86_64/lib/"


./configure CFLAGS="-I${PYTHON27_INC}" LDFLAGS="-L${PYTHON27_LIBS}/lib" --without-python


apt search xxx可以查找一些库可用apt安装的版本,找到之后,然后通过sudo apt install xxx安装即可。

比如:

$ apt search libogg
Sorting... Done
Full Text Search... Done
libogg-dbg/focal 1.3.4-0ubuntu1 amd64
  debugging symbols for libogg

libogg-dev/focal,now 1.3.4-0ubuntu1 amd64 [installed,automatic]
  Ogg bitstream library development files

libogg0/focal,now 1.3.4-0ubuntu1 amd64 [installed,automatic]
  Ogg bitstream library

安装:

$ sudo apt install libogg-dev

你可能感兴趣的:(FFmpeg,media,dash,git,jenkins)