64 uint32_t target_width = 0,
65 uint32_t target_height = 0,
66 int target_format = -1);
85 uint32_t target_width = 0,
86 uint32_t target_height = 0,
87 int target_format = -1);
96 return codec_context && stream_index >= 0;
110 return codec_context && sws_context && stream_index >= 0;
128 [[nodiscard]]
bool rebuild_scaler_from_frame(
129 const AVFrame* frame,
130 uint32_t target_width = 0,
131 uint32_t target_height = 0,
132 int target_format = -1);
162 [[nodiscard]] std::vector<FileRegion> extract_keyframe_regions(
const FFmpegDemuxContext& demux)
const;
168 [[nodiscard]]
const std::string&
last_error()
const {
return m_last_error; }
174 AVCodecContext* codec_context =
nullptr;
175 SwsContext* sws_context =
nullptr;
177 int stream_index = -1;
178 uint64_t total_frames {};
181 uint32_t out_width {};
182 uint32_t out_height {};
183 double frame_rate {};
184 int src_pixel_format = -1;
185 int out_pixel_format = -1;
186 uint32_t out_bytes_per_pixel = 4;
189 uint32_t target_width {};
190 uint32_t target_height {};
191 int target_format = -1;
203 bool setup_scaler(uint32_t target_width, uint32_t target_height,
int target_format);
RAII owner of a single AVFormatContext and associated demux state.
VideoStreamContext(const VideoStreamContext &)=delete
const std::string & last_error() const
VideoStreamContext(VideoStreamContext &&)=delete
VideoStreamContext & operator=(VideoStreamContext &&)=delete
VideoStreamContext & operator=(const VideoStreamContext &)=delete
bool is_codec_valid() const
True if the codec context is open and ready to receive packets.
bool is_valid() const
True if the codec and scaler are ready for decoding.
VideoStreamContext()=default
RAII owner of one video stream's codec and pixel-format scaler state.