title: ffmpeg: combine filter_complex trim, overlay and concat
body: <p>I try to combine different video and audio clips with trimming and a logo on top.</p>
  
  <p>My syntax looks like this:</p>
  
  <pre><code>ffmpeg -i "$introVid" -i "$introAud" -i "$mainVid" -i "$mainAud" -i "$outroVid" -i "$outroAud" -i "$logo" -i "$mainVid" -i "$mainAud" \
  -filter_complex \
  "[2:0]trim=0.4:60[trimV1]; \
   [3:0]atrim=0.4:60[trimA1]; \
   [trimV1][6:v]overlay=main_w-overlay_w-20:15,fade=in:s=2:d=0.5:alpha=1,fade=out:s=60:d=0.5:alpha=1[fade]; \
   [7:0]trim=60.2:72[trimV2]; [8:0]atrim=60.2:72[trimA2]; \
   [0:0] [1:0] [fade] [trimA1] [4:0] [5:0] [trimV2] [trimA2] concat=n=4:v=1:a=1[cv][a]; \
   [cv]scale=864:480:flags=gauss:interl=0[scal]" \
  -map "[scal]" -map "[a]" -pix_fmt yuv420p -c:v libx264 -preset fast -y "$out"
  </code></pre>
  
  <p>It works mostly, but the problem is that I get a black video, with the same length then the main video, on the 3rd place. Interesting is also, when I watch the ffmpeg process, it hangs shortly on time 1:26min and then it jumps to 2:40min. Normally the complete test video have around 1:30min. </p>
  
  <p>The output what I get is at the moment:</p>
  
  <p><code>([intro][trimmed main with logo][black video][outro][credits])</code> &lt;- the black video part is to much.</p>