Answers.Body: <p>Add the overlay to the result of the stacked videos.</p>
  
  <p>Use</p>
  
  <pre><code>ffmpeg -i input0 -i input1 -i input2 -i input3 -i overlay -filter_complex \
  "[0:v][1:v]hstack[top]; \
   [2:v][3:v]hstack[bottom]; \
   [top][bottom]vstack[v];[v][4:v]overlay=0:0[v]" \
  -map "[v]" output.mp4
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-19T05:22:29.450Z
Answers.LastActivityDate: 2020-02-19T05:22:29.450Z
Answers.UserDisplayName: Gyan
Body: <p>I have four videos (no audio) which I am able to stitch together using <a href="https://stackoverflow.com/questions/35034775/how-to-merge-four-videos-on-one-screen-with-ffmpeg">this command</a>.
  I am also able to add an overlay on a single video with <a href="http://hamelot.io/visualization/using-ffmpeg-to-convert-a-set-of-images-into-a-video/#overlaying-image-on-video" rel="nofollow noreferrer">this command</a>.</p>
  
  <p>Is it possible to combine both of these operations with a single ffmpeg command (i.e. stack four 960x540 videos as in the first link, then add a 1920x1080 overlay onto the resulting 1920x1080 video)? Thanks.</p>
  
Tags: <ffmpeg>
Title: FFMPEG Stitch four videos together, then add overlay to result
UserDisplayName: ffmpegpoweruser
ThreadText: # FFMPEG Stitch four videos together, then add overlay to result
  
  (Asked by: username_0 on 2020-02-18)
  
  I have four videos (no audio) which I am able to stitch together using [this command](https://stackoverflow.com/questions/35034775/how-to-merge-four-videos-on-one-screen-with-ffmpeg).
  I am also able to add an overlay on a single video with [this command](http://hamelot.io/visualization/using-ffmpeg-to-convert-a-set-of-images-into-a-video/#overlaying-image-on-video).
  
  Is it possible to combine both of these operations with a single ffmpeg command (i.e. stack four 960x540 videos as in the first link, then add a 1920x1080 overlay onto the resulting 1920x1080 video)? Thanks.
  
  **Tags:** ffmpeg
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-02-19. Score: 0 | Accepted answer
  
  Add the overlay to the result of the stacked videos.
  
  Use
  
  ```
  ffmpeg -i input0 -i input1 -i input2 -i input3 -i overlay -filter_complex \
  "[0:v][1:v]hstack[top]; \
   [2:v][3:v]hstack[bottom]; \
   [top][bottom]vstack[v];[v][4:v]overlay=0:0[v]" \
  -map "[v]" output.mp4
  
  ```
  
  
  ---
  
  