Answers.Body: <p>Use the <a href="http://www.ffmpeg.org/ffmpeg-filters.html#interleave_002c-ainterleave" rel="nofollow noreferrer">interleave</a> filter.</p>
  <pre><code>ffmpeg -i video1 -i video2 -filter_complex &quot;[0]settb=AVTB,setpts=N/30/TB[v0];[1]settb=AVTB,setpts=N/30/TB[v1];[v0][v1]interleave=n=2&quot; out.mp4
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-21T03:44:08.167Z
Answers.LastActivityDate: 2023-08-21T03:44:08.167Z
Answers.UserDisplayName: Gyan
Body: <p>I have two videos and I want to go through them frame by frame<br />
  taking one frame from video 1, followed by 1 frame of video 2<br />
  then the next frame of video 1, followed by the next frame of video 2.</p>
  <p>Like depicted in the following image:</p>
  <p><a href="https://i.sstatic.net/c8ZHd.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/c8ZHd.png" alt="Example of input and output" /></a></p>
  <p>Or, if the image does not load:</p>
  <pre><code>Video 1: [a][b][c]
  Video 2: [1][2][3]
  Result:  [a][1][b][2][c][3]
  </code></pre>
  <p>The way I have done it now is by using <code>ffmpeg</code> to convert every<br />
  video to a series of <code>png</code> files on disk. Renaming them and then<br />
  combining them back into a single video:</p>
  <p><code>ffmpeg -framerate 60 -i %03d.png -c:v libx265 -preset slow -crf 23 output4.mp4 </code></p>
  <pre><code>Note: The input videos were each 30fps, so I selected 60fps for the output.
  </code></pre>
  <p>Is there a way to do this using <code>ffmpeg</code> in a single command without storing all frames on disk first?</p>
  
Tags: <ffmpeg><video>
Title: Is there a way to combine two videos interlaced frame by frame with a single ffmpeg command?
UserDisplayName: TimothyP
ThreadText: # Is there a way to combine two videos interlaced frame by frame with a single ffmpeg command?
  
  (Asked by: username_0 on 2023-08-21)
  
  I have two videos and I want to go through them frame by frame  
  taking one frame from video 1, followed by 1 frame of video 2  
  then the next frame of video 1, followed by the next frame of video 2.
  
  Like depicted in the following image:
  
  [![Example of input and output](https://i.sstatic.net/c8ZHd.png)](https://i.sstatic.net/c8ZHd.png)
  
  Or, if the image does not load:
  
  ```
  Video 1: [a][b][c]
  Video 2: [1][2][3]
  Result:  [a][1][b][2][c][3]
  
  ```
  
  The way I have done it now is by using `ffmpeg` to convert every  
  video to a series of `png` files on disk. Renaming them and then  
  combining them back into a single video:
  
  `ffmpeg -framerate 60 -i %03d.png -c:v libx265 -preset slow -crf 23 output4.mp4`
  
  ```
  Note: The input videos were each 30fps, so I selected 60fps for the output.
  
  ```
  
  Is there a way to do this using `ffmpeg` in a single command without storing all frames on disk first?
  
  **Tags:** ffmpeg, video
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-08-21. Score: 1
  
  Use the [interleave](http://www.ffmpeg.org/ffmpeg-filters.html#interleave_002c-ainterleave) filter.
  
  ```
  ffmpeg -i video1 -i video2 -filter_complex "[0]settb=AVTB,setpts=N/30/TB[v0];[1]settb=AVTB,setpts=N/30/TB[v1];[v0][v1]interleave=n=2" out.mp4
  
  ```
  
  
  ---
  
  