ffmpeg generate and use different palette for every frame

1

2

Following this tutorial I managed to create high quality gifs in reasonable memory size.

Using piping, what I'm currently doing is this

# Generate palette
ffmpeg -y -i - -vf fps=15,scale=600:-1:flags=lanczos,palettegen some_dir/palette.png

# Generate gif using palette
ffmpeg -y -i - -i some_dir/palette.png -filter_complex fps=15,scale=600:-1:flags=lanczos[x];[x][1:v]paletteuse output.gif 

This is working great, but I read in the tutorial above that it is possible to generate a different palette for EVERY frame, how can I do that ? (Generate and use different palette for every frame)

bluesummers

Posted 2017-07-20T08:59:37.797

Reputation: 113

Answers

10

It is possible. Tutorial is outdated.

ffmpeg.exe -i Wildlife.wmv -lavfi palettegen=stats_mode=single[pal],[0:v][pal]paletteuse=new=1 out.mp4

Paul B. Mahol

Posted 2017-07-20T08:59:37.797

Reputation: 560

Did you mean out.gif? Because running this command with out.gif resulted me in the following error Error initializing filter 'palettegen' with args 'stats_mode=single' Error initializing complex filters. Invalid argument – bluesummers – 2017-08-09T10:53:08.950

Your ffmpeg is prahistoric. – Paul B. Mahol – 2017-08-10T11:36:31.827

ffmpeg version 2.8.11 not good enough? – bluesummers – 2017-08-10T11:40:35.630

This actually works in ffmpeg 3.3.3 - accepted. How would you run it on a series of pictures instead of a video? – bluesummers – 2017-08-10T12:07:59.510

1By using image2 muxer? ffmpeg.exe -i Wildlife.wmv -lavfi palettegen=stats_mode=single[pal],[0:v][pal]paletteuse=new=1 out%04d.png ? – Paul B. Mahol – 2017-08-10T15:32:12.757

@PaulB.Mahol thanx for the solution! Is it possible to generate 1 palette per, let's say, 30 frames? Because it seems like the performance is terrible when generating palette for each frame. – Alexander Korzhykov – 2017-08-18T19:43:09.503

Currently not in code. – Paul B. Mahol – 2017-08-20T14:09:52.613

on ubuntu 16 lts the version in apt is 2.8.15 – chiliNUT – 2019-10-15T21:11:09.530