Answers.Body: <p>concat demuxer</p>
  <pre><code>#!/bin/bash
  
  f=&quot;../input.mp3&quot;
  a=&quot;in.mp3&quot;
  
  # get duration of input
  d=$(ffprobe -v 0 -show_entries format=duration -of default=nw=1:nk=1 &quot;$f&quot;)
  
  # get seconds
  d=${d%.*}
  echo $d
  
  # variables
  i=0
  o=60
  
  # create list of inputs
  l=&quot;list.txt&quot;
  echo &quot;ffconcat version 1.0&quot; &gt; $l
  echo &quot;file '$f'&quot; &gt;&gt; $l
  echo &quot;outpoint $o&quot; &gt;&gt; $l
  # increase variables by 60 sec
  i=$o
  ((o+=60))
  while (( $i &lt; $d )); do
      # insert audio clip
      echo &quot;file '$a'&quot; &gt;&gt; $l
      # add audio next 60 sec
      echo &quot;file '$f'&quot; &gt;&gt; $l
      echo &quot;inpoint $i&quot; &gt;&gt; $l
      echo &quot;outpoint $o&quot; &gt;&gt; $l
      # increase variables by 60 sec
      i=$o
      ((o+=60))
  done
  cat $l
  
  ffmpeg -f concat -safe 0 -i &quot;$l&quot; -c copy output.mp3 -y
  
  ffplay output.mp3
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-21T14:32:21.937Z
Answers.Text: could you please explain me, how this solves it , so I can extend and use it to my needs?
Answers.UserDisplayName: Aarav Shah
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-21T05:04:53.610Z
Answers.LastActivityDate: 2024-01-22T02:21:37.237Z
Answers.LastEditDate: 2024-01-22T02:21:37.237Z
Answers.UserDisplayName: Баяр Гончикжапов
Body: <p>I am trying to use FFmpeg to insert an audio clip at every 60 seconds into an audio file. I also want to delay the original audio stream  until the end of the inserted audio clip , so that the inserted audio doesn't overlap with the original audio.</p>
  <p>I would prefer a solution that doesn't involve splitting the original file into 60 seconds videos and then combine then together , as it makes the following steps, that I have to do, many times more complex.</p>
  <h2>Possible Solution:</h2>
  <p>I think the <code>-ss</code> flag could be used to set the timestamp of the inserted audio clip to 60 seconds after the end of the last segment. Then, I could use a delay filter to delay the original audio track until the end of the inserted audio clip.</p>
  <p>However I am not sure how to create command. Mainly the part , where we apply this filter at every 60 seconds intervals.</p>
  <p>Thanks for any help in advance!!</p>
  
Tags: <ffmpeg><editing>
Title: Insert Audio at Every 60 Seconds and Delay Another Audio Stream until the End of the Inserted Audio with ffmpeg
UserDisplayName: Aarav Shah
ThreadText: # Insert Audio at Every 60 Seconds and Delay Another Audio Stream until the End of the Inserted Audio with ffmpeg
  
  (Asked by: username_0 on 2024-01-20)
  
  I am trying to use FFmpeg to insert an audio clip at every 60 seconds into an audio file. I also want to delay the original audio stream until the end of the inserted audio clip , so that the inserted audio doesn't overlap with the original audio.
  
  I would prefer a solution that doesn't involve splitting the original file into 60 seconds videos and then combine then together , as it makes the following steps, that I have to do, many times more complex.
  
  ## Possible Solution:
  
  I think the `-ss` flag could be used to set the timestamp of the inserted audio clip to 60 seconds after the end of the last segment. Then, I could use a delay filter to delay the original audio track until the end of the inserted audio clip.
  
  However I am not sure how to create command. Mainly the part , where we apply this filter at every 60 seconds intervals.
  
  Thanks for any help in advance!!
  
  **Tags:** ffmpeg, editing
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-01-21. Score: 0 | Accepted answer
  
  concat demuxer
  
  ```
  #!/bin/bash
  
  f="../input.mp3"
  a="in.mp3"
  
  # get duration of input
  d=$(ffprobe -v 0 -show_entries format=duration -of default=nw=1:nk=1 "$f")
  
  # get seconds
  d=${d%.*}
  echo $d
  
  # variables
  i=0
  o=60
  
  # create list of inputs
  l="list.txt"
  echo "ffconcat version 1.0" > $l
  echo "file '$f'" >> $l
  echo "outpoint $o" >> $l
  # increase variables by 60 sec
  i=$o
  ((o+=60))
  while (( $i < $d )); do
      # insert audio clip
      echo "file '$a'" >> $l
      # add audio next 60 sec
      echo "file '$f'" >> $l
      echo "inpoint $i" >> $l
      echo "outpoint $o" >> $l
      # increase variables by 60 sec
      i=$o
      ((o+=60))
  done
  cat $l
  
  ffmpeg -f concat -safe 0 -i "$l" -c copy output.mp3 -y
  
  ffplay output.mp3
  
  ```
  
  > **Comments:**
  > **username_0**: could you please explain me, how this solves it , so I can extend and use it to my needs?  
  
  ---
  
  