MayaFlux 0.2.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 m_filepath = filepath;
76 m_options = options;
77
78 auto demux = std::make_shared<FFmpegDemuxContext>();
79 if (!demux->open(filepath)) {
80 set_error(demux->last_error());
81 return false;
82 }
83
84 auto video = std::make_shared<VideoStreamContext>();
85 if (!video->open(*demux, m_target_width, m_target_height)) {
86 set_error(video->last_error());
87 return false;
88 }
89
90 std::shared_ptr<AudioStreamContext> audio;
93
94 audio = std::make_shared<AudioStreamContext>();
95 if (!audio->open(*demux, planar, m_target_sample_rate)) {
97 "VideoFileReader: no audio stream found or audio open failed");
98 audio.reset();
99 }
100 }
101
102 {
103 std::unique_lock lock(m_context_mutex);
104 m_demux = std::move(demux);
105 m_video = std::move(video);
106 m_audio = std::move(audio);
107 }
108
113
114 return true;
115}
#define MF_WARN(comp, ctx,...)
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, and set_error().

+ Here is the call graph for this function: