Using pad, overlay and blend … (2)

Watch on youtube.com
doc

https://ffmpeg.org/ffmpeg-filters.html#blend, https://ffmpeg.org/ffmpeg-filters.html#pad, https://ffmpeg.org/ffmpeg-filters.html#overlay, https://ffmpeg.org/ffmpeg-filters.html#split, https://ffmpeg.org/ffmpeg-filters.html#amerge, https://ffmpeg.org/ffmpeg-filters.html#pan

In video comparison, overlapping should often be allowed.

The method shown here is somewhat smartly written than the one shown earlier. However, this seems to be a bit poor performance.

#! /bin/sh
pref="`basename $0 .sh`"
vleft="EuropeanArchive.mp4"
vright="Eduardo.mp4"

#
fac=${1:-80}
cx=$((16 * ${fac}))
cy=$((9 * ${fac}))
ox=$((1920 - 16 * ${fac}))
oy=$((1080 - 9 * ${fac}))
#
ffmpeg -y -i "${vleft}" -i "${vright}" -filter_complex "
[0:v]scale=${cx}:${cy},setsar=1,split[0v_1][0v_2];
[1:v]scale=${cx}:${cy},setsar=1,split[1v_1][1v_2];

[0v_2]pad=1920:1080:0:0[0v_p];
[1v_2]pad=1920:1080:${ox}:${oy}[1v_p];

[0v_p][1v_1]overlay=x=W-w:y=H-h[v3_1];
[1v_p][0v_1]overlay=x=0:y=0[v3_2];

[v3_1][v3_2]blend=all_mode=average[v];


[0:a][1:a]amerge=inputs=2,pan=stereo|c0<c0+c1|c1<c2+c3[a]
" -map '[v]' -map '[a]' \
  "${pref}.mp4"