#pragma once #include #include #include #include extern "C" { #include #include #include } #include "system/loggerd/encoder/encoder.h" #include "system/loggerd/loggerd.h" class FfmpegEncoder : public VideoEncoder { public: FfmpegEncoder(const EncoderInfo &encoder_info, int in_width, int in_height) : VideoEncoder(encoder_info, in_width, in_height) { encoder_init(); } ~FfmpegEncoder(); void encoder_init(); int encode_frame(VisionBuf* buf, VisionIpcBufExtra *extra); void encoder_open(const char* path); void encoder_close(); private: int segment_num = -1; int counter = 0; bool is_open = false; AVCodecContext *codec_ctx; AVFrame *frame = NULL; std::vector convert_buf; std::vector downscale_buf; };