(1)ffmpeg的编译和安装
http://blog.csdn.net/zhouzhenhe2008/article/details/48531355
(2)安装完成后,ffmpeg静态库将会出现在/usr/local/lib/
,即
libavcodec.a
libavdevice
libavfilter.a
libavformat.a
libavutil.a
libswresample.a
libswscale。
(3)安装后可以引用的头文件的位置 /usr/local/include/
(4)测试程序,保存为myfirst_ffmpeg.c,
编译命令:gcc -o a.out myfirst_ffmpeg.c -I /usr/local/include -L /usr/local/lib -lavutil -lavformat -lavcodec -lavutil -lswresample -lm -lrt -lpthread -lz
-
#include "libavformat/avformat.h"
-
#include "libavcodec/avcodec.h"
-
#include "libavutil/avutil.h"
-
#include "stdio.h"
-
int main(int argc, char* argv[])
-
{
-
printf("going to av_register_all\n");
-
av_register_all();
-
return 0;
-
}
(5)可能遇到的问题。
a.
timeval.c:(.text+0x6f): undefined reference to `clock_gettime'
解决:
则你只需要在你的编译命令加上 -lrt 编译即可
b.
/share/FFmpeg-master/libavcodec/opusdec.c:379: undefined reference to `swr_is_initialized'
/usr/local/lib/libavcodec.a(opusdec.o): In function `opus_decode_frame':
/share/FFmpeg-master/libavcodec/opusdec.c:220: undefined reference to `swr_is_initialized
解决:
编译加上-lswresample
c.忘记为什么要执行下面这条了
cp /usr/local/lib/pkgconfig/* /usr/share/pkgconfig/