Frage

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>
}
War es hilfreich?

Lösung

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>

Andere Tipps

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top