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?

1 Answer 1

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
2
  • Change that to vstack and I'll accept!
    – H.v.M.
    Apr 8, 2021 at 22:21
  • @Blrp Fixed the typo.
    – llogan
    Apr 8, 2021 at 22:23

You must log in to answer this question.

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