MayaFlux 0.4.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_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_capture() to finalise.

Definition at line 480 of file IOManager.cpp.

485{
486 if (!window) {
488 "capture_window: null window");
489 return 0;
490 }
491
492 auto writer = std::make_shared<VideoFileWriter>();
493 if (!writer->record(window, filepath, frame_rate, codec_id)) {
495 "capture_window: record failed for '{}': {}", filepath, writer->last_error());
496 return 0;
497 }
498
499 const uint32_t id = m_next_video_capture_id.fetch_add(1, std::memory_order_relaxed);
500
501 {
502 std::lock_guard lock(m_video_captures_mutex);
503 m_video_captures.emplace(id, VideoCaptureState { .writer = writer, .capture_id = id });
504 m_video_writers.push_back(writer);
505 }
506
507 return id;
508}
#define MF_ERROR(comp, ctx,...)
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, and MayaFlux::IO::IOManager::VideoCaptureState::writer.