Answers.Body: <p>For vertical stacking, the widths have to be equalized.</p>
  
  <p><code>[1:v][0:v]scale2ref=iw:ow/mdar[1v][0v];[2:v][0v]scale2ref=iw:ow/mdar[2v][0v];[0v][1v][2v]vstack=3</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-22T06:37:08.343Z
Answers.Text: oh it works,thx!
Answers.UserDisplayName: Jesus Slim
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-29T18:55:07.107Z
Answers.Text: @Gyan can you explain the parts of the above string?
Answers.UserDisplayName: maurice
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-16T11:44:48.400Z
Answers.LastActivityDate: 2018-11-16T11:44:48.400Z
Answers.UserDisplayName: Gyan
Body: <p>I'd like to combine three videos into one vertically stacked video. The three videos have different width and height.</p>
  
  <p>I can combine them horizontally successfully with this command:</p>
  
  <p><code>ffmpeg -i s1.mp4 -i s2.mp4 -i temp.mp4 -filter_complex "[1:v][0:v]scale2ref=oh*mdar:ih[1v][0v];[2:v][0v]scale2ref=oh*mdar:ih[2v][0v];[0v][1v][2v]hstack=3,scale='2*trunc(iw/2)':'2*trunc(ih/2)';[0:a:0][1:a:0][2:a:0] amix=inputs=3:duration=first:dropout_transition=0,dynaudnorm" final.mp4
  </code></p>
  
  <p>How can I modify this command to stack them vertically?</p>
  
Tags: <video><ffmpeg>
Title: How to stack three videos side by side with ffmpeg
UserDisplayName: Jesus Slim
ThreadText: # How to stack three videos side by side with ffmpeg
  
  (Asked by: username_0 on 2018-11-16)
  
  I'd like to combine three videos into one vertically stacked video. The three videos have different width and height.
  
  I can combine them horizontally successfully with this command:
  
  `ffmpeg -i s1.mp4 -i s2.mp4 -i temp.mp4 -filter_complex "[1:v][0:v]scale2ref=oh*mdar:ih[1v][0v];[2:v][0v]scale2ref=oh*mdar:ih[2v][0v];[0v][1v][2v]hstack=3,scale='2*trunc(iw/2)':'2*trunc(ih/2)';[0:a:0][1:a:0][2:a:0] amix=inputs=3:duration=first:dropout_transition=0,dynaudnorm" final.mp4`
  
  How can I modify this command to stack them vertically?
  
  **Tags:** video, ffmpeg
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-11-16. Score: 0 | Accepted answer
  
  For vertical stacking, the widths have to be equalized.
  
  `[1:v][0:v]scale2ref=iw:ow/mdar[1v][0v];[2:v][0v]scale2ref=iw:ow/mdar[2v][0v];[0v][1v][2v]vstack=3`
  
  > **Comments:**
  > **username_0**: oh it works,thx!  
  > **username_2**: @username_1 can you explain the parts of the above string?  
  
  ---
  
  