我正在尝试使用共享库支持编译ffmpeg,因为当我静态编译它时,最终会生成大型库,例如libavcodec.a
,大小为75MB。我针对libavcodec
编译的任何程序的大小至少为50MB。这只发生在我的RaspberryPi上,如果我这样做
ls -lsth $(which ffmpeg)
在我的RPI3上我得到了
15M -rwxr-xr-x 1 pi pi 15M Jul 29 21:49 /home/pi/camiocam/cam/binaries/bin//ffmpeg
如果我在我的macbook上做同样的事情,我会得到这个输出
488 -r-xr-xr-x 1 john admin 242K Jul 26 19:34 /usr/local/Cellar/ffmpeg/3.1.1/bin/ffmpeg
为了获得共享库支持,我做了以下
# download and install libx264
cd ~/ffmpeg_build
git clone git://git.videolan.org/x264.git
cd x264
PATH="$HOME/bin:$PATH" ./configure --host=arm-unknown-linux-gnueabi --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-shared --disable-opencl
# PATH="$HOME/bin:$PATH" make -j 8
# PATH="$HOME/bin:$PATH" make install
# ldconfig
和......
# to install ffmpeg
cd ~/ffmpeg_sources
wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --arch=armel --target-os=linux --extra-cflags="-I$HOME/ffmpeg_build/include" --enable-pic --extra-ldflags="-L$HOME/ffmpeg_build/lib" --bindir="$HOME/bin" --enable-gpl --enable-libx264 --enable-nonfree --enable-shared
PATH="$HOME/bin:$PATH" make -j 8
提供此输出
License: nonfree and unredistributable
Creating config.mak, config.h, and doc/config.texi...
config.h is unchanged
libavutil/avconfig.h is unchanged
libavcodec/bsf_list.c is unchanged
libavformat/protocol_list.c is unchanged
CC libavcodec/libx264.o
POD doc/ffprobe.pod
POD doc/ffmpeg-all.pod
POD doc/ffserver-all.pod
POD doc/ffmpeg.pod
POD doc/ffprobe-all.pod
POD doc/ffserver.pod
MAN doc/ffprobe.1
MAN doc/ffmpeg.1
MAN doc/ffserver.1
MAN doc/ffmpeg-all.1
MAN doc/ffprobe-all.1
MAN doc/ffserver-all.1
GEN libavcodec/libavcodec.ver
LD libavcodec/libavcodec.so.57
AR libavcodec/libavcodec.a
LD libavformat/libavformat.so.57
LD libavfilter/libavfilter.so.6
LD libavdevice/libavdevice.so.57
library.mak:102: recipe for target 'libavdevice/libavdevice.so.57' failed
make: *** [libavdevice/libavdevice.so.57] Killed
make: *** Deleting file 'libavdevice/libavdevice.so.57'
我已尝试将--enable-pic
标志添加到ffmpeg configure命令中,但这没有任何区别。