近段时间一直在忙着编译mac平台下ffmpeg库用于electron项目。搜索了很多资料才终于把整个编译过程整通过。
1.查看以下安装说明并安装ffmpeg依赖模块
http://blog.csdn.net/matrix_laboratory/article/details/53519165
http://blog.csdn.net/willib/article/details/52530328
2. 编译FFMPEG模块
#说明:
#FFMPEG版本:3.2.2
#配置命令:
./configure --enable-gpl --enable-version3 --enable-nonfree \
--enable-bzlib --enable-iconv --enable-zlib --enable-libopus \
--enable-libfdk-aac --enable-libx264 --enable-libvpx --enable-libfreetype \
--enable-fontconfig --enable-libass --enable-libssh \
--enable-static \
--disable-sdl2 \
--extra-ldflags=-L/usr/local/lib
#编译模块
make BITS=64
#安装模块至../../ffmpeg_dev64 目录
DESTDIR='../../ffmpeg_dev64' make install
#修正目录中模块
INSTALL_DIR=../../ffmpeg_dev64
cp -r $INSTALL_DIR/usr/local/ $INSTALL_DIR
rm -r $INSTALL_DIR/usr/
#清理垃圾
make clean
3.安装electron
#electron:
#安装1.4.4版本
npm install electron@1.4.4
4.配置node-gyp编译脚本
{
"targets":[
{
"target_name":"xxx",
'include_dirs': [
'.',
'../3rd-mac/ffmpeg/include',
'../3rd-mac/iojs/deps/uv/include',
'../3rd-mac/iojs/deps/npm',
'../3rd-mac/iojs/deps/v8',
'../3rd-mac/iojs/deps/http_parse',
'../3rd-mac/iojs/deps/zlib',
'../3rd-mac/iojs/src',
'/usr/local/include'
],
"sources":[
"RegisterModules.cpp",
"xxx.cpp",
],
'libraries': [
"-lstdc++",
"-lpthread",
"-lsdl2",
"-lavcodec",
"-lavdevice",
"-lavfilter",
"-lavformat",
"-lavutil",
"-lpostproc",
"-lswresample",
"-lswscale",
"-lopus",
"-logg",
"-lfdk-aac",
"-lvpx",
"-lass",
"-lx264",
"-liconv",
"-lfontconfig",
"-lfreetype",
"-lssh",
"-lssl",
"-lbz2",
"-lz",
"-llzma",
"-framework CoreGraphics",
"-framework CoreVideo",
"-framework Foundation",
"-framework AVFoundation",
"-framework CoreMedia",
"-framework QuartzCore",
"-framework AppKit",
"-framework OpenGL",
"-framework VideoDecodeAcceleration",
"-framework CoreFoundation",
"-framework CoreServices",
"-framework Security"
],
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',
'OTHER_CFLAGS':[
'-std=c++11',
'-stdlib=libc++'
]
},
'defines': [
],