1

I cut out the top part of a 320x356 gif as follows:

ffmpeg -i image.gif -filter:v "crop=320:226:0:130" out.gif

I have a text image that I want to put where the cut out part was; how do I do this? Preferably with as little quality loss as possible (but also preferably without an explosion in file size). Also if there's quality loss from the crop, is there a better way to do it?

H.v.M.
  • 577

1 Answers1

2

Add the vstack filter:

ffmpeg -i input.gif -i input.png -filter_complex "[0]crop=320:226:0:130[bottom];[1][bottom]vstack" out.gif

input.png needs to be the same width as the cropped GIF. If it is not then add the scale, pad, and/or crop filters.

If you want better quality then adapt How do I convert a video to GIF using ffmpeg, with reasonable quality?

ffmpeg -i input.gif -i input.png -filter_complex "[0]crop=320:226:0:130[bottom];[1][bottom]vstack,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" out.gif
llogan
  • 63,280