Answers.Body: <p>I'm going to call the video/image on top, overlay, and the bottom one, the photo.</p>
  
  <pre><code>ffmpeg -i photo -i overlay
         -filter_complex "[1]split=2[color][alpha];
                          [color]crop=iw/2:ih:0:0[color];[alpha]crop=iw/2:ih:iw/2:0[alpha];
                          [color][alpha]alphamerge[ovrly];
                          [0][ovrly]overlay=0:0" output.jpg
  </code></pre>
  
  <p>I assume that if the resolution of the video is WxH then the resolution of the photo is W/2 X H. If it's not, add a crop filter to the photo and then use that result in the overlay.</p>
  
  <p>If the resulting video has uneven dimensions, add a scale filter after the overlay to rectify that: <code>[0][ovrly]overlay=0:0,scale=2*trunc(iw/2):2*trunc(ih/2)</code></p>
  
  <hr>
  
  <p>If you have a sequence of images of the same resolution, then you can use the concat demuxer.</p>
  
  <p>First, create a text file,</p>
  
  <pre><code>file 'image1'
  duration 2.0
  file 'image2'
  duration 4.0
  file 'image3'
  duration 2.0
  </code></pre>
  
  <p>Then,</p>
  
  <pre><code>ffmpeg -f concat -i text -i overlay
         -filter_complex "[0]fps=25[bg];
                          [1]split=2[color][alpha];
                          [color]crop=iw/2:ih:0:0[color];[alpha]crop=iw/2:ih:iw/2:0[alpha];
                          [color][alpha]alphamerge[ovrly];
                          [bg][ovrly]overlay=0:0,scale=2*trunc(iw/2):2*trunc(ih/2)" output.jpg
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-03T14:02:48.083Z
Answers.Text: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/90513/discussion-on-answer-by-gyan-how-to-add-photos-in-background-to-a-video-using-ff).
Answers.UserDisplayName: Dr Mayhem
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-28T18:47:31.500Z
Answers.LastActivityDate: 2019-01-30T17:26:50.570Z
Answers.LastEditDate: 2019-01-30T17:26:50.570Z
Answers.UserDisplayName: Gyan
Body: <p>I saw one app and I'm willing to add photos similar to how that app does.</p>
  
  <p>Following is the screenshot of the video that I got from that app:</p>
  
  <p>I'm not sure what is the black part in there on the right-hand side.</p>
  
  <p>Below is the end result after a photo has been added:</p>
  
  <p>Now the photo that I've added seems like it's behind the video, so any help how to do that and an answer to what the black part the right side of the video is, then it will be great and highly appreciated.</p>
  
Tags: <video><ffmpeg>
Title: How to add Photos in background to a Video using FFMPEG
UserDisplayName: Siddharth
ThreadText: # How to add Photos in background to a Video using FFMPEG
  
  (Asked by: username_0 on 2019-01-28)
  
  I saw one app and I'm willing to add photos similar to how that app does.
  
  Following is the screenshot of the video that I got from that app:
  
  I'm not sure what is the black part in there on the right-hand side.
  
  Below is the end result after a photo has been added:
  
  Now the photo that I've added seems like it's behind the video, so any help how to do that and an answer to what the black part the right side of the video is, then it will be great and highly appreciated.
  
  **Tags:** video, ffmpeg
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-01-28. Score: 3
  
  I'm going to call the video/image on top, overlay, and the bottom one, the photo.
  
  ```
  ffmpeg -i photo -i overlay
         -filter_complex "[1]split=2[color][alpha];
                          [color]crop=iw/2:ih:0:0[color];[alpha]crop=iw/2:ih:iw/2:0[alpha];
                          [color][alpha]alphamerge[ovrly];
                          [0][ovrly]overlay=0:0" output.jpg
  
  ```
  
  I assume that if the resolution of the video is WxH then the resolution of the photo is W/2 X H. If it's not, add a crop filter to the photo and then use that result in the overlay.
  
  If the resulting video has uneven dimensions, add a scale filter after the overlay to rectify that: `[0][ovrly]overlay=0:0,scale=2*trunc(iw/2):2*trunc(ih/2)`
  
  ---
  
  If you have a sequence of images of the same resolution, then you can use the concat demuxer.
  
  First, create a text file,
  
  ```
  file 'image1'
  duration 2.0
  file 'image2'
  duration 4.0
  file 'image3'
  duration 2.0
  
  ```
  
  Then,
  
  ```
  ffmpeg -f concat -i text -i overlay
         -filter_complex "[0]fps=25[bg];
                          [1]split=2[color][alpha];
                          [color]crop=iw/2:ih:0:0[color];[alpha]crop=iw/2:ih:iw/2:0[alpha];
                          [color][alpha]alphamerge[ovrly];
                          [bg][ovrly]overlay=0:0,scale=2*trunc(iw/2):2*trunc(ih/2)" output.jpg
  
  ```
  
  > **Comments:**
  > **username_2**: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/90513/discussion-on-answer-by-username_1-how-to-add-photos-in-background-to-a-video-using-ff).  
  
  ---
  
  