avcpp 3.1.0
Wrapper for the FFmpeg that simplify usage from C++ projects.
Loading...
Searching...
No Matches
av::FilterGraph Class Reference

A filter graph: filters, the links between them, and their configuration. More...

#include <filtergraph.h>

Inheritance diagram for av::FilterGraph:

Public Member Functions

 FilterGraph ()
 Create an empty graph.
 FilterGraph (decltype(nullptr))
 Create an empty graph from a nullptr tag; the graph starts empty.
 FilterGraph (const FilterGraph &)=delete
void operator= (const FilterGraph &)=delete
bool isValid ()
 Whether the graph has an FFmpeg context.
int filtersCount () const
 Number of filters in the graph.
void setAutoConvert (unsigned flags)
 Enable automatic format conversion between linked filters.
FilterContext filter (const std::string &name, OptionalErrorCode ec=throws())
 Filter instance by name.
FilterContext filter (unsigned idx, OptionalErrorCode ec=throws())
 Filter instance by position.
FilterContext allocFilter (const Filter &filter, const std::string &name, OptionalErrorCode ec=throws())
 Add a filter without initialising it.
FilterContext createFilter (const Filter &filter, const std::string &filterName, const std::string &filterArgs, OptionalErrorCode ec=throws())
 Add a filter and initialise it with its arguments.
void parse (const std::string &graphDescription, FilterContext &srcFilterCtx, FilterContext &sinkFilterCtx, OptionalErrorCode ec=throws())
 Build the graph from a textual description with explicit endpoints.
void parse (const std::string &graphDescription, OptionalErrorCode ec=throws())
 Build the graph from a textual description.
void config (OptionalErrorCode ec=throws())
 Negotiate formats and allocate the graph.
std::string dump (bool doPrint=true, const std::string &options=std::string())
 Describe the graph.
BufferSrcFilterContext bufferSrcFilter (OptionalErrorCode ec=throws())
 The source endpoint the graph was parsed with.
BufferSinkFilterContext bufferSinkFilter (OptionalErrorCode ec=throws())
 The sink endpoint the graph was parsed with.

Friends

class FilterInOut

Detailed Description

Build it in one of two ways: parse() a textual description such as "scale=320:240,format=yuv420p", or add filters by hand with createFilter() and link() them. config() negotiates the formats and allocates the internals; nothing can be pushed before it succeeds.

The graph owns every context created through it, so contexts must not outlive the graph.

Examples
api2-decode-filter-encode.cpp, and api2-decode-overlay-encode.cpp.

Member Function Documentation

◆ allocFilter()

FilterContext av::FilterGraph::allocFilter ( const Filter & filter,
const std::string & name,
OptionalErrorCode ec = throws() )

Initialise the returned context with init() before linking it.

Parameters
filterthe filter descriptor to instantiate
namename of the instance inside the graph
echolder for the error code
Returns
the new context, or an invalid one on failure

◆ bufferSinkFilter()

BufferSinkFilterContext av::FilterGraph::bufferSinkFilter ( OptionalErrorCode ec = throws())
Parameters
echolder for the error code
Returns
the sink context, or an invalid one when the graph has none

◆ bufferSrcFilter()

BufferSrcFilterContext av::FilterGraph::bufferSrcFilter ( OptionalErrorCode ec = throws())
Parameters
echolder for the error code
Returns
the source context, or an invalid one when the graph has none

◆ config()

void av::FilterGraph::config ( OptionalErrorCode ec = throws())

Must be called after the filters are linked and before anything is pushed; a format mismatch is reported here rather than later.

Parameters
echolder for the error code
Examples
api2-decode-filter-encode.cpp, and api2-decode-overlay-encode.cpp.

◆ createFilter()

FilterContext av::FilterGraph::createFilter ( const Filter & filter,
const std::string & filterName,
const std::string & filterArgs,
OptionalErrorCode ec = throws() )
Parameters
filterthe filter descriptor to instantiate
filterNamename of the instance inside the graph
filterArgsthe filter-specific argument string
echolder for the error code
Returns
the new context, or an invalid one on failure
Examples
api2-decode-filter-encode.cpp.

◆ dump()

std::string av::FilterGraph::dump ( bool doPrint = true,
const std::string & options = std::string() )
Parameters
doPrinttrue also writes the description through the FFmpeg log
optionsoptions for avfilter_graph_dump(); may be empty
Returns
the textual description of the graph

◆ filter() [1/2]

FilterContext av::FilterGraph::filter ( const std::string & name,
OptionalErrorCode ec = throws() )
Parameters
namethe instance name given when it was created
echolder for the error code
Returns
the context, or an invalid one when no such filter exists
Examples
api2-decode-overlay-encode.cpp.

◆ filter() [2/2]

FilterContext av::FilterGraph::filter ( unsigned idx,
OptionalErrorCode ec = throws() )
Parameters
idxzero-based index into the graph
echolder for the error code
Returns
the context, or an invalid one when the index is out of range

◆ filtersCount()

int av::FilterGraph::filtersCount ( ) const
Returns
the filter count

◆ isValid()

bool av::FilterGraph::isValid ( )
Returns
true when the graph can accept filters

◆ parse() [1/2]

void av::FilterGraph::parse ( const std::string & graphDescription,
FilterContext & srcFilterCtx,
FilterContext & sinkFilterCtx,
OptionalErrorCode ec = throws() )

The description names only the filters between the endpoints, for example "scale=320:240,split [s0][s1]; [s0] palettegen [p]; [s1][p] paletteuse".

Parameters
graphDescriptionthe filter chain
srcFilterCtxthe source context to start from
sinkFilterCtxthe sink context to end at
echolder for the error code
Examples
api2-decode-filter-encode.cpp, and api2-decode-overlay-encode.cpp.

◆ parse() [2/2]

void av::FilterGraph::parse ( const std::string & graphDescription,
OptionalErrorCode ec = throws() )
Parameters
graphDescriptionthe filter chain, including its buffer and buffersink endpoints
echolder for the error code

◆ setAutoConvert()

void av::FilterGraph::setAutoConvert ( unsigned flags)
Parameters
flagsAVFILTER_AUTO_CONVERT_* bits

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