Answers.Body: <p>Here is an example:</p>
  <p>Overlay &quot;01.png&quot; after 3 seconds for a duration is 4 seconds.</p>
  <p>Then overlay &quot;02.png&quot; immediately after the first image for a duration of 5 seconds.</p>
  <p>Both images are scaled to 400x300 and positioned in the upper right corner.</p>
  <p>The variables make the ffmpeg commands easier to understand.</p>
  <pre class="lang-bash prettyprint-override"><code># video
  v=video.mp4
  
  # image 1
  i1=01.png
  
  # image 1 start
  i1_s=3
  
  # image 1 duration in seconds
  i1_dur=4
  
  # wait after image 1 is displayed for this duration. &quot;0&quot; displays image 2 immediately after image 1
  w1=0
  
  # image 2
  i2=02.png 
  
  # image 2 duration in seconds
  i2_dur=5
  
  # framerate
  fr=25
  
  # image width
  i_w=400
  
  # image height
  i_h=300
  
  ffmpeg \
  -i &quot;$v&quot; -framerate $fr \
  -i &quot;$i1&quot; -framerate $fr \
  -i &quot;$i2&quot; -filter_complex &quot;\
  [0:v]scale=1280:720[v0];\
  [1:v]fps=$fr,trim=0:$i1_dur,scale=$i_w:$i_h[i1];\
  [2:v]fps=$fr,trim=0:$i2_dur,scale=$i_w:$i_h[i2];\
  [v0][i1]overlay=W-w-10:10:enable='between(t,$i1_s,$i1_s+$i1_dur)'[v1];\
  [v1][i2]overlay=W-w-10:10:enable='between(t,$w1+$i1_s+$i1_dur,$w1+$i1_s+$i1_dur+$i2_dur)'&quot; -c:v libx264 -crf 18 -preset veryfast output.mp4
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-21T14:44:28.377Z
Answers.LastActivityDate: 2023-08-21T14:44:28.377Z
Answers.UserDisplayName: drake7
Body: <p>Insert PNG at exact position of a video, with exact duration - is it possible with FFMPEG?</p>
  <p>If not, then may be with other software?</p>
  <p>I have several hundreds of PNGs. Each needs to be inserted at exact position and displayed until the next PNG comes.</p>
  <p>Time intervals between them are irregular. Some should be displayed for 10 seconds, the other - for 2 minutes etc.</p>
  
Tags: <ffmpeg>
Title: Insert PNG at exact position of a video, with exact duration
UserDisplayName: Paul
ThreadText: # Insert PNG at exact position of a video, with exact duration
  
  (Asked by: username_0 on 2023-08-19)
  
  Insert PNG at exact position of a video, with exact duration - is it possible with FFMPEG?
  
  If not, then may be with other software?
  
  I have several hundreds of PNGs. Each needs to be inserted at exact position and displayed until the next PNG comes.
  
  Time intervals between them are irregular. Some should be displayed for 10 seconds, the other - for 2 minutes etc.
  
  **Tags:** ffmpeg
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-08-21. Score: 0
  
  Here is an example:
  
  Overlay "01.png" after 3 seconds for a duration is 4 seconds.
  
  Then overlay "02.png" immediately after the first image for a duration of 5 seconds.
  
  Both images are scaled to 400x300 and positioned in the upper right corner.
  
  The variables make the ffmpeg commands easier to understand.
  
  ```bash
  # video
  v=video.mp4
  
  # image 1
  i1=01.png
  
  # image 1 start
  i1_s=3
  
  # image 1 duration in seconds
  i1_dur=4
  
  # wait after image 1 is displayed for this duration. "0" displays image 2 immediately after image 1
  w1=0
  
  # image 2
  i2=02.png 
  
  # image 2 duration in seconds
  i2_dur=5
  
  # framerate
  fr=25
  
  # image width
  i_w=400
  
  # image height
  i_h=300
  
  ffmpeg \
  -i "$v" -framerate $fr \
  -i "$i1" -framerate $fr \
  -i "$i2" -filter_complex "\
  [0:v]scale=1280:720[v0];\
  [1:v]fps=$fr,trim=0:$i1_dur,scale=$i_w:$i_h[i1];\
  [2:v]fps=$fr,trim=0:$i2_dur,scale=$i_w:$i_h[i2];\
  [v0][i1]overlay=W-w-10:10:enable='between(t,$i1_s,$i1_s+$i1_dur)'[v1];\
  [v1][i2]overlay=W-w-10:10:enable='between(t,$w1+$i1_s+$i1_dur,$w1+$i1_s+$i1_dur+$i2_dur)'" -c:v libx264 -crf 18 -preset veryfast output.mp4
  
  ```
  
  
  ---
  
  