Answers.Body: <p>Use</p>
  
  <pre><code>ffmpeg -i s1.mp4 -i s2.mp4 -i s3.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)'" final.mp4
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-08T05:31:56.290Z
Answers.Text: I tried with this code,strill without any luck 
  `[libx264 @ 0x7f9334838e00] width not divisible by 2 (637x160)
  Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height` @Gyan
Answers.UserDisplayName: gs z
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-08T06:11:19.780Z
Answers.Text: Added filter at end
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-14T11:04:31.550Z
Answers.Text: Can you tell me How to use "VSTACK" in this case? @Gyan
Answers.UserDisplayName: gs z
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-07T18:41:02.480Z
Answers.LastActivityDate: 2018-11-08T06:11:03.277Z
Answers.LastEditDate: 2018-11-08T06:11:03.277Z
Answers.UserDisplayName: Gyan
Body: <p>I have three videos s1.mp4,s2.mp4 s3.mp4 and I need to combine three videos side by side I know use hstack but my three videos has different size?</p>
  
  <p>I've found  following commands.It works,but only support two videos.</p>
  
  <pre><code>ffmpeg -i s1.mp4 -i s2.mp4 -filter_complex "[1:v][0:v]scale2ref[wm][base];[base][wm]hstack=2" final.mp4
  </code></pre>
  
Tags: <video><ffmpeg>
Title: ffmpeg combine three videos side by side
UserDisplayName: gs z
ThreadText: # ffmpeg combine three videos side by side
  
  (Asked by: username_0 on 2018-11-07)
  
  I have three videos s1.mp4,s2.mp4 s3.mp4 and I need to combine three videos side by side I know use hstack but my three videos has different size?
  
  I've found following commands.It works,but only support two videos.
  
  ```
  ffmpeg -i s1.mp4 -i s2.mp4 -filter_complex "[1:v][0:v]scale2ref[wm][base];[base][wm]hstack=2" final.mp4
  
  ```
  
  **Tags:** video, ffmpeg
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-11-07. Score: 5 | Accepted answer
  
  Use
  
  ```
  ffmpeg -i s1.mp4 -i s2.mp4 -i s3.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)'" final.mp4
  
  ```
  
  > **Comments:**
  > **username_0**: I tried with this code,strill without any luck  `[libx264 @ 0x7f9334838e00] width not divisible by 2 (637x160) Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height` @username_1  
  > **username_1**: Added filter at end  
  > **username_0**: Can you tell me How to use "VSTACK" in this case? @username_1  
  
  ---
  
  