AVFilterContext

public final class AVFilterContext

An instance of a filter.

  • Create a new filter instance in a filter graph.

    Declaration

    Swift

    public init(graph: AVFilterGraph, filter: AVFilter, name: String? = nil)

    Parameters

    graph

    graph in which the new filter will be used

    filter

    the filter to create an instance of

    name

    Name to give to the new instance (will be copied to AVFilterContext.name). This may be used by the caller to identify different filters, libavfilter itself assigns no semantics to this parameter. May be nil.

    Return Value

    the context of the newly created filter instance (note that it is also retrievable directly through AVFilterGraph.filters or with avfilter_graph_get_filter()).

  • The AVFilter of which this is an instance.

    Declaration

    Swift

    public var filter: AVFilter { get set }
  • The name of this filter instance.

    Declaration

    Swift

    public var name: String { get }
  • The input links of this filter instance.

    Declaration

    Swift

    public var inputs: [AVFilterLink] { get }
  • The number of input pads.

    Declaration

    Swift

    public var inputCount: Int { get }
  • The output links of this filter instance.

    Declaration

    Swift

    public var outputs: [AVFilterLink] { get }
  • The number of input pads.

    Declaration

    Swift

    public var outputCount: Int { get }
  • The filtergraph this filter belongs to.

    Declaration

    Swift

    public var graph: AVFilterGraph { get }
  • Initialize a filter with the supplied parameters.

    Throws

    AVError

    Declaration

    Swift

    public func initialize(args: String? = nil) throws

    Parameters

    args

    Options to initialize the filter with. This must be a ‘:’-separated list of options in the ‘key=value’ form. May be nil if the options have been set directly using the AVOptions API or there are no options that need to be set. The default is nil.

  • Initialize a filter with the supplied dictionary of options.

    Note

    This function and avfilter_init_str() do essentially the same thing, the difference is in manner in which the options are passed. It is up to the calling code to choose whichever is more preferable. The two functions also behave differently when some of the provided options are not declared as supported by the filter. In such a case, avfilter_init_str() will fail, but this function will dump those extra options and continue as usual.

    Throws

    AVError

    Declaration

    Swift

    public func initialize(args: [String : String]) throws

    Parameters

    args

    A Dictionary filled with options for this filter.

  • Link two filters together.

    Throws

    AVError

    Declaration

    Swift

    @discardableResult
    public func link(
        srcPad: UInt = 0,
        dst: AVFilterContext,
        dstPad: UInt = 0
    ) throws -> AVFilterContext

    Parameters

    srcPad

    The index of the output pad on the source filter. The default is 0.

    dst

    The destination filter.

    dstPad

    The index of the input pad on the destination filter. The default is 0.

    Return Value

    The destination filter.

  • Undocumented

    Declaration

    Swift

    public static let `class`: AVClass
  • Undocumented

    Declaration

    Swift

    public func withUnsafeClassObjectPointer<T>(_ body: (UnsafeMutableRawPointer) throws -> T) rethrows -> T
  • Undocumented

    Declaration

    Swift

    public func withUnsafeObjectPointer<T>(_ body: (UnsafeMutableRawPointer) throws -> T) rethrows -> T
  • Add a frame to the buffer source.

    By default, if the frame is reference-counted, this function will take ownership of the reference(s) and reset the frame. Otherwise the frame data will be copied. This can be controlled using the flags.

    If this function throws an error, the input frame is not touched.

    Throws

    AVError

    Declaration

    Swift

    public func addFrame(_ frame: AVFrame?, flags: AVBufferSourceFlag = .init(rawValue: 0)) throws

    Parameters

    frame

    a frame, or nil to mark EOF

    flags

    a combination of AVBufferSourceFlag flags

  • The media type of the buffer sink.

    Declaration

    Swift

    public var mediaType: AVMediaType { get }
  • The timebase of the buffer sink.

    Declaration

    Swift

    public var timebase: AVRational { get }
  • The pixel format of the video buffer sink.

    Declaration

    Swift

    public var pixelFormat: AVPixelFormat { get }
  • The frame rate of the video buffer sink.

    Declaration

    Swift

    public var frameRate: AVRational { get }
  • The width of the video buffer sink.

    Declaration

    Swift

    public var width: Int { get }
  • The height of the video buffer sink.

    Declaration

    Swift

    public var height: Int { get }
  • The sample aspect ratio of the video buffer sink.

    Declaration

    Swift

    public var sampleAspectRatio: AVRational { get }
  • The sample format of the audio buffer sink.

    Declaration

    Swift

    public var sampleFormat: AVSampleFormat { get }
  • The sample rate of the audio buffer sink.

    Declaration

    Swift

    public var sampleRate: Int { get }
  • The number of channels in the audio buffer sink.

    Declaration

    Swift

    public var channelCount: Int { get }
  • The channel layout of the audio buffer sink.

    Declaration

    Swift

    public var channelLayout: AVChannelLayout { get }
  • Get a frame with filtered data from sink and put it in frame.

    Throws

    • AVError.tryAgain if no frames are available at this point; more input frames must be added to the filtergraph to get more output.
    • AVError.eof if there will be no more output frames on this sink.
    • A different AVError in other failure cases.

    Declaration

    Swift

    public func getFrame(_ frame: AVFrame, flags: AVBufferSinkFlag = .init(rawValue: 0)) throws

    Parameters

    frame

    pointer to an allocated frame that will be filled with data. The data must be freed using av_frame_unref() / av_frame_free().

    flags

    a combination of AVBufferSinkFlag flags