2

I have two videos. I used below command to overlay first video(overlay.mp4) on top of second video(main.mp4) and set transparency for alpha chanel to 0.3

ffmpeg -y \
-i main.mp4 \
-i overlay.mp4 \
-filter_complex \
[1]format=yuva420p,colorchannelmixer=aa=0.3,setpts=PTS+8/TB[1d]; \
[0][1d]overlay=enable='between(t,8, 13)'[v1]; \
-map [v1] -map 0:a -c:a copy -c:v libx264 -preset ultrafast output.mp4

The result looks like this. overlay

The background of first video is still remaining (look darker than the main video background).

I want to overlay only the 'foreground' on top of second video. How to set transparency of overlay video background so only the foreground display?

Edit

Set the colorkey option and it works

ffmpeg -y \
-i main.mp4 \
-i overlay.mp4 \
-filter_complex \
[1]format=rgb24,colorkey=black:0.3:0.2,colorchannelmixer=aa=0.3,setpts=PTS+8/TB[1d]; \
[0][1d]overlay=enable='between(t,8, 13)'[v1]; \
-map [v1] -map 0:a -c:a copy -c:v libx264 -preset ultrafast output.mp4
huynq9
  • 522
  • 8
  • 22

1 Answers1

4

You'll need to use a keying filter to remove the background color

ffmpeg -y \
-i main.mp4 \
-i overlay.mp4 \
-filter_complex \
[1]format=rgb24,colorkey=black,colorchannelmixer=aa=0.3,setpts=PTS+8/TB[1d]; \
[0][1d]overlay=enable='between(t,8, 13)'[v1]; \
-map [v1] -map 0:a -c:a copy -c:v libx264 -preset ultrafast output.mp4
Gyan
  • 85,394
  • 9
  • 169
  • 201
  • I set the similarity and blend value for colorkey option: `colorkey=black:0.3:0.2` and It works! Thank you – huynq9 Sep 30 '18 at 11:45