user19321: am trying to cut a part of Video
Here is the code i have tried Let's say i have 6 seconds video and i want to slow down 2:5 seconds video that 3 second video
First approach after searching is, Cut the video, then apply slow filter then concat it with original video. But this is a mid part not entire video. How can i modify below code

ffmpeg -i Soon.mp4 -filter_complex
  [0:v]trim=2:5,setpts=PTS-STARTPTS[v1];[v1]setpts=0.5PTS[v1];[0:a]atempo=2[a]
  concat=n=1:v=1:a=1 -map "[v]" -map "[a] -preset superfast -profile:v
  baseline output.mp4


user1871: This slows down one part of a video and keeps the rest as is.
ffmpeg -i Soon.mp4
  -filter_complex
     "[0:v]trim=0:2,setpts=PTS-STARTPTS[v1];
      [0:v]trim=2:5,setpts=2*(PTS-STARTPTS)[v2];
      [0:v]trim=5,setpts=PTS-STARTPTS[v3];
      [0:a]atrim=0:2,asetpts=PTS-STARTPTS[a1];
      [0:a]atrim=2:5,asetpts=PTS-STARTPTS,atempo=0.5[a2];
      [0:a]atrim=5,asetpts=PTS-STARTPTS[a3];
      [v1][a1][v2][a2][v3][a3]concat=n=3:v=1:a=1"
  -preset superfast -profile:v baseline output.mp4

How does it work?

The trim and atrim filters cut the video into different parts, from 0–2 seconds, from 2–5, and from 5 to the end.
In each part a setpts/asetpts filter is applied, which, when using the option PTS-STARTPTS, "resets" the presentation timestamps of each frame in each part, so that they can later be concatenated easily.
Each part is given an output label (e.g. [v1] through [v3]).
For the video parts that need to be slowed down, every presentation timestamp is doubled (2*(…)), which effectively halves the speed of the video. If you wanted to speed up the video, use a multiplier lower than 1.
For audio parts to be sped up / slowed down, use the atempo filter, whose parameter is the speedup (e.g., 0.5 = half speed).
These parts are finally concatenated using the concat filter.


19321: <p>am trying to cut a part of Video</p>

<p>Here is the code i have tried Let's say i have 6 seconds video and i want to slow down 2:5 seconds video that 3 second video</p>

<p>First approach after searching is, Cut the video, then apply slow filter then concat it with original video. But this is a mid part not entire video. How can i modify below code</p>

<blockquote>
  <p>ffmpeg -i Soon.mp4 -filter_complex
  [0:v]trim=2:5,setpts=PTS-STARTPTS[v1];[v1]setpts=0.5PTS[v1];[0:a]atempo=2[a]
  concat=n=1:v=1:a=1 -map "[v]" -map "[a] -preset superfast -profile:v
  baseline output.mp4</p>
</blockquote>
 1871: <p>This slows down one part of a video and keeps the rest as is.</p>

<pre><code>ffmpeg -i Soon.mp4
  -filter_complex
     "[0:v]trim=0:2,setpts=PTS-STARTPTS[v1];
      [0:v]trim=2:5,setpts=2*(PTS-STARTPTS)[v2];
      [0:v]trim=5,setpts=PTS-STARTPTS[v3];
      [0:a]atrim=0:2,asetpts=PTS-STARTPTS[a1];
      [0:a]atrim=2:5,asetpts=PTS-STARTPTS,atempo=0.5[a2];
      [0:a]atrim=5,asetpts=PTS-STARTPTS[a3];
      [v1][a1][v2][a2][v3][a3]concat=n=3:v=1:a=1"
  -preset superfast -profile:v baseline output.mp4
</code></pre>

<p>How does it work?</p>

<ul>
<li>The <code>trim</code> and <code>atrim</code> filters cut the video into different parts, from 0–2 seconds, from 2–5, and from 5 to the end.</li>
<li>In each part a <code>setpts</code>/<code>asetpts</code> filter is applied, which, when using the option <code>PTS-STARTPTS</code>, "resets" the presentation timestamps of each frame in each part, so that they can later be concatenated easily.</li>
<li>Each part is given an output label (e.g. <code>[v1]</code> through <code>[v3]</code>).</li>
<li>For the video parts that need to be slowed down, every presentation timestamp is doubled (<code>2*(…)</code>), which effectively halves the speed of the video. If you wanted to speed up the video, use a multiplier lower than 1.</li>
<li>For audio parts to be sped up / slowed down, use the <code>atempo</code> filter, whose parameter is the speedup (e.g., <code>0.5</code> = half speed).</li>
<li>These parts are finally concatenated using the <code>concat</code> filter.</li>
</ul>
