質問

In my case, I'm experimenting with QtMultimedia and libffmpeg as decoder. Imported ffmpeg as extern "C", but the ffmpeg's AVPixelFormat collides with QVideoFrame's PixelFormat.

Exact error:

'AVPixelFormat' : is not a member of 'QVideoFrame'

Does anyone know a possible solution?

EDIT: Code parts.

Part 1: Qt VideoWidget Sample

Part 2: Usage of libffmpeg, based on dranger tutorial

extern "C"
{
    #include <libavcodec/avcodec.h>
    #include <libavformat/avformat.h>
    #include <libswscale/swscale.h>
}
役に立ちましたか?

解決

This is caused by the following line in the FFmpeg's pixfmt.h:

#define PixelFormat AVPixelFormat

You can try the following trick then:

extern "C"
{
    #include <libavcodec/avcodec.h>
    #include <libavformat/avformat.h>
    #include <libswscale/swscale.h>
}

#undef PixelFormat
#include <qt headers>

他のヒント

You can't blindly extern "C" the headers if they contain C++ code. Even if you make it past that collision you're going to run into problems at link time when your calls try to link to the "C" symbols but the ffmpeg library exports them with C++ linkage.

If you're trying to export C symbols, my advice would be to create a wrapper function that exports C but makes the C++ calls into the library.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top