1. 程式人生 > >在VS2010上搭建FFMPEG環境

在VS2010上搭建FFMPEG環境

參考: http://blog.yundiantech.com/?log=blog&id=7

  1. 下載FFMPEG

傳送門: https://ffmpeg.zeranoe.com/builds/

在這裡下載的是2.5.2-win32的版本。

步驟,按照 http://blog.yundiantech.com/?log=blog&id=7 這裡。

  1. 編寫程式碼等。

  1. 程式碼如下

    #include <iostream>

    using namespace std;

    extern "C"

    {

    #include "libavcodec/avcodec.h"

    #include "libavformat/avformat.h"

    #include "libswscale/swscale.h"

    #include "libavdevice/avdevice.h"

    };

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

    {

    cout<<"Test"<<endl;

    av_register_all();

    cout<<avcodec_version()<<endl;

    int aaa;

    cin>>aaa;

    }

  2. 編譯執行

    出現一些問題:

  3. 問題a:

    fatal error C1083: Cannot open include file: 'inttypes.h': No such file or directory

    原因:

    沒有找到標頭檔案。inttypes.h

    參考:http://blog.csdn.net/ly402609921/article/details/9030635

    解決方法:

    步驟一:下載 FFmpeg-full-SDK-3.2.rar,裡面有標頭檔案inttypes.h

    傳送門:http://download.csdn.net/detail/hslaiyaya/4423897    

    步驟二:將inttypes.h檔案拷貝到FFMPEG libavutil 目錄下面

    步驟三:將common.h檔案中,修改#include <inttypes.h>  #include "inttypes.h"

  4. 問題b:

    符號未解析:

    error LNK2019: unresolved external symbol _avcodec_version referenced in function _main

    error LNK2019: unresolved external symbol _av_register_all referenced in function _main

    原因:在vs2010中,沒有找到對應的lib檔案。

    解決方法:

    步驟一:

    右擊工程,點選屬性,配置工程--聯結器--通常--新增lib目錄

    步驟二:

    右擊工程,點選屬性,配置工程--聯結器--輸入--新增依賴

    步驟三:將ffmpeglib檔案,加入依賴項中

    步驟四:儲存,退出。

  5. 問題c:

    缺少動態庫

    原因:沒有找到ffmpeg的動態庫

    解決方法:

    步驟一:下載2.5.2-win32shared版本,將bin目錄下面的所有檔案拷貝到與應用程式一致的目錄

    1. 執行結果(成功)