#ifndef INT64_C
#define INT64_C(c)
(c ## LL)
#define UINT64_C(c)
(c ## ULL)
#endif
(4)假设此时再次编译project,还是会有错误,错误原因是我们新建的win 32 c++project直接调用ffmpeg的c函数库,导致c函数无法解析。对于这样因为c++和c函数名编译后命名机制不同导致无法解析的问题。仅仅需在引用c函数库时加入extern "C"就可以,当然还有引用lib库。改动后的代码例如以下:
#include "stdafx.h"
#include
#include
extern "C"
{
#include
#include
}
#pragma comment(lib, "avformat.lib")
#pragma comment(lib, "avutil.lib")
int main ()
{
AVFormatContext *fmt_ctx = NULL;
AVDictionaryEntry *tag = NULL;
int ret = 0;
av_register_all();
if ((ret = avformat_open_input(&fmt_ctx, "iphone.mp3", NULL, NULL)))
{
return ret;
}
while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
{
printf("%s=%s\n", tag->key, tag->value);
}
avformat_close_input(&fmt_ctx);
system("pause");
return 0;
}
此时能够顺利编译通过了,执行结果例如以下:
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMzA4NTg5Nw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">
当然,随着开发的深入,在使用uint8_t、int64_t等数据类型时,编译器会报例如以下错误:fatal error C1083: Cannot open include file: 'stdint.h': No such
file or directory,即找不到相关头文件。该头文件的压缩包能够在我上传的project文件文件夹内找到。解压缩后将两个头文件拷贝至Microsoft Visual Studio 8/vc/include文件夹就可以。
因为project执行依赖的几个dll体积比較大,所以在上传project时本人将其删掉了,该dll能够到文中提到的链接下载。即: