Skip to content

Instantly share code, notes, and snippets.

@PhoenixIllusion
Created April 1, 2019 14:26
Show Gist options
  • Save PhoenixIllusion/9f6a0df972423da4af49697a333c1cb6 to your computer and use it in GitHub Desktop.
Save PhoenixIllusion/9f6a0df972423da4af49697a333c1cb6 to your computer and use it in GitHub Desktop.
Takes a source gif, an overlay image, and a transformed texture square to render under the overlay image. Position animated GIF inside image
FILTER="
[0:v] scale=512:512[src];
[2:v]format=rgba64,colorchannelmixer=rr=1/128:bb=1/128[map16];
[map16]extractplanes=r+b+a[x][y][a];
[src][x][y]remap[remap];
[remap][a]alphamerge[remapa];
[remapa][1:v]overlay"
echo "===="
echo $FILTER
echo "===="
GIF=$1
OVERLAY=$2
MASK=$3
OUT=$4
ffmpeg -i $GIF -i $OVERLAY -loop 1 -i $MASK \
-filter_complex "${FILTER}" \
-pix_fmt yuv420p \
$OUT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment