문제

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