xcal
基于 C++23 的现代图形渲染引擎
载入中...
搜索中...
未找到
ffmpegcodec.hpp
浏览该文件的文档.
1#ifndef VIDEO_ENCODER_H
2#define VIDEO_ENCODER_H
3
4#include <xcal/public.h>
5
6#include <string>
7#include <vector>
9
10extern "C" {
11struct AVFormatContext;
12struct AVCodecContext;
13struct AVStream;
14struct AVFrame;
15struct AVFrame;
16struct SwsContext;
17struct AVPacket;
18}
20
22 public:
23 FfmpegCodec(const std::string& filename, int width, int height,
24 int frame_rate);
26
27 bool_t open() override;
28 bool_t append_frame(const std::vector<char>& rgba_data) override;
29 bool_t finish() override;
30
31 int encoded_frames() const { return encoded_frames_; }
32
33 private:
34 bool encode_frame(AVFrame* frame);
35 bool write_packet(AVPacket* packet);
36 bool setup_scaler();
37
38 int encoded_frames_;
39
40 // FFmpeg相关资源
41 AVFormatContext* format_ctx_;
42 AVCodecContext* codec_ctx_;
43 AVStream* video_stream_;
44 AVFrame* frame_;
45 AVFrame* rgba_frame_;
46 SwsContext* sws_ctx_;
47
48 bool initialized_;
49 bool finished_;
50};
51} // namespace xcal::render::codec
52
53#endif // VIDEO_ENCODER_H
bool bool_t
Definition public.h:28
#define XCAL_CODEC_API
Definition public.h:78