MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::IO::FFmpegDemuxContext Class Reference

RAII owner of a single AVFormatContext and associated demux state. More...

#include <FFmpegDemuxContext.hpp>

+ Collaboration diagram for MayaFlux::IO::FFmpegDemuxContext:

Public Member Functions

 FFmpegDemuxContext ()=default
 
 ~FFmpegDemuxContext ()
 
 FFmpegDemuxContext (const FFmpegDemuxContext &)=delete
 
FFmpegDemuxContextoperator= (const FFmpegDemuxContext &)=delete
 
 FFmpegDemuxContext (FFmpegDemuxContext &&)=delete
 
FFmpegDemuxContextoperator= (FFmpegDemuxContext &&)=delete
 
bool open (const std::string &filepath)
 Open a media file and probe stream information.
 
void close ()
 Close the format context and release all demux resources.
 
bool is_open () const
 True if the format context is open and stream info was found.
 
bool open_device (const std::string &device_name, const std::string &format_name, AVDictionary **options=nullptr)
 Open an FFmpeg device input (camera, screen capture, etc.).
 
int find_best_stream (int media_type, const void **out_codec=nullptr) const
 Find the best stream of the requested media type.
 
AVStream * get_stream (int index) const
 Access a stream by index.
 
unsigned int stream_count () const
 Number of streams in the container.
 
bool seek (int stream_index, int64_t timestamp)
 Seek to the nearest keyframe at or before the given timestamp.
 
void flush ()
 Flush the demuxer's internal read buffers.
 
void extract_container_metadata (FileMetadata &out_metadata) const
 Extract container-level metadata tags into a FileMetadata attributes map.
 
std::vector< FileRegionextract_chapter_regions () const
 Extract chapter information as FileRegion entries.
 
double duration_seconds () const
 Total container duration in seconds, or 0 if unknown.
 
const std::string & last_error () const
 

Static Public Member Functions

static void init_ffmpeg ()
 Initialise FFmpeg logging level once per process.
 

Public Attributes

AVFormatContext * format_context = nullptr
 Owned; freed in destructor.
 

Private Attributes

std::string m_last_error
 

Static Private Attributes

static std::atomic< bool > s_ffmpeg_initialized { false }
 
static std::mutex s_ffmpeg_init_mutex
 

Detailed Description

RAII owner of a single AVFormatContext and associated demux state.

Encapsulates all format-level (container) FFmpeg operations:

  • Opening and probing a media file via libavformat
  • Enumerating streams and selecting best stream per media type
  • Seeking at the format level (av_seek_frame)
  • Extracting container-level metadata tags and chapter regions
  • FFmpeg library initialization (once per process)

Does NOT own any codec context, resampler, or scaler — those are domain-specific and belong to AudioStreamContext / VideoStreamContext.

Shared ownership via shared_ptr allows multiple stream contexts to reference the same demuxer without duplicating the format state. Not copyable or movable; always heap-allocated through make_shared.

Definition at line 32 of file FFmpegDemuxContext.hpp.


The documentation for this class was generated from the following files: