2017-06-13 00:38:32 +02:00
|
|
|
#ifndef ENCODER_HPP
|
|
|
|
#define ENCODER_HPP
|
2017-06-11 23:56:06 +02:00
|
|
|
|
|
|
|
#include <QImage>
|
|
|
|
#include <QSize>
|
|
|
|
#include <formats.hpp>
|
|
|
|
extern "C" {
|
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
#include <libavformat/avformat.h>
|
|
|
|
#include <libswscale/swscale.h>
|
|
|
|
}
|
|
|
|
|
2017-06-13 00:38:32 +02:00
|
|
|
struct OutputStream {
|
|
|
|
AVStream *st = NULL;
|
|
|
|
AVCodecContext *enc = NULL;
|
|
|
|
|
|
|
|
int64_t nextPts = 0;
|
2017-06-11 23:56:06 +02:00
|
|
|
|
2017-06-13 00:38:32 +02:00
|
|
|
AVFrame *frame = NULL;
|
|
|
|
|
|
|
|
SwsContext *sws = NULL;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Encoder {
|
|
|
|
public:
|
|
|
|
Encoder(QString &targetFile, QSize res);
|
|
|
|
~Encoder();
|
2017-06-11 23:56:06 +02:00
|
|
|
bool addFrame(QImage frm);
|
|
|
|
bool isRunning();
|
2017-06-13 00:38:32 +02:00
|
|
|
bool end();
|
2017-06-11 23:56:06 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
AVCodec *codec = NULL;
|
2017-06-13 00:38:32 +02:00
|
|
|
|
|
|
|
OutputStream *out = new OutputStream;
|
|
|
|
AVFormatContext *fc = NULL;
|
2017-06-11 23:56:06 +02:00
|
|
|
AVPacket pkt;
|
|
|
|
|
|
|
|
bool success = false;
|
|
|
|
|
|
|
|
QSize size;
|
|
|
|
|
|
|
|
void setFrameRGB(uint8_t *rgb);
|
|
|
|
};
|
|
|
|
|
2017-06-13 00:38:32 +02:00
|
|
|
#endif // ENCODER_HPP
|