-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVideoEncodeFF.h
46 lines (33 loc) · 920 Bytes
/
VideoEncodeFF.h
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
#pragma once
#include "VideoEncode.h"
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswresample/swresample.h>
#include <libavutil/avutil.h>
#include <libavutil/opt.h>
}
#define WRITE_CAPTURE_264
class VideoEncodeFF : public VideoEncoder
{
public:
int InitEncode(int width, int height, int fps, int bitrate, const char* profile)override;
unsigned int Encode(unsigned char* src_buf, unsigned char* dst_buf)override;
int StopEncode()override;
const uint8_t* const GetExterdata() {
return videoCodecCtx->extradata;
}
const int const GetExterdataSize() {
return videoCodecCtx->extradata_size;
}
void CopySpsPps(uint8_t* src,int size);
private:
AVPacket* pkt;
AVFrame* frame;
AVCodecContext* videoCodecCtx;
#ifdef WRITE_CAPTURE_264
FILE* h264_out_file = nullptr;
#endif // WRITE_CAPTURE_YUV
uint64_t pts = 0;
bool receive_first_frame = true;
};