我的第一个ffmpeg程序(编译及调用ffmpeg函数)

(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

 
  1. #include "libavformat/avformat.h"

  2. #include "libavcodec/avcodec.h"

  3. #include "libavutil/avutil.h"

  4. #include "stdio.h"

  5. int main(int argc, char* argv[])

  6. {

  7. printf("going to av_register_all\n");

  8. av_register_all();

  9. return 0;

  10. }

(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/

猜你喜欢

转载自blog.csdn.net/special00/article/details/82596785
今日推荐