#ifndef SCAR_VIDEO_ENCODER_H #define SCAR_VIDEO_ENCODER_H #include #include #include extern "C" { #include #include #include #include } namespace scar { class VideoEncoder { public: VideoEncoder(); ~VideoEncoder(); // Initialize encoder // bitrate in bits per second (default 2Mbps) // spa_format: SPA video format from PipeWire (0 = auto-detect as BGR0) bool initialize(int width, int height, int fps, int bitrate = 2000000, uint32_t spa_format = 0); // Encode a raw frame (BGR0 format from PipeWire) // Returns encoded packet data, empty if error or no packet yet std::vector encode(const uint8_t* frame_data, uint32_t frame_size); // Flush any remaining frames std::vector flush(); // Cleanup void cleanup(); private: AVCodecContext* codec_ctx_; AVFrame* frame_; AVPacket* packet_; SwsContext* sws_ctx_; int width_; int height_; int frame_counter_; bool initialized_; }; } // namespace scar #endif // SCAR_VIDEO_ENCODER_H