我的第一個ffmpeg程式(編譯及呼叫ffmpeg函式)

zhouzhenhe2008發表於2017-01-03


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



相關文章