vendredi 3 mai 2019

invalid new-expression of abstract class type 'PGMFileSink' [duplicate]

This question already has an answer here:

I'm wanting to decode a video with a ffmpegwrapper, but I've got a invalid new-expression of abstract class error on the 'PGMFileSink'. I think there is something wrong with the inheritance of the header files, but I can't figure out what. when I want to add override after the write frame function in main.cpp It gives the error that it is not overridden.

main.cpp:

class PGMFileSink : public VideoFrameSink, public FrameWriter
{
public:

    PGMFileSink()
    {
    }

    FrameSinkStream* CreateStream()
    {
        stream = new FrameSinkStream(this, 0);
        return stream;
    }
    virtual void WriteFrame(int streamIndex, AVFrame* frame, AVRational* timeBase)
    {
        ++frameNumber;
        printf("saving frame %3d\n", frameNumber);
        fflush(stdout);

        // write the first channel's color data to a PGM file.
        // This raw image file can be opened with most image editing programs.
        snprintf(fileNameBuffer, sizeof(fileNameBuffer), "pgm-%d.pgm", frameNumber);
        pgm_save(frame->data[0], frame->linesize[0],
            frame->width, frame->height, fileNameBuffer);
    }
...
}

and

int main()
{
...
        PGMFileSink* fileSink = new PGMFileSink();
...
}

videoframesink.h:

#pragma once

#include "FrameSink.h"

namespace ffmpegcpp
{
    class VideoFrameSink : public FrameSink
    {
    public:

        virtual ~VideoFrameSink() {}
    };
}

framewriter.h:

#pragma once

#include "../ffmpeg.h"
#include "../Demuxing/StreamData.h"

namespace ffmpegcpp
{
    class FrameWriter
    {
    public:

        virtual void WriteFrame(int streamIndex, AVFrame* frame, StreamData* metaData) = 0;

        virtual void Close(int streamIndex) = 0;

        virtual bool IsPrimed() = 0;
    };
}

Aucun commentaire:

Enregistrer un commentaire