Search code examples
ffmpegreversegif

FFMPEG - two inputs, reverse the second input


I have an image sequence that scrolls down the page, i want to add this sequence as an input twice, the first sequence scrolls down the page, then i want to reverse the second sequence so it appears as if we're scrolling back up the page and so the output gif has a smooth animation and doesn't snap back to the top of the page when it loops.

ffmpeg -f image2 -i ./tmp/frame-%03d.jpg -i ./tmp/frame-%03d.jpg -vf "[1:v]reverse,fps=25,scale=200:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" ./tmp/test.gif

Haven't managed to get this to work but the above is what i've tried, any help would be great!


Solution

  • No need to ingest the image sequence twice.

    You have to split the frames beforehand and apply reverse to only one of the copies, then join them together before splitting again to generate and apply the palette.

    ffmpeg -f image2 -i ./tmp/frame-%03d.jpg -vf "fps=25,scale=200:-1:flags=lanczos,split[s0][s1];[s1]reverse[s1];[s0][s1]concat=n=2:v=1:a=0,split[gif][pal];[pal]palettegen[p];[gif][p]paletteuse" ./tmp/test.gif