title: overlay transparency video on top of other video
body: <p>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</p>
  
  <pre><code>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
  </code></pre>
  
  <p>The result looks like this. 
  <a href="https://i.stack.imgur.com/ziUBO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ziUBO.png" alt="overlay"></a></p>
  
  <p>The background of first video is still remaining (look darker than the main video background).</p>
  
  <p>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?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Set the colorkey option and it works</p>
  
  <pre><code>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
  </code></pre>