Search code examples
ffmpeglibav

Clarity on FFmpeg Filter graph description


I'm using libavfilter C API to scale my video.

I started to read the documents related to libavfilter and got stuck at Filtergraph-description.

I don't understand the terminology "filter pads". Throughout the documents, I came across these terms like filter input pad and the output pad.

It would be really appreciable if anyone explains the filter pads in a simple way. Also please share any documents or links related to libavfilter C API examples.


Solution

  • pad (pæd)
    The fleshy cushion-like underpart of the foot of a cat, dog, etc


    I never liked the term "pad" when used in the context of filtering and I don't know why that term was used. Replacing it with the word "node" may make it more comprehendible.

    This can be visually represented with the graph2dot tool:

    enter image description here

    In this example the split filter makes two identical copies of a video. One copy is flipped, and then the hstack filter stacks them side-by-side to create the output.

    Each filter is linked, and each link is connected to an input "node" (pad) and an output "node" (pad).

    This may make more sense if you've ever used software that uses node graph architecture such as Nuke or the unfortunately discontinued Apple Shake.

    A filter with no input pads is called a "source", and a filter with no output pads is called a "sink". Source filter examples include testsrc2, color, and sine. These filters can generate video or audio by themselves with no input needed, so there are no input pads. Example to output a video test pattern, 3 seconds, 1280x720:

    ffmpeg -f lavfi -i testsrc2=d=3:s=1280x720 output.mp4
    

    A sink is less useful for most users. One use is to test complicated filtergraphs. If you have a filterchain that you want to temporarily omit then you can terminate it into a sink, such as anullsink. There is no output from a sink. It's kind of like using /dev/null if you're familiar with that.