1 min read

Add a Subscription Animation with FFmpeg

Add a Subscription Animation with FFmpeg

This one was a doozy to figure out but I finally managed to overlay a little subscribe animation over my main videos.

Normally I would explain it but it's pretty long-winded so if you want the full explanation, please watch the video.

The short answer is, it's using a complex filter graph to offset the timestamps on the frames of the sub animation and delay its audio so they play over the main video when I wanted them to.

The command is as follows:

#!/usr/bin/env sh

IN=$1
OVER=$2
OUT=$3
START=$4
MILLI=${START}000

ffmpeg -i $IN -filter_complex \
"[0:v]setpts=PTS-STARTPTS[v0];
movie=$OVER:s=dv+da[overv][overa];
[overv]setpts=PTS-STARTPTS+$START/TB[v1];
[v0][v1]overlay=-600:0:eof_action=pass[out1];
[overa]adelay=$MILLI|$MILLI,volume=0.5[a1];
[0:a:0][0:a:1][a1]amix=inputs=3:duration=longest:dropout_transition=0:weights=3 3 1[outa]" \
-map "[out1]" -map "[outa]" $OUT

Did you find this information useful? If so, consider heading over to my donation page and drop me some support.

Want to ask a question or just chat? Contact me here