一、概述
本文旨在介绍如何在VS 2010下使用FFmpeg编译好的库。
二、操作步骤
1、把编译好的FFmpeg中的.h,.lib,.dll拷贝到工程中去,如图所示:
3、在_mingw.h文件的结尾处(在#endif 一行之前)添加了一行:#define __restrict__(解决inttypes.h有问题的错误)
4、在程序中添加如下代码:
#ifdef __cplusplus
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
<span style="color:#006600;">#include "SDL2/SDL.h"</span>
extern "C"
{
#include "include/libavutil/avutil.h"-----为工程的include目录,我的是"include/libavutil/avutil.h"
#include "include/libavcodec/avcodec.h"
#include "include/libavformat/avformat.h"
#include "include/libswscale/swscale.h"
}
#endif
#pragma comment(lib,"lib/avutil.lib")
#pragma comment(lib,"lib/avcodec.lib")
#pragma comment(lib,"lib/avformat.lib")
#pragma comment(lib,"lib/swscale.lib")
<span style="color:#006600;">#pragma comment(lib,"lib/SDL2.lib")
#pragma comment(lib,"lib/SDL2main.lib")</span>
#include <stdio.h>
如果要使用sdl的话,还需要将sdl的.h,.lib ,.dll文件拷贝到相应的目录中去,然后添加:
#include "SDL2/SDL.h"
#pragma comment(lib,"SDL.lib")
#pragma comment(lib,"SDL2main.lib")
这就是我移植时所做的操作。还可以参考以下博客的内容:
http://blog.csdn.net/leixiaohua1020/article/details/12747899