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

◆ open()

bool MayaFlux::IO::VideoFileReader::open ( const std::string &  filepath,
FileReadOptions  options = FileReadOptions::ALL 
)
overridevirtual

Open a file for reading.

Parameters
filepathPath to the file.
optionsReading options (see FileReadOptions).
Returns
true if file was successfully opened.

Implements MayaFlux::IO::FileReader.

Definition at line 71 of file VideoFileReader.cpp.

72{
73 close();
74
75 auto resolved = resolve_path(filepath);
76 m_filepath = resolved;
77 m_options = options;
78
79 auto demux = std::make_shared<FFmpegDemuxContext>();
80 if (!demux->open(resolved)) {
81 set_error(demux->last_error());
82 return false;
83 }
84
85 auto video = std::make_shared<VideoStreamContext>();
86 if (!video->open(*demux, m_target_width, m_target_height)) {
87 set_error(video->last_error());
88 return false;
89 }
90
91 std::shared_ptr<AudioStreamContext> audio;
94
95 audio = std::make_shared<AudioStreamContext>();
96 if (!audio->open(*demux, planar, m_target_sample_rate)) {
98 "VideoFileReader: no audio stream found or audio open failed");
99 audio.reset();
100 }
101 }
102
103 {
104 std::unique_lock lock(m_context_mutex);
105 m_demux = std::move(demux);
106 m_video = std::move(video);
107 m_audio = std::move(audio);
108 }
109
114
115 return true;
116}
#define MF_WARN(comp, ctx,...)
static std::string resolve_path(const std::string &filepath)
Resolve a filepath against the project source root if not found as-is.
void set_error(const std::string &msg) const
void build_metadata(const std::shared_ptr< FFmpegDemuxContext > &demux, const std::shared_ptr< VideoStreamContext > &video) const
void build_regions(const std::shared_ptr< FFmpegDemuxContext > &demux, const std::shared_ptr< VideoStreamContext > &video) const
std::shared_ptr< FFmpegDemuxContext > m_demux
std::shared_ptr< VideoStreamContext > m_video
std::shared_ptr< AudioStreamContext > m_audio
void close() override
Close the currently open file.
@ DEINTERLEAVE
Output planar (per-channel) doubles instead of interleaved.
@ EXTRACT_METADATA
Extract file metadata.
@ EXTRACT_REGIONS
Extract semantic regions (format-specific)
@ NONE
No special options.
@ FileIO
Filesystem I/O operations.
@ IO
Networking, file handling, streaming.

References build_metadata(), build_regions(), close(), MayaFlux::IO::DEINTERLEAVE, MayaFlux::IO::EXTRACT_AUDIO, MayaFlux::IO::EXTRACT_METADATA, MayaFlux::IO::EXTRACT_REGIONS, MayaFlux::Journal::FileIO, MayaFlux::Journal::IO, m_audio, m_audio_options, m_context_mutex, m_demux, m_filepath, m_options, m_target_height, m_target_sample_rate, m_target_width, m_video, m_video_options, MF_WARN, MayaFlux::IO::NONE, MayaFlux::IO::FileReader::resolve_path(), and set_error().

+ Here is the call graph for this function: