Konstantin
Konstantin

Reputation: 3123

How to use palettegen and paletteuse filters with FFmpeg for image sequences?

I have converted a short video to gif with the help of the following script:

#!/bin/sh

palette="/tmp/palette.png"

filters="fps=15,scale=320:-1:flags=lanczos"

ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette
ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2

However when I convert an image sequence, I get error message: "Filter paletteuse has a unconnected output"

#!/bin/sh

palette="/tmp/palette.png"

filters="fps=25"

ffmpeg -v warning -f image2 -i %04d.jpg -vf "$filters,palettegen" -y $palette
ffmpeg -v warning -f image2 -i %04d.jpg -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2

How can I make palettegen and paletteuse work with the image sequences too?

Upvotes: 7

Views: 9412

Answers (2)

Alexander
Alexander

Reputation: 1

You need right syntax:

# ./videogif.sh bf5_orig.webm battlefield5.gif

$2 = output filename (.gif)

Upvotes: 0

llogan
llogan

Reputation: 133693

palettegen and paletteuse work fine with image sequence inputs.

The problem is with your positional parameter. You're using $2, but there is only one argument passed from your command to your script. Change the $2 to $1.

Upvotes: 6

Related Questions