FFRecoder2.h
747 Bytes
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
#pragma once
#include <memory>
class AVFrame;
class AVStream;
class AVCodecContext;
class AVFormatContext;
class AVPacket;
class FFRecoder2
{
public:
FFRecoder2();
~FFRecoder2();
bool init(int w, int h, int fps, int bit_rate, const char* outfile_name);
void uninit();
bool write_image(const uint8_t* bgr);
bool write_yuv(const uint8_t* yuv_data);
bool write_frame(const AVFrame* frame);
bool write_pkt(AVPacket* pkt);
bool flush();
bool close();
private:
bool bgr_to_yuv420p(const uint8_t* const buf_bgr, uint8_t* const buf_420p);
private:
int width_;
int height_;
int y_size_;
int uv_size_;
int pts_;
AVCodecContext* codec_ctx_;
AVFormatContext* fmt_ctx_;
AVStream* out_stream_;
AVFrame* yuv_frame_;
int frame_nb{0};
};