1

What I'm trying to do is to create a gif from images with different sizes and make the borders (padded area) for images that have different aspect ratio transparent.

Each image should be shown for 3 seconds. (-r 1/3)

I created a file list (Lista.txt) from the images I want, the image names are not sequenced so I can't use %03d or something. All files are in *.jpg format.

My code:

ffmpeg -f concat -safe 0 -r 1/3 -i Lista.txt -loop 0 -lavfi ^
"[0]format=rgba,scale=854:480:force_original_aspect_ratio=decrease:eval=frame,pad=854:480:-1:-1:eval=frame:color=#[email protected][vid]; ^
[vid]split[vid1][vid2];[vid1]palettegen=reserve_transparent=1[pal]; ^
[vid2][pal]paletteuse=alpha_threshold=128[final]" -map [final] -gifflags -offsetting "output.gif"

The end result output.gif shows only the last image of the sequence and not all the images. Any help would be appreciated.

These are the images: Images.zip

This is the result: output.gif

1 Answer 1

2

It looks like adding -reinit_filter 0 flag, solves the issue:

ffmpeg -f concat -safe 0 -reinit_filter 0 -r 1/3 -i Lista.txt -loop 0 -lavfi ^
"[0]format=rgba,scale=854:480:force_original_aspect_ratio=decrease:eval=frame,pad=854:480:-1:-1:eval=frame:color=#[email protected][vid]; ^
[vid]split[vid1][vid2];[vid1]palettegen=reserve_transparent=1[pal]; ^
[vid2][pal]paletteuse=alpha_threshold=128[final]" -map [final] -gifflags -offsetting "output.gif"

Downscaled output:

enter image description here

3
  • Thank you very much. Any idea why the video has to be duplicated with split, it doesn't seem to work without that part. I copied the palettegen part from another topic and I got that is necessary for some reason for transparency with gif files but I didn't get why the video has to be duplicated, then a palete is created with one of the copies, then the palete is mixed with the other copy that looks wierd for me, but I'm no ffmpeg expert... Commented Nov 17, 2022 at 20:25
  • [vid1] is consumed by palettegen filter, and [vid2] is consumed by paletteuse filter. When building a filter-graph, we can use the same input twice (unless it's a "primary input" like 0:v) I think. I'm no ffmpeg expert eather...
    – Rotem
    Commented Nov 17, 2022 at 20:34
  • That got through my head too, hä??? is that part used with palettegen beeing consumed somhow so I can't use it later? So all the input's that are created that one may call aliases or nickname can only be used once? I didn't notice this before.... Commented Nov 17, 2022 at 20:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .