maskedmerge
Watch on youtube.com
- doc
https://ffmpeg.org/ffmpeg-filters.html#maskedmerge,
https://ffmpeg.org/ffmpeg-filters.html#geq
.
- see also
alphamerge, alphaextract
What can be achieved with “alphamerge” is also possible with “maskedmerge”, and using “maskedmerge” is a bit more compact.
00:00:00
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=0xAAAAAA:s=1920x1080:d=24[alpha];
[1:v][alpha]alphamerge[1v];
[0:v][1v]overlay[v]
" -map '[v]' -an out.mp4
|
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=0xAAAAAA:s=1920x1080:d=24[mask];
[0:v][1:v][mask]maskedmerge[v]
" -map '[v]' -an out.mp4
|
00:00:20
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=1920x1080:d=24,
geq='lum=mod(sqrt((W/2-X)^2+(H/2-Y)^2)*3,256)'
[alpha];
[1:v][alpha]alphamerge[1v];
[0:v][1v]overlay[v]
" -map '[v]' -an out.mp4
|
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=1920x1080:d=24,
geq='lum=mod(sqrt((W/2-X)^2+(H/2-Y)^2)*3,256)'
[mask];
[0:v][1:v][mask]maskedmerge[v]
" -map '[v]' -an out.mp4
|
00:00:40
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
testsrc2=s=1920x1080:d=24[alpha];
[1:v][alpha]alphamerge[1v];
[0:v][1v]overlay[v]
" -map '[v]' -an out.mp4
|
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
testsrc2=s=1920x1080:d=24[mask];
[0:v][1:v][mask]maskedmerge[v]
" -map '[v]' -an out.mp4
|
1x1 checker board
00:01:00
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='if(eq(mod(X,2),mod(Y,2)),255,0)'
[alpha];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[1v][alpha]alphamerge[1v];
[0v][1v]overlay,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='if(eq(mod(X,2),mod(Y,2)),255,0)'
[mask];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[0v][1v][mask]maskedmerge,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
32x32 checker board
00:01:20
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='if(eq(mod(floor(X/32),2),mod(floor(Y/32),2)),255,0)'
[alpha];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[1v][alpha]alphamerge[1v];
[0v][1v]overlay,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='if(eq(mod(floor(X/32),2),mod(floor(Y/32),2)),255,0)'
[mask];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[0v][1v][mask]maskedmerge,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
00:01:40
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='lum=if(eq(mod(floor(X/32),2),mod(floor(Y/32),2)),255,0):
cr=128:
cb=128'
[alpha];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[1v][alpha]alphamerge[1v];
[0v][1v]overlay,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='lum=if(eq(mod(floor(X/32),2),mod(floor(Y/32),2)),255,0):
cr=128:
cb=128'
[mask];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[0v][1v][mask]maskedmerge,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
gradation
00:02:00
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='lum=X*255/W:
cr=128:
cb=128'
[alpha];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[1v][alpha]alphamerge[1v];
[0v][1v]overlay,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='lum=X*255/W:
cr=128:
cb=128'
[mask];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[0v][1v][mask]maskedmerge,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
00:02:20
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='lum=Y*255/H:
cr=128:
cb=128'
[alpha];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[1v][alpha]alphamerge[1v];
[0v][1v]overlay,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='lum=Y*255/H:
cr=128:
cb=128'
[mask];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[0v][1v][mask]maskedmerge,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
00:02:40
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='lum=255*(1-sqrt((X-W/2)^2+(Y-H/2)^2)/sqrt((W/2)^2+(H/2)^2)):
cr=128:
cb=128'
[alpha];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[1v][alpha]alphamerge[1v];
[0v][1v]overlay,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='lum=255*(1-sqrt((X-W/2)^2+(Y-H/2)^2)/sqrt((W/2)^2+(H/2)^2)):
cr=128:
cb=128'
[mask];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[0v][1v][mask]maskedmerge,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
00:03:00
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='lum=255*gauss((X/W-0.5)*3)*gauss((Y/H-0.5)*3)/gauss(0)/gauss(0):
cr=128:
cb=128'
[alpha];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[1v][alpha]alphamerge[1v];
[0v][1v]overlay,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='lum=255*gauss((X/W-0.5)*3)*gauss((Y/H-0.5)*3)/gauss(0)/gauss(0):
cr=128:
cb=128'
[mask];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[0v][1v][mask]maskedmerge,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
wave (horizontal)
00:03:20
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='128+sin(X*(8*PI/W))*127'
[alpha];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[1v][alpha]alphamerge[1v];
[0v][1v]overlay,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='128+sin(X*(8*PI/W))*127'
[mask];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[0v][1v][mask]maskedmerge,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
wave (vertical)
00:03:40
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='128+sin(Y*(8*PI/H))*127'
[alpha];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[1v][alpha]alphamerge[1v];
[0v][1v]overlay,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='128+sin(Y*(8*PI/H))*127'
[mask];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[0v][1v][mask]maskedmerge,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
wave (radial)
00:04:00
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='128+sin(((W/2-X)^2+(H/2-Y)^2)*(8*PI/((W/2)^2+(H/2)^2)))*127'
[alpha];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[1v][alpha]alphamerge[1v];
[0v][1v]overlay,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='128+sin(((W/2-X)^2+(H/2-Y)^2)*(8*PI/((W/2)^2+(H/2)^2)))*127'
[mask];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[0v][1v][mask]maskedmerge,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
wave (horizontal)
00:04:20
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='128+sin((X+T*40)*(8*PI/W))*127'
[alpha];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[1v][alpha]alphamerge[1v];
[0v][1v]overlay,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='128+sin((X+T*40)*(8*PI/W))*127'
[mask];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[0v][1v][mask]maskedmerge,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
wave (vertical)
00:04:40
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='128+sin((Y+T*20)*(8*PI/H))*127'
[alpha];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[1v][alpha]alphamerge[1v];
[0v][1v]overlay,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='128+sin((Y+T*20)*(8*PI/H))*127'
[mask];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[0v][1v][mask]maskedmerge,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
wave (radial)
00:05:00
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='128+sin(((W/2-X)^2+(H/2-Y)^2)*((8+T)*PI/((W/2)^2+(H/2)^2))-T*10)*127'
[alpha];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[1v][alpha]alphamerge[1v];
[0v][1v]overlay,format=yuv420p
[v]" -map '[v]' -an out.mp4
|
#! /bin/sh
f1="Pexels_2877_2880.mp4"
f2="Pexels_2880_2877.mp4"
ffmpeg -y -i "${f1}" -i "${f2}" -filter_complex "
color=black:s=992x558:d=24
,format=yuv444p
,geq='128+sin(((W/2-X)^2+(H/2-Y)^2)*((8+T)*PI/((W/2)^2+(H/2)^2))-T*10)*127'
[mask];
[0:v]scale=992:558,setsar=1[0v];
[1:v]scale=992:558,setsar=1[1v];
[0v][1v][mask]maskedmerge,format=yuv420p
[v]" -map '[v]' -an out.mp4
|