Answers.Body: <p>You can chain multiple overlay filters where each instance overlays one slide, but this will very quickly produce an unwieldy command. It's more convenient to do this in two steps. 1) Generate a video of the slides only with the required timings. 2) Use a simple ffmpeg command to overlay that video onto the main video.</p>
  
  <p>For the first step, I've pasted an earlier <a href="https://stackoverflow.com/q/28086775/5726027">answer</a> I gave:</p>
  
  <blockquote>
    <p>You can use a combination of two tools to do this: ffmpeg and
    <a href="https://stackoverflow.com/q/28086775/5726027">mp4fpsmod</a></p>
    
    <p><strong>Step 1</strong> is to generate a constant frame rate file using ffmpeg</p>
  
  <pre><code>ffmpeg -i images%d.bmp -pix_fmt yuv420p ffmpeg-cfr.mp4
  </code></pre>
    
    <p><strong>Step 2</strong> is to generate a timecode file like the one below, with each line containing the relative timestamp for a frame in
    milliseconds.</p>
  
  <pre><code># timecode format v2
  
  0
  33
  88
  100
  120
  160
  200
  230
  330
  347
  </code></pre>
    
    <p><strong>Step 3</strong> is to use mp4fpsmod to generate the VFR file</p>
  
  <pre><code>mp4fpsmod -o vfr.mp4 -t timecodes.txt ffmpeg-cfr.mp4 
  </code></pre>
    
    <p>This file plays as expected with <code>ffplay</code> but may not with some
    players, in which case run</p>
    
    <p><strong>Step 4</strong> Generate a CFR MP4 from the VFR using FFmpeg</p>
  
  <pre><code>ffmpeg -i vfr.mp4 final-cfr.mp4
  </code></pre>
    
    <p>This is a CFR file but the temporal relations are preserved as per the
    VFR, although there will be some PTS adjustments, if the timecode
    intervals are very irregular. That can be remedied by specifying a
    high framerate <code>-r N</code></p>
  </blockquote>
  
  <p>You'll have to rename your slide images so that their names form a continuous regular sequence. And for your case, I'd suggest your <strong>Step 1</strong> command should be </p>
  
  <pre><code>ffmpeg -i images%d.png -c:v libx264rgb -pix_fmt rgb24 ffmpeg-cfr.mp4
  </code></pre>
  
  <p>and <strong>Step 4</strong> if needed should be</p>
  
  <pre><code>ffmpeg -i vfr.mp4 -crf 16 -c:v libx264rgb final-cfr.mp4
  </code></pre>
  
  <p>You can then overlay the latest file onto the lecture video, using a command like the one in your question.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-03T23:00:01.237Z
Answers.Text: Thanks for your answer. I tried, but during the last step, I'm not sure how I should use the command you're reffering to. Here is what I tried but the slids aren't showing for a few seconds in the resulting video: `ffmpeg -i "Video name-WUUc5HYE3yY.mp4" -i final-cfr.mp4 -filter_complex "[0:v][1:v] overlay=25:25:enable='between(t,0,5)'" -pix_fmt yuv420p -c:a copy output.mp4`. What should I do instead?
Answers.UserDisplayName: Alexis Métaireau
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-04T05:11:35.933Z
Answers.Text: What's the first value in your timecode text file?
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-03T04:57:58.800Z
Answers.LastActivityDate: 2016-11-03T04:57:58.800Z
Answers.LastEditDate: 2017-05-23T12:40:36.170Z
Answers.UserDisplayName: Gyan
Body: <p>I have on one side a video (of someone giving a talk) and on the other side a list of slides that were used, and the timing at where the slides were switched. I want to embed the slides in a resulting video. Do you know how to do this?</p>
  
  <p>I've found how to do it with one image, but I don't know if it's possible to do it with multiple ones?</p>
  
  <p><code>ffmpeg -i input.mp4 -i image.png \
  -filter_complex "[0:v][1:v] overlay=25:25:enable='between(t,0,20)'" \
  -pix_fmt yuv420p -c:a copy \
  output.mp4</code></p>
  
Tags: <ffmpeg>
Title: How to embed multiple images in a video recording
UserDisplayName: Alexis Métaireau
ThreadText: # How to embed multiple images in a video recording
  
  (Asked by: username_0 on 2016-11-02)
  
  I have on one side a video (of someone giving a talk) and on the other side a list of slides that were used, and the timing at where the slides were switched. I want to embed the slides in a resulting video. Do you know how to do this?
  
  I've found how to do it with one image, but I don't know if it's possible to do it with multiple ones?
  
  `ffmpeg -i input.mp4 -i image.png \
  -filter_complex "[0:v][1:v] overlay=25:25:enable='between(t,0,20)'" \
  -pix_fmt yuv420p -c:a copy \
  output.mp4`
  
  **Tags:** ffmpeg
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-11-03. Score: 5 | Accepted answer
  
  You can chain multiple overlay filters where each instance overlays one slide, but this will very quickly produce an unwieldy command. It's more convenient to do this in two steps. 1) Generate a video of the slides only with the required timings. 2) Use a simple ffmpeg command to overlay that video onto the main video.
  
  For the first step, I've pasted an earlier [answer](https://stackoverflow.com/q/28086775/5726027) I gave:
  
  > You can use a combination of two tools to do this: ffmpeg and
  > [mp4fpsmod](https://stackoverflow.com/q/28086775/5726027)
  >
  > **Step 1** is to generate a constant frame rate file using ffmpeg
  >
  > ```
  > ffmpeg -i images%d.bmp -pix_fmt yuv420p ffmpeg-cfr.mp4
  >
  > ```
  >
  > **Step 2** is to generate a timecode file like the one below, with each line containing the relative timestamp for a frame in
  > milliseconds.
  >
  > ```
  > # timecode format v2
  >
  > 0
  > 33
  > 88
  > 100
  > 120
  > 160
  > 200
  > 230
  > 330
  > 347
  >
  > ```
  >
  > **Step 3** is to use mp4fpsmod to generate the VFR file
  >
  > ```
  > mp4fpsmod -o vfr.mp4 -t timecodes.txt ffmpeg-cfr.mp4 
  >
  > ```
  >
  > This file plays as expected with `ffplay` but may not with some
  > players, in which case run
  >
  > **Step 4** Generate a CFR MP4 from the VFR using FFmpeg
  >
  > ```
  > ffmpeg -i vfr.mp4 final-cfr.mp4
  >
  > ```
  >
  > This is a CFR file but the temporal relations are preserved as per the
  > VFR, although there will be some PTS adjustments, if the timecode
  > intervals are very irregular. That can be remedied by specifying a
  > high framerate `-r N`
  
  You'll have to rename your slide images so that their names form a continuous regular sequence. And for your case, I'd suggest your **Step 1** command should be
  
  ```
  ffmpeg -i images%d.png -c:v libx264rgb -pix_fmt rgb24 ffmpeg-cfr.mp4
  
  ```
  
  and **Step 4** if needed should be
  
  ```
  ffmpeg -i vfr.mp4 -crf 16 -c:v libx264rgb final-cfr.mp4
  
  ```
  
  You can then overlay the latest file onto the lecture video, using a command like the one in your question.
  
  > **Comments:**
  > **username_0**: Thanks for your answer. I tried, but during the last step, I'm not sure how I should use the command you're reffering to. Here is what I tried but the slids aren't showing for a few seconds in the resulting video: `ffmpeg -i "Video name-WUUc5HYE3yY.mp4" -i final-cfr.mp4 -filter_complex "[0:v][1:v] overlay=25:25:enable='between(t,0,5)'" -pix_fmt yuv420p -c:a copy output.mp4`. What should I do instead?  
  > **username_1**: What's the first value in your timecode text file?  
  
  ---
  
  