Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 960
Konstantin Avatar asked Dec 31 '15 22:12

Konstantin


1 Answers

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.

like image 181
llogan Avatar answered Oct 21 '22 18:10

llogan