82 AVPixelFormat src_pixel_format,
96 return codec_context && sws_context && m_scratch_frame && m_stream_index >= 0;
123 bool encode_frame(
const uint8_t* src_data,
144 [[nodiscard]]
const std::string&
last_error()
const {
return m_last_error; }
150 AVCodecContext* codec_context {};
151 SwsContext* sws_context {};
153 [[nodiscard]] uint32_t
width()
const {
return m_width; }
154 [[nodiscard]] uint32_t
height()
const {
return m_height; }
157 AVStream* m_stream {};
158 AVFrame* m_scratch_frame {};
160 int m_stream_index { -1 };
162 uint32_t m_height {};
163 int m_src_src_bpp { 4 };
164 AVPixelFormat m_src_pixel_fmt { AV_PIX_FMT_BGRA };
165 int m_cached_src_width { -1 };
166 int m_cached_src_height { -1 };
RAII owner of a single AVFormatContext on the write path.
VideoEncodeContext(VideoEncodeContext &&)=delete
const std::string & last_error() const
bool is_valid() const
True if codec, scaler, and scratch frame are all ready.
VideoEncodeContext(const VideoEncodeContext &)=delete
VideoEncodeContext()=default
VideoEncodeContext & operator=(const VideoEncodeContext &)=delete
VideoEncodeContext & operator=(VideoEncodeContext &&)=delete
RAII owner of one video stream's encoder and pixel-format converter on the write path.