ffmpeg-2.4.3实现硬字幕添加
一、ffmpeg-v2.4.3的库安装
1. zlib-1.2.3.tar.bz2
$ tar -jxvf zlib-1.2.3.tar.bz2
$ cd zlib-1.2.3
$ ./configure --prefix=/INSTALL_PATH/3rd-lib-install
$ make
$ make install
2. faac-1.28.tar.gz
$ tar -zxvf faac-1.28.tar.gz
$ cd faac-1.28
$ ./configure --prefix=/INSTALL_PATH/3rd-lib-install --enable-static --disable-shared
$ make
$ make install
3. lame-3.98.4.tar.gz
$ tar -zxvf lame-3.98.4.tar.gz
$ cd lame-3.98.4
$ ./configure --prefix=/INSTALL_PATH/3rd-lib-install --enable-static --disable-shared
$ make
$ make install
4. x264
$ cd x264
$ ./configure --prefix=/INSTALL_PATH/3rd-lib-install --enable-static --disable-shared --disable-opencl
$ make
$ make install
5. fontconfig
$ wget https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.11.1.tar.gz
$ cd fontconfig-2.11.1
$ ./configure --prefix=/INSTALLPATH/3rd-lib-install --enable-static --disable-shared
...
checking for struct statvfs.f_basetype... no
checking for struct statvfs.f_fstypename... no
checking for struct statfs.f_flags... no
checking for struct statfs.f_fstypename... no
checking for struct dirent.d_type... yes
checking for FREETYPE... no
configure: error: Package requirements (freetype2) were not met:
No package 'freetype2' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables FREETYPE_CFLAGS
and FREETYPE_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
解决办法:
yum install freetype-devel
6. libass
下载链接:
https://github.com/libass/libass/tree/0.10.2
$ unzip libass-0.10.2.zip
$ cd libass-0.10.2
$ ./autogen.sh
Running autoreconf...
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I m4
autoreconf: configure.ac: tracing
autoreconf: configure.ac: not using Libtool
autoreconf: running: /usr/local/bin/autoconf --force
configure.ac:7: error: possibly undefined macro: AC_PROG_LIBTOOL
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
configure.ac:33: error: possibly undefined macro: AC_DEFINE
autoreconf: /usr/local/bin/autoconf failed with exit status: 1
Running configure...
configure: error: cannot find install-sh, install.sh, or shtool in "." "./.." "./../.."
原因分析
aclocal是个扫描程序, 负责扫描configure.ac中所有的宏定义并展开,
上面产生的原因就是找不到LIBTOOL宏的定义之处造成的.
原因就是aclocal与libtool没有安装在一个相同目录下面
aclocal是去默认 安装目录 /usr/share/aclocal下面搜索所有的.m4文件找所定义的宏,
但是由于安装了多个aclocal,可能aclocal目录不存在,实际目录为/usr/share/aclocal1.10等,
这就造成了aclocal找不到m4文件的情况, 解决办法就是将文件夹aclocal1.10重命名为aclocal.
或者显示指定路径 aclocal -I /usr/share/aclocal1.10 -I /usr/share/libtool/m4 --install
或者把/usr/share/libtool/m4下面的文件都copy至/usr/share/aclocal1.10中.
解决办法:
安装libtool
$ wget http://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.gz
$ tar -zxvf libtool-2.4.6.tar.gz
$ cd libtool-2.4.6
$ ./configure && make && make install
$./autogen.sh
Running autoreconf...
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I m4
autoreconf: configure.ac: tracing
autoreconf: running: libtoolize --copy --force
libtoolize: putting auxiliary files in '.'.
libtoolize: copying file './ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: copying file 'm4/libtool.m4'
libtoolize: copying file 'm4/ltoptions.m4'
libtoolize: copying file 'm4/ltsugar.m4'
libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
autoreconf: running: /usr/local/bin/autoconf --force
configure.ac:33: error: possibly undefined macro: AC_DEFINE
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
autoreconf: /usr/local/bin/autoconf failed with exit status: 1
Running configure...
configure: error: cannot find install-sh, install.sh, or shtool in "." "./.." "./../.."
解决办法:
若是ubuntu下:
sudo apt-get install libtool
libsysfs-dev
若是Centos下:
yum install libtool
yum install libsysfs
或重新安装pkg-config
$ wget https://pkg-config.freedesktop.org/releases/pkg-config-0.29.tar.gz
$ tar -zxvf pkg-config-0.29.tar.gz
$ cd pkg-config-0.29
$ ./configure --with-internal-glib
$ make && make install
$ ./autogen.sh
...
checking for FRIBIDI... no
configure: error: Package requirements (fribidi >= 0.19.0) were not met:
No package 'fribidi' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables FRIBIDI_CFLAGS
and FRIBIDI_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details
解决办法:
$ yum install fribidi
或
$ git clone git://anongit.freedesktop.org/fribidi/fribidi
$ cd fribidi
$ ./configure --enable-static --disable-shared
$ make && make install
$ cd libass-0.10.2
$ ./autogen.sh
$ ./configure --prefix=/INSTALL_PATH/3rd-lib-install --enable-static --disable-shared
$ make
make all-recursive
make[1]: Entering directory `/INSTALL_PATH/3rd-lib-package/libass-0.10.2'
Making all in libass
make[2]: Entering directory `/INSTALL_PATH/3rd-lib-package/libass-0.10.2/libass'
CCLD libass.la
/usr/bin/ld: /usr/local/lib/libenca.a(encnames.o): relocation R_X86_64_32S against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libenca.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [libass.la] Error 1
make[2]: Leaving directory `/INSTALL_PATHs/3rd-lib-package/libass-0.10.2/libass'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directo
$ ./configure --prefix=/INSTALL_PATH/3rd-lib-install --enable-static --disable-shared
$ make && make install
二、ffmpeg-v2.4.3的编译配置
./configure \
--enable-debug=3 --disable-stripping \
--disable-lzma --enable-gpl --enable-nonfree --enable-version3 \
--enable-pthreads --enable-runtime-cpudetect \
--disable-shared --enable-static \
--enable-zlib --enable-bzlib --enable-swscale \
--enable-postproc \
--extra-cflags=-I'../3rd-lib-install/include/ -DREDIRECT_DEBUG_LOG' \
--extra-ldflags=-L'../3rd-lib-install/lib/ -gl' \
--disable-encoder=aac \
--enable-libx264 --enable-encoder=libx264 \
--enable-libfaac --enable-encoder=libfaac \
--enable-libmp3lame --enable-encoder=libmp3lame \
--enable-avfilter --enable-filter=movie \
--enable-fontconfig --extra-libs=-lexpat --enable-libass
config.log中的错误提示:
check_pkg_config fontconfig fontconfig/fontconfig.h FcInit
pkg-config --exists --print-errors fontconfig
Package fontconfig was not found in the pkg-config search path.
Perhaps you should add the directory containing `fontconfig.pc'
to the PKG_CONFIG_PATH environment variable
No package 'fontconfig' found
ERROR: fontconfig not found
解决办法:
$ export PKG_CONFIG_PATH=../3rd-lib-install/lib/pkgconfig/:$PKG_CONFIG_PATH
或:
$ vim vim /etc/profile
#在最后一行添加:
export PKG_CONFIG_PATH=/opt/ABSTRACT_PATH/3rd-lib-install/lib/pkgconfig/:$PKG_CONFIG_PATH
【保存并退出】
$ source /etc/profile
三、测试字幕添加
命令:
$ ffmpeg -i <INPUT> -vf subtitles=<SUBTITLE> -f mp4 test.mp4

浙公网安备 33010602011771号