Skip to content

ffavf

FFmpeg AVFilter

Register name used to load filter: ffavf
This filter is not checked during graph resolution and needs explicit loading.
Filters of this class can connect to each-other.

This filter provides libavfilter raw audio and video tools.
See FFmpeg documentation (https://ffmpeg.org/documentation.html) for more details
To list all supported avfilters for your GPAC build, use gpac -h ffavf:*.

Declaring a filter

The filter loads a filter or a filter chain description from the f option.
Example

ffavf:f=showspectrum

Unlike other FFmpeg bindings in GPAC, this filter does not parse other libavfilter options, you must specify them directly in the filter chain, and the f option will have to be escaped.
Example

ffavf::f=showspectrum=size=320x320 or ffavf::f=showspectrum=size=320x320::pfmt=rgb  
ffavf::f=anullsrc=channel_layout=5.1:sample_rate=48000

For complex filter graphs, it is possible to store options in a file (e.g. opts.txt):
Example

:f=anullsrc=channel_layout=5.1:sample_rate=48000

And load arguments from file:
Example
ffavf:opts.txt aout

The filter will automatically create buffer and buffersink AV filters for data exchange between GPAC and libavfilter.
The builtin options ( pfmt, afmt ...) can be used to configure the buffersink filter to set the output format of the filter.

Naming of PIDs

For simple filter graphs with only one input and one output, the input PID is assigned the avfilter name in and the output PID is assigned the avfilter name out

When a graph has several inputs, input PID names shall be assigned by the user using the ffid property, and mapping must be done in the filter.
Example

gpac -i video:#ffid=a -i logo:#ffid=b ffavf::f=[a][b]overlay=main_w-overlay_w-10:main_h-overlay_h-10 vout

In this example:

  • the video source is identified as a
  • the logo source is identified as b
  • the filter declaration maps a to its first input (in this case, main video) and b to its second input (in this case the overlay)

When a graph has several outputs, output PIDs will be identified using the ffid property set to the output avfilter name.
Example

gpac -i source ffavf::f=split inspect:SID=#ffid=out0 vout#SID=out1

In this example:

  • the splitter produces 2 video streams out0 and out1
  • the inspector only process stream with ffid out0
  • the video output only displays stream with ffid out1

The name(s) of the final output of the avfilter graph cannot be configured in GPAC. You can however name intermediate output(s) in a complex filter chain as usual.

Filter graph commands

The filter handles option updates as commands passed to the AV filter graph. The syntax expected in the option name is:

  • com_name=value: sends command com_name with value value to all filters
  • name#com_name=value: sends command com_name with value value to filter named name

Options

f (str): filter or filter chain description
pfmt (pfmt, default: none): pixel format of output. If not set, let AVFilter decide
afmt (afmt, default: none): audio format of output. If not set, let AVFilter decide
sr (uint, default: 0): sample rate of output. If not set, let AVFilter decide
ch (uint, default: 0): number of channels of output. If not set, let AVFilter decide
dump (bool, default: false, updatable): dump graph as log media@info or stderr if not set
* (str): any possible options defined for AVFilter and sub-classes (see gpac -hx ffavf and gpac -hx ffavf:*)