MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ capture_window()

uint32_t MayaFlux::IO::IOManager::capture_window ( const std::shared_ptr< Core::Window > &  window,
const std::string &  filepath,
double  frame_rate,
AVCodecID  codec_id = AV_CODEC_ID_NONE 
)

Begin continuous capture of a window's rendered frames to a file.

Delegates to VideoFileWriter::record(). The encoder is opened lazily on the first delivered frame so pixel format and dimensions come from the live swapchain. Returns an opaque capture id for use with stop_video_capture().

Returns 0 if the window is null or record() fails.

Parameters
windowWindow whose swapchain frames will be captured.
filepathOutput file path. Extension determines container format.
frame_rateNominal frame rate written into the container header.
codec_idEncoder override; AV_CODEC_ID_NONE = container default.
Returns
Capture handle; pass to stop_video_capture() to finalise.

Definition at line 625 of file IOManager.cpp.

630{
631 if (!window) {
633 "capture_window: null window");
634 return 0;
635 }
636
637 auto writer = std::make_shared<VideoFileWriter>();
638 if (!writer->record(window, filepath, frame_rate, codec_id)) {
640 "capture_window: record failed for '{}': {}", filepath, writer->last_error());
641 return 0;
642 }
643
644 const uint32_t id = m_next_video_capture_id.fetch_add(1, std::memory_order_relaxed);
645
646 {
647 std::lock_guard lock(m_video_captures_mutex);
648 m_video_captures.emplace(id, VideoCaptureState { .writer = writer, .capture_id = id });
649 m_video_writers.push_back(writer);
650 }
651
652 return id;
653}
#define MF_ERROR(comp, ctx,...)
std::weak_ptr< Core::Window > window
Definition Picker.cpp:23
std::vector< std::shared_ptr< VideoFileWriter > > m_video_writers
std::mutex m_video_captures_mutex
std::atomic< uint32_t > m_next_video_capture_id
std::unordered_map< uint32_t, VideoCaptureState > m_video_captures
@ FileIO
Filesystem I/O operations.
@ IO
Networking, file handling, streaming.

References MayaFlux::Journal::FileIO, MayaFlux::Journal::IO, m_next_video_capture_id, m_video_captures, m_video_captures_mutex, m_video_writers, MF_ERROR, window, and MayaFlux::IO::IOManager::VideoCaptureState::writer.