title: How do I independently fade in/out multiple (3+) overlay images over video using FFMPEG?
body: <p>Using an arbitrary source video, I would like to INDEPENDENTLY fade in/fade out a minimum of three .png overlays/watermarks at various times throughout the video. I'm having trouble getting the syntax right for the filter chain.</p>
  
  <p>In these failed attempts below, I'm using four transparent .png images all at 1920x1080 using the same sized source input video. No scaling/positioning needed, just the overlays fading in and out at the defined times.</p>
  
  <p>I have the functionality working without fade, unsing 'enable', like so: </p>
  
  <pre><code>ffmpeg -i vid1.mp4 -loop 1 -i img1.png -i img2.png -i img3.png -i img4.png -filter_complex 
  "overlay=0:0:enable='between(t,8,11)' [tmp];
  [tmp]overlay=0:0:enable='between(t,10,15)'[tmp1];
  [tmp1]overlay=0:0:enable='between(t,15,138)'[tmp2];
  [tmp2]overlay=0:0:enable='between(t,140,150)" 
  -c:v libx264 -c:a copy 
  -flags +global_header -shortest -s 1920x1080 -y out.mp4
  </code></pre>
  
  <p>I just want the same control, using fade in/out.</p>
  
  <p>The following <em>almost</em> works as I'd like but I obviously don't want the entire output stream to fade out. I realize that adding the fade=out to lines 7, 8 &amp; 9 is fading the combined output (starting at line 7), but this is as close as I've come where I see each overlay image actually fading. The defined fades in lines 3, 4 and 5 apparently don't affect anything, and that's where I defined them originally. When I copied them to the output stream, the fade works on each overlay image, but again I don't want it to affect the entire output stream, just the individual overlays.</p>
  
  <pre><code>ffmpeg -i vid1.mp4 -loop 1 -i img1.png -i img2.png -i img3.png -i img4.png -filter_complex 
      "[1:v]fade=out:st=3:d=1[watermark0]; 
      [2:v]fade=out:st=4:d=1[watermark1]; 
      [3:v]fade=out:st=5:d=1[watermark2]; 
      [4:v]fade=out:st=6:d=1[watermark3]; 
      [0:v][watermark0] overlay=0:0 [tmp0]; 
      [tmp0][watermark1] overlay=0:0,fade=out:st=4:d=1 [tmp1]; 
      [tmp1][watermark2] overlay=0:0,fade=out:st=6:d=1 [tmp2]; 
      [tmp2][watermark3] overlay=0:0,fade=out:st=8:d=1 [out]" -map "[out]" -c:v libx264 -c:a copy 
      -flags +global_header -shortest -s 1920x1080 -y out.mp4
  </code></pre>
  
  <p>I've also tried 'split' with similar results to the above, but the fade only seems to work on the first image (this one uses fade in as well):</p>
  
  <pre><code>ffmpeg -i vid.mp4 -loop 1 -i img1.png -i img2.png -i img3.png -i img4.png -filter_complex 
  "[1:v]split=4[wm1][wm2][wm3][wm4]; 
  [wm1]fade=in:st=1:d=1:alpha=1,fade=out:st=3:d=1:alpha=1[ovr1]; 
  [wm2]fade=in:st=2:d=1:alpha=1,fade=out:st=4:d=1:alpha=1[ovr2]; 
  [wm3]fade=in:st=3:d=1:alpha=1,fade=out:st=5:d=1:alpha=1[ovr3]; 
  [wm4]fade=in:st=4:d=1:alpha=1,fade=out:st=6:d=1:alpha=1[ovr4]; 
  [0:v][ovr1]overlay=0:0[base1]; 
  [base1][ovr2]overlay=0:0[base2]; 
  [base2][ovr3]overlay=0:0[base3]; 
  [base3][ovr4]overlay=0:0[out]" -map "[out]" 
  -t 10 -c:v libx264 -c:a copy -flags +global_header -shortest -s 1920x1080 -y out.mp4
  </code></pre>
  
  <p>Any help is greatly appreciated! :)</p>