Answers.Body: <p>Use</p>
  
  <pre><code>ffmpeg -i shorter.mp4 -i longer.mp4 -filter_complex
   "[0]trim=0:3.5,drawbox=c=black[delay];[delay][0]concat[left];
    [left][1]hstack[v]"
   -map "[v]" -map 1:a -c:a copy out.mp4
  </code></pre>
  
  <p>where <code>3.5</code> should be replaced with the delayed start time (in seconds) of the shorter video.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-04T09:04:49.897Z
Answers.Text: Awesome! But there was one missing point. Sync was proper. But the right video didn't start until the delay (13s) elapsed. Then both videos started simultaneously. In essence, I lost the first 13s of the right video
Answers.UserDisplayName: Nagabhushan S N
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-04T09:15:22.860Z
Answers.Text: See edited cmd.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-04T09:30:09.307Z
Answers.Text: No. The update distorted. Both videos began simultaneously. After few seconds, left video paused for few seconds. Then it resumed in sync with the right video
Answers.UserDisplayName: Nagabhushan S N
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-04T09:31:37.070Z
Answers.Text: Show full log..
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-04T12:05:29.567Z
Answers.Text: https://drive.google.com/open?id=1gaX3d2ccbUcNjS8TqIPBL1kRX-sB4z0y
  
  I have put the logs here
Answers.UserDisplayName: Nagabhushan S N
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-04T12:09:31.117Z
Answers.Text: You're using an older version of ffmpeg which needs manual buffering. Change first line of filters to `[0]trim=0:3.5,drawbox=c=black,fifo[delay];[delay][0]concat,fifo[left]`
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-04T12:56:36.030Z
Answers.Text: Got an Error
  https://drive.google.com/open?id=1vgDD6T0HlR7BBaUHLdybBzlfBQnJNqyx
  
  I installed ffmpeg today from here http://ffmpeg.org/releases/ffmpeg-3.4.1.tar.bz2. I'm running on macbook pro
  Do, I need to install something else also?
Answers.UserDisplayName: Nagabhushan S N
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-04T13:16:21.540Z
Answers.Text: Get a binary from https://ffmpeg.zeranoe.com/builds/
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-04T13:42:35.960Z
Answers.Text: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/71182/discussion-between-nagabhushan-s-n-and-mulvya).
Answers.UserDisplayName: Nagabhushan S N
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-04T16:21:26.063Z
Answers.Text: Use `ffmpeg -i left.mp4 -i right.mp4 -i left.mp4 -filter_complex "[0]trim=0:13,drawbox=c=black:t=fill[delay];[delay][2]concat[left];[left][1]hstack[v]" -map "[v]" -map 1:a -c:a copy out.mp4` with the new binary. This is an outstanding buffer mgmt issue.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-05T03:22:52.897Z
Answers.Text: Error again! 
  https://drive.google.com/open?id=1fRWw03VP-GlCtDJOgHcWgs5dXUnRlb4t
Answers.UserDisplayName: Nagabhushan S N
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-05T06:08:53.160Z
Answers.Text: What's the output of `ffmpeg -hide_banner -filters`
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-05T07:54:57.450Z
Answers.Text: https://drive.google.com/open?id=13vBYu8M9wsiGXsJBTqgTB977sM7K2hlC
Answers.UserDisplayName: Nagabhushan S N
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-05T09:45:59.157Z
Answers.Text: It shows the concat filter. Rarely, there's a character coding issue when pasting to/from Stack Exchange. Retype the command at your end and run.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-05T10:43:35.733Z
Answers.Text: Yes. Its working perfectly fine now. Thanks a lot!
  Also, I have one more request. A small extension. How to handle the below scenario. Left video should start after right video. But the length is such that left video extends after the right video ends. The current command handles this, but after right video ends, audio stops. Left video continues without audio. How to make such that after right video ends, audio should be taken from left video?
  Should I ask a new question for this?
Answers.UserDisplayName: Nagabhushan S N
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-05T17:26:42.903Z
Answers.Text: Ask a new Q. It's more convoluted to switch audio like that.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-06T08:03:47.883Z
Answers.Text: I have asked here. https://video.stackexchange.com/q/23156/21062
  Thanks!
Answers.UserDisplayName: Nagabhushan S N
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-04T07:52:50.370Z
Answers.LastActivityDate: 2018-01-04T09:15:14.190Z
Answers.LastEditDate: 2018-01-04T09:15:14.190Z
Answers.UserDisplayName: Gyan
Body: <p>I have two videos of different length. I need to create a new video with one video at the left and other at the right. I tried using <a href="https://unix.stackexchange.com/a/233833/267627">this</a>. Problem is my videos are of different length. I want to start one video a few seconds after the other started. Also, I want to keep the audio of the longer video only.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-01-04T06:21:09.163Z
Comments.Text: Do you know which of the videos is longer?
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-01-04T07:36:02.790Z
Comments.Text: Yes. I know. The right one.
Comments.UserDisplayName: Nagabhushan S N
Tags: <video><ffmpeg><video-editor>
Title: Create splitscreen video using ffmpeg
UserDisplayName: Nagabhushan S N
ThreadText: # Create splitscreen video using ffmpeg
  
  (Asked by: username_0 on 2018-01-04)
  
  I have two videos of different length. I need to create a new video with one video at the left and other at the right. I tried using [this](https://unix.stackexchange.com/a/233833/267627). Problem is my videos are of different length. I want to start one video a few seconds after the other started. Also, I want to keep the audio of the longer video only.
  
  **Tags:** video, ffmpeg, video-editor
  
  > **Comments:**
  > **username_1**: Do you know which of the videos is longer?  
  > **username_0**: Yes. I know. The right one.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-01-04. Score: 1 | Accepted answer
  
  Use
  
  ```
  ffmpeg -i shorter.mp4 -i longer.mp4 -filter_complex
   "[0]trim=0:3.5,drawbox=c=black[delay];[delay][0]concat[left];
    [left][1]hstack[v]"
   -map "[v]" -map 1:a -c:a copy out.mp4
  
  ```
  
  where `3.5` should be replaced with the delayed start time (in seconds) of the shorter video.
  
  > **Comments:**
  > **username_0**: Awesome! But there was one missing point. Sync was proper. But the right video didn't start until the delay (13s) elapsed. Then both videos started simultaneously. In essence, I lost the first 13s of the right video  
  > **username_1**: See edited cmd.  
  > **username_0**: No. The update distorted. Both videos began simultaneously. After few seconds, left video paused for few seconds. Then it resumed in sync with the right video  
  > **username_1**: Show full log..  
  > **username_0**: https://drive.google.com/open?id=1gaX3d2ccbUcNjS8TqIPBL1kRX-sB4z0y  I have put the logs here  
  > **username_1**: You're using an older version of ffmpeg which needs manual buffering. Change first line of filters to `[0]trim=0:3.5,drawbox=c=black,fifo[delay];[delay][0]concat,fifo[left]`  
  > **username_0**: Got an Error https://drive.google.com/open?id=1vgDD6T0HlR7BBaUHLdybBzlfBQnJNqyx  I installed ffmpeg today from here http://ffmpeg.org/releases/ffmpeg-3.4.1.tar.bz2. I'm running on macbook pro Do, I need to install something else also?  
  > **username_1**: Get a binary from https://ffmpeg.zeranoe.com/builds/  
  > **username_0**: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/71182/discussion-between-username_0-s-n-and-mulvya).  
  > **username_1**: Use `ffmpeg -i left.mp4 -i right.mp4 -i left.mp4 -filter_complex "[0]trim=0:13,drawbox=c=black:t=fill[delay];[delay][2]concat[left];[left][1]hstack[v]" -map "[v]" -map 1:a -c:a copy out.mp4` with the new binary. This is an outstanding buffer mgmt issue.  
  > **username_0**: Error again!  https://drive.google.com/open?id=1fRWw03VP-GlCtDJOgHcWgs5dXUnRlb4t  
  > **username_1**: What's the output of `ffmpeg -hide_banner -filters`  
  > **username_0**: https://drive.google.com/open?id=13vBYu8M9wsiGXsJBTqgTB977sM7K2hlC  
  > **username_1**: It shows the concat filter. Rarely, there's a character coding issue when pasting to/from Stack Exchange. Retype the command at your end and run.  
  > **username_0**: Yes. Its working perfectly fine now. Thanks a lot! Also, I have one more request. A small extension. How to handle the below scenario. Left video should start after right video. But the length is such that left video extends after the right video ends. The current command handles this, but after right video ends, audio stops. Left video continues without audio. How to make such that after right video ends, audio should be taken from left video? Should I ask a new question for this?  
  > **username_1**: Ask a new Q. It's more convoluted to switch audio like that.  
  > **username_0**: I have asked here. https://video.stackexchange.com/q/23156/21062 Thanks!  
  
  ---
  
  