ffmpeg -ss 4.5 -t 3.9 -i input.mp4 -vf "fps=18,scale=360:-2:flags=lanczos,palettegen" palette.png

ffmpeg -ss 4.5 -t 3.9 -i input.mp4 -i palette.png -filter_complex "fps=18,scale=360:-2:flags=lanczos[x];[x][1:v]palett‎euse" output.gif

I used this command to make a gif, but I don't know what [x];[x][1:v] means.

What is this all about?


The [x] is just a name given to the output of the filter.

Please read the respective documentation entry and also the part about link labels.

Usually, a simple filter takes one or more filters and puts them into a filter chain. This is the case in your first command.

You have a complex filter in the second command where there can be multiple filter chains combined into a filter graph, as you are processing multiple input streams. The first chain applies fps and scale to the first input video, and the second chain applies the paletteuse filter to the output of the first filterchain and the second input image.

Each filterchain can have zero or more inputs, and zero or more outputs. In a complex filter, you usually have to tell ffmpeg what these inputs and outputs are for each of the filter chains. This is what the [x] does.

Basically, the [x] says, the output of the fps and scale filter chain is called x. Later, it can be re-used as an input for the paletteuse filter chain. You don't have to use x; you can use any other name as well – something more descriptive would make sense, like scaled.

| improve this answer | |

They are link labels.

From the docs,

The name and arguments of the filter are optionally preceded and followed by a list of link labels. A link label allows one to name a link and associate it to a filter output or input pad.

So, in scale=360:-2:flags=lanczos[x], x is the label assigned to the output of the scale filter.

In [x][1:v]palett‎euse, [x] means to feed paletteuse with the output of the scale filter as the first input and [1:v] means to feed the first video stream of the 2nd input (palette.png).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.