Ok, I'm using FFMPEG wasm in a NextJS project, but I think general FFMPEG solutions will work since FFMPEG wasm will parse normal FFMPEG commands.
What I'm trying to do is to add an overlay video on top of the input video, I also change the overlay video's opacity so that I can see the main video below. I already have that working, with this line of code:
-i input.mkv -i overlay.mov -filter_complex [1:v]format=argb,geq=r=\'r(X,Y)\':a=\'0.5*alpha(X,Y)\'[zork];[0:v][zork]overlay -pix_fmt yuv420p -preset ultrafast -c:a copy output.mkv
.
The problem is that the input.mkv
size might change as well as the overlay.mov
, and I want to set the overlay.mov
size to be the same as the input.mkv
(so the solutions preferrebly can't use fixed values as well). I've seen other questions about that in stackoverflow, but since I'm already using the command to change the overlay's opacity I can't make it work with the command to also change the overlay's size, I don't have experience with FFMPEG whatsoever, so even though I've seen how to change overlay's opacity, and how to change overlay's size, I can't figure out how to combine those commands into a single one that do both.
Asked
Active
Viewed 295 times
0

Gustavo Sales
- 69
- 7
-
Check out [`scale2ref` filter](https://ffmpeg.org/ffmpeg-filters.html#scale2ref) – kesh Apr 29 '22 at 18:55
-
I've seen it already, but can't figure out how to combine it with the command to change overlay's opacity... – Gustavo Sales Apr 30 '22 at 00:02
1 Answers
1
First scale using scale2ref, then change opacity.
-i input.mkv -i overlay.mov -filter_complex [1:v][0:v]scale2ref[zork][video]; [zork]format=argb,lutrgb=a=val*0.5[zork];[video][zork]overlay -pix_fmt yuv420p -preset ultrafast -c:a copy output.mkv

Gyan
- 85,394
- 9
- 169
- 201