在VS2010上搭建FFMPEG環境
參考: http://blog.yundiantech.com/?log=blog&id=7
下載FFMPEG
傳送門: https://ffmpeg.zeranoe.com/builds/
在這裡下載的是2.5.2-win32的版本。
步驟,按照 http://blog.yundiantech.com/?log=blog&id=7 這裡。
編寫程式碼等。
程式碼如下
#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;
}
編譯執行
出現一些問題:
問題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"
問題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目錄
步驟二:
右擊工程,點選屬性,配置工程--聯結器--輸入--新增依賴
步驟三:將ffmpeg的lib檔案,加入依賴項中
步驟四:儲存,退出。
問題c:
缺少動態庫
原因:沒有找到ffmpeg的動態庫
解決方法:
步驟一:下載2.5.2-win32的shared版本,將bin目錄下面的所有檔案拷貝到與應用程式一致的目錄
執行結果(成功)