Filters¶
- class av.filter.graph.Graph(hw_device=None)¶
Bases:
objectA graph of audio and/or video filters.
- Parameters:
hw_device (HWDevice) – An optional hardware device for filters such as
hwupload. A reference is attached to every filter which declaresAVFILTER_FLAG_HWDEVICEbefore that filter is initialized.
- add(filter, args=None, **kwargs)¶
- add_abuffer(template=None, sample_rate=None, format=None, layout=None, channels=None, name=None, time_base=None)¶
Convenience method for adding abuffer.
- add_buffer(template=None, width=None, height=None, format=None, name=None, time_base=None)¶
- configure(bool auto_buffer: cython.bint = True, bool force: cython.bint = False)¶
- configured¶
- hw_device¶
The hardware device supplied when this graph was created.
- link_nodes(*nodes)¶
Links nodes together for simple filter graphs.
- pull()¶
- push(frame, int at: cython.int = -1)¶
Push a frame into the graph’s buffer source(s).
- Parameters:
frame – An
AudioFrameorVideoFrameto push into the matching buffer sources, orNoneto signal end of stream to every buffer source.at (int) – Index of a single buffer source to push to, for graphs with multiple inputs (e.g.
overlay). The default of-1pushes to every buffer source matching the frame’s type.
- set_audio_frame_size(frame_size)¶
Set the audio frame size for the graphs abuffersink. See av_buffersink_set_frame_size.
- threads¶
Maximum number of threads used by filters in this graph.
Set to 0 for automatic thread count. Must be set before adding any filters to the graph.
Wraps AVFilterGraph.nb_threads.
- vpull()¶
Like pull, but only for VideoFrames.
- vpush(VideoFrame frame: VideoFrame | None, int at: cython.int = -1)¶
Like
push(), but only forVideoFrame.
Hardware filters which create frames need an HWDevice
when the graph is constructed. The graph shares that device with every filter
which requests one before the filter is initialized:
from av.codec.hwaccel import HWDevice
from av.filter import Graph
device = HWDevice("vaapi")
graph = Graph(hw_device=device)
- class av.filter.context.FilterContext¶
Bases:
object- filter¶
- graph¶
- init(args=None, **kwargs)¶
- inputs¶
- link_to(FilterContext input_: FilterContext, int output_idx: cython.int = 0, int input_idx: cython.int = 0)¶
- name¶
- outputs¶
- process_command(cmd, arg=None, int res_len: cython.int = 1024, int flags: cython.int = 0)¶
- pull()¶