ommon.h(30) : fatal error C1189: #error : missing -D__STDC_CONSTANT_MACROS / #define __STDC_CONSTANT_MACROS
原因:
FFmpeg is written in C99, thus some features may not be compilable or usable in C++.
Anyway, for most purposes, including FFmpeg headers in a C++ application should be rather straightforward.
First, to include the FFmpeg headers within your C++ application you need to explicitly state that you are including C code. You can do this by encompassing your FFmpeg includes usingextern "C", like in:
extern "C" { #include <libavutil/imgutils.h> #include <libavcodec/avcodec.h> #include <libswscale/swscale.h> }
Second, you may need to append -D__STDC_CONSTANT_MACROS to your CXXFLAGS flags, if the compiler complains about ’UINT64_C’ was not declared in this scope.
解决办法:
extern "C"
{
#ifdef __cplusplus
#define __STDC_CONSTANT_MACROS
#endif
}
编译又提示错误:
错误二: error C3861: “UINT64_C”: 找不到标识符
解决方法:在common.h中添加如下代码:
#ifndef INT64_C
#define INT64_C(c) (c ## LL)
#define UINT64_C(c) (c ## ULL)
#endif
ffmpeg v2.1 的api和v1.2.1api对比,修改了几个地方:
1)v1.2.1 frame = avcodec_alloc_frame();
v.2.1 frame = av_frame_alloc();
2)v.1.2.1 avcodec_free_frame(&frame);
v.2.1 av_frame_free(&frame);