You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
689 B
31 lines
689 B
4 months ago
|
#ifndef FFMPEG_ENCODER_H
|
||
|
#define FFMPEG_ENCODER_H
|
||
4 months ago
|
|
||
|
#include <QImage>
|
||
|
|
||
|
extern "C" {
|
||
|
#include <libavcodec/avcodec.h>
|
||
|
#include <libavformat/avformat.h>
|
||
|
#include <libswscale/swscale.h>
|
||
|
}
|
||
|
|
||
|
class FFmpegEncoder {
|
||
|
public:
|
||
|
FFmpegEncoder(const QString& outputFile, int width, int height, int fps);
|
||
|
~FFmpegEncoder();
|
||
|
bool writeFrame(const QImage& image);
|
||
|
|
||
|
private:
|
||
|
bool initialized = false;
|
||
4 months ago
|
int64_t frame_count = 0;
|
||
4 months ago
|
AVFormatContext* format_ctx = nullptr;
|
||
|
AVStream* stream = nullptr;
|
||
4 months ago
|
AVCodecContext* codec_ctx = nullptr;
|
||
4 months ago
|
AVFrame* frame = nullptr;
|
||
|
AVPacket* packet = nullptr;
|
||
|
SwsContext* sws_ctx = nullptr;
|
||
4 months ago
|
|
||
|
bool encodeFrame(AVFrame* input_frame);
|
||
|
};
|
||
|
|
||
|
#endif // FFMPEG_ENCODER_H
|