-
Notifications
You must be signed in to change notification settings - Fork 4
/
FrameWriter.hpp
46 lines (36 loc) · 1.05 KB
/
FrameWriter.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef _FRAMEWRITER_H
#define _FRAMEWRITER_H
#include <string>
#include <stdint.h>
#include <stdexcept>
extern "C" {
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavutil/avutil.h>
};
using namespace std;
class FrameWriter {
protected:
int width, height, pixfmt, bitrate;
float framerate;
AVFormatContext *oc;
AVCodecContext *c;
AVCodec *pCodec;
AVStream *videoStream;
uint8_t *outbuf;
int outbufSize;
double video_pts;
uint64_t pts;
void OpenVideo();
AVStream* AddVideoStream(int width, int height, int pixfmt, AVCodecID codec_id, int bitrate);
public:
static void SaveFrame(const string &filename, AVFrame *pframe, int width, int height, int pixfmt);
FrameWriter(const string &filename, int width, int height, int pixfmt, float framerate, int bitrate);
void WriteVideoFrame(AVFrame *pframe);
~FrameWriter();
};
class FrameWriterException : public runtime_error {
public:
FrameWriterException(const string &str):runtime_error(str){};
};
#endif //_FRAMEWRITER_H