1.安装ffmpeg1.获取依赖包可以按照以下网址联网下载最新版本或者使用安装包里面的软件
yasm
x264
fdk-acc
ame
opus
ogg
vorbis
libvpx
xvidcore
libtheora
2.安装依赖包Yasmtar zxvf yasm-1.3.0.tar.gz cd yasm-1.3.0 ./configure --prefix=/usr/local/cellar/ffmpeg_build --bindir=/usr/bin make && make install
x264tar axf last_x264.tar.bz2 cd last_x264 ./configure \ --prefix=/usr/local/cellar/ffmpeg_build \ --bindir=/usr/bin \ --enable-shared make && make install
fdk-acctar zxvf fdk-aac-0.1.4.tar.gz cd fdk-aac-0.1.4 autoreconf -fiv ./configure --prefix=/usr/local/cellar/ffmpeg_build --disable-shared make && make install
Lametar zxvf lame-3.99.5.tar.gz cd tar zxvf lame-3.99.5 ./configure --prefix=/usr/local/cellar/ffmpeg_build --bindir=/usr/bin --disable-shared --enable-nasm make && make install
Opustar zxvf opus-1.1.tar.gz cd opus-1.1 autoreconf -fiv ./configure --prefix=/usr/local/cellar/ffmpeg_build --disable-shared make && make install
oggtar zxvf libogg-1.3.2.tar.gz cd tar zxvf libogg-1.3.2 ./configure --prefix=/usr/local/cellar/ffmpeg_build --disable-shared make && make install
vorbistar zxvf libvorbis-1.3.5.tar.gz cd libvorbis-1.3.5 ./configure --prefix=/usr/local/cellar/ffmpeg_build --with-ogg=/usr/local/cellar/ffmpeg_build --disable-shared make && make install
Libvpxcd libvpx ./configure --prefix=/usr/local/cellar/ffmpeg_build --disable-examples make && make install
Xvidcoretar zxvf xvidcore-1.3.4.tar.gz cd xvidcore/build/generic/ ./configure --prefix=/usr/local/cellar/ffmpeg_build make && make install
Libtheoratar zxvf libtheora-1.1.1.tar.gz cd libtheora-1.1.1 ./configure --prefix=/usr/local/cellar/ffmpeg_build --with-ogg=/usr/local/cellar/ffmpeg_build --disable-examples --disable-shared --disable-sdltest --disable-vorbistest
Freetypetar zxvf freetype-2.3.5.tar.gz cd freetype-2.3.5 ./configure --prefix=/usr/local/cellar/ffmpeg_build
3.安装ffmpegtar axf ffmpeg-2.7.2.tar.bz2 cd ffmpeg-2.7.2 export PKG_CONFIG_PATH=/usr/local/cellar/ffmpeg_build/lib/pkgconfig
CFLAGS="-fPIC -m64" ./configure \ --prefix=/usr/local/cellar/ffmpeg \ --extra-cflags="-I/usr/local/cellar/ffmpeg_build/include" \ --extra-ldflags="-L/usr/local/cellar/ffmpeg_build/lib" \ --extra-libs=-ldl \ --bindir=/usr/bin \ --enable-version3 \ --enable-zlib \ --enable-bzlib \ --enable-pic \ --enable-gpl \ --enable-nonfree \ --enable-pthreads \ --enable-libfdk_aac \ --enable-libfreetype \ --enable-libmp3lame \ --enable-libopus \ --enable-libvorbis \ --enable-libvpx \ --enable-libx264
此处出现问题,请访问http://rickie622.blog.163.com/blog/static/212388112014113125836773/尝试解决 确认Makefile中指定的config.mak(在ffmpeg根目录下)中:CONFIG_FFPLAY=yes,用来生成ffplay
make && make install
4.验证是否安装成功ffmpeg -version
如果报如下类似错误 ffmpeg: error while loading shared libraries: libx264.so.146: cannot open shared object file: No such file or directory 解决办法是: vi /etc/ld.so.conf 将 /usr/local/cellar/ffmpeg_build/lib 加到ld.so.conf文件末尾 然后执行命令: Ldconfig
5.编译ffmpeg
1.out: g++ testCode.cc -o main.out -L"/usr/local/cellar/ffmpeg/lib" -L"/usr/local/cellar/ffmpeg_build/lib" -I"/usr/local/cellar/ffmpeg/include" -I"/usr/local/cellar/ffmpeg_build/include" -lavformat -lavdevice -lavcodec -lavutil -lavfilter -lpostproc -lswresample -lswscale -lSDL -lxvidcore -lx264 -lpthread -ltheora -ltheoraenc -ltheoradec -lvorbis -lvorbisenc -lvpx -lopus -logg -lmp3lame -lfdk-aac -lm -lz -lpthread -lrt (责任编辑:IT) |