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

◆ load_video() [2/2]

VideoLoadResult MayaFlux::IO::IOManager::load_video ( const std::string &  filepath,
VideoLoadConfig  config 
)

Load a video file into a VideoFileContainer.

Performs can_read check, opens with metadata and region extraction, registers the reader (assigning a globally unique reader_id), calls setup_io_service(), loads into container, and configures the default FrameAccessProcessor with auto_advance enabled.

Passing VideoReadOptions::EXTRACT_AUDIO also extracts the embedded SoundFileContainer, configures its ContiguousAccessProcessor identically to load_audio_file() in Depot, and fills the audio half of the result.

Parameters
filepathPath to the video file.
configVideoLoadConfig containing options and target dimensions.
Returns
The video container and, if requested and present, its audio container.

Definition at line 251 of file IOManager.cpp.

252{
253 auto reader = std::make_shared<IO::VideoFileReader>();
254
255 if (!reader->can_read(filepath)) {
257 "Cannot read video file: {}", filepath);
258 return {};
259 }
260
261 reader->set_video_options(config.video_options);
262 reader->set_audio_options(config.audio_options);
263 reader->set_target_dimensions(config.target_width, config.target_height);
264
266 reader->set_target_sample_rate(m_stream_info.sample_rate);
267 }
268
269 if (!reader->open(filepath, config.file_options)) {
271 "Failed to open video file: {}", reader->get_last_error());
272 return {};
273 }
274
275 const uint64_t reader_id = register_video_reader(reader);
276 reader->setup_io_service(reader_id);
277
278 auto video_container = std::dynamic_pointer_cast<Kakshya::VideoFileContainer>(reader->create_container());
279
280 if (!video_container) {
282 "Failed to create video container from: {}", filepath);
283 release_video_reader(reader_id);
284 return {};
285 }
286
287 if (!reader->load_into_container(video_container)) {
289 "Failed to load video data: {}", reader->get_last_error());
290 release_video_reader(reader_id);
291 return {};
292 }
293
294 configure_frame_processor(video_container);
295
296 std::shared_ptr<Kakshya::SoundFileContainer> audio_container;
297
299 audio_container = reader->get_audio_container();
300 if (audio_container) {
301 configure_audio_processor(audio_container);
302 m_extracted_audio[video_container] = audio_container;
303 } else {
305 "No audio track found in: {}", filepath);
306 }
307 }
308
310 "Loaded video: {}", filepath);
311
312 return { std::move(video_container), std::move(audio_container) };
313}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
std::unordered_map< std::shared_ptr< Kakshya::VideoFileContainer >, std::shared_ptr< Kakshya::SoundFileContainer > > m_extracted_audio
void configure_audio_processor(const std::shared_ptr< Kakshya::SoundFileContainer > &container) const
Core::GlobalStreamInfo & m_stream_info
void configure_frame_processor(const std::shared_ptr< Kakshya::VideoFileContainer > &container) const
void release_video_reader(uint64_t reader_id)
Release ownership of the reader identified by reader_id.
uint64_t register_video_reader(std::shared_ptr< VideoFileReader > reader)
Assign a globally unique reader_id and take ownership of a reader.
@ FileIO
Filesystem I/O operations.
@ Runtime
General runtime operations (default fallback)
@ API
MayaFlux/API Wrapper and convenience functions.
uint32_t sample_rate
Number of samples processed per second (Hz)

References MayaFlux::Journal::API, MayaFlux::IO::VideoLoadConfig::audio_options, configure_audio_processor(), configure_frame_processor(), MayaFlux::IO::EXTRACT_AUDIO, MayaFlux::IO::VideoLoadConfig::file_options, MayaFlux::Journal::FileIO, m_extracted_audio, m_stream_info, MF_ERROR, MF_INFO, MF_WARN, register_video_reader(), release_video_reader(), MayaFlux::Journal::Runtime, MayaFlux::Core::GlobalStreamInfo::sample_rate, MayaFlux::IO::VideoLoadConfig::target_height, MayaFlux::IO::VideoLoadConfig::target_width, and MayaFlux::IO::VideoLoadConfig::video_options.

+ Here is the call graph for this function: