_expr of blend (complex, and slow)¶
Watch on youtube.com- doc
https://ffmpeg.org/ffmpeg-filters.html#blend, (ffmpeg-utils)3. Expression Evaluation, https://ffmpeg.org/ffmpeg-filters.html#amerge, https://ffmpeg.org/ffmpeg-filters.html#pan
In video comparison, overlapping should often be allowed.
Although the method shown here works as expected, it is complicated as you can see. Not only that, this is very heavy and slow.
#! /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},pad=1920:1080:0:0,setsar=1[v1_1];
[1:v]scale=${cx}:${cy},pad=1920:1080:${ox}:${oy},setsar=1[v2_1];
[v1_1][v2_1]blend='
c0_expr=
if(lt(X, ${ox}) + lt(Y, ${oy}), A,
(if(lte(X, ${cx}) * lte(Y, ${cy}), A/2+B/2, B))):
c1_expr=
if(lt(X*2, ${ox}) + lt(Y*2, ${oy}), A,
(if(lte(X*2, ${cx}) * lte(Y*2, ${cy}), A/2+B/2, B))):
c2_expr=
if(lt(X*2, ${ox}) + lt(Y*2, ${oy}), A,
(if(lte(X*2, ${cx}) * lte(Y*2, ${cy}), A/2+B/2, B)))
'[v];
[0:a][1:a]amerge=inputs=2,pan=stereo|c0<c0+c1|c1<c2+c3[a]
" -map '[v]' -map '[a]' \
"${pref}.mp4"