<p>If I understand the question correctly: yes! You can create a file that is a concatenation of different parts of the input video.</p>
<p>The script you're looking for is something like:</p>
<pre><code>ffmpeg \
-i &quot;$INPUT_FILE&quot; \
-filter_complex \
&quot;[0:v]trim=start=5:duration=10,setpts=PTS-STARTPTS[v0]; \
 [0:a]atrim=start=5:duration=10,asetpts=PTS-STARTPTS[a0]; \
 [0:v]trim=start=20:duration=10,setpts=PTS-STARTPTS[v1];
 [0:a]atrim=start=20:duration=10,asetpts=PTS-STARTPTS[a1]; \
 [v0][a0][v1][a1]concat=n=2:v=1:a=1[final]&quot; \
-map &quot;[final]&quot; concat-video.mp4
</code></pre>
<p>You can read a little bit more about this on <a href="https://mediamachine.io/blog/ffmpeg-series-complex-filters-trim-concat" rel="nofollow noreferrer">this blog post</a></p>
<p>(Disclaimer: I'm one of the co-founder of <a href="https://mediamachine.io" rel="nofollow noreferrer">https://mediamachine.io</a>)</p>
<p>Hope this helps!</p>

CC BY-SA 4.0
2021-04-19T23:18:55.153Z
2021-04-19T23:18:55.153Z
GiaNU
<p>Is it possible to concat without temp files using ffmpeg?
eg;</p>
<pre><code># nice ffmpeg -v error -f concat \
  -ss &quot;52.519&quot; -copyts -to &quot;53.153&quot; -i in.mkv \
  -ss &quot;53.186&quot; -copyts -to &quot;390.690&quot; -i in.mkv \
  -ss &quot;464.264&quot; -copyts -to &quot;2831.331&quot; -i in.mkv \
  -c copy out.mkv &lt; /dev/null
Invalid duration specification for ss: &quot;52.519&quot;
</code></pre>
<p>if so, what is ffmpeg version 4.2.4 complaining about?
the &quot;duration specification&quot; is valid when using temp files followed by concat.</p>
<p>mkvtoolnix is able to do this btw.</p>

<ffmpeg><concatenation>
ffmpeg: concat without temp files?
user1133275
# ffmpeg: concat without temp files?

(Asked by: username_0 on 2021-04-11)

Is it possible to concat without temp files using ffmpeg?
eg;
# nice ffmpeg -v error -f concat \
  -ss "52.519" -copyts -to "53.153" -i in.mkv \
  -ss "53.186" -copyts -to "390.690" -i in.mkv \
  -ss "464.264" -copyts -to "2831.331" -i in.mkv \
  -c copy out.mkv < /dev/null
Invalid duration specification for ss: "52.519"

if so, what is ffmpeg version 4.2.4 complaining about?
the "duration specification" is valid when using temp files followed by concat.
mkvtoolnix is able to do this btw.

**Tags:** ffmpeg, concatenation


---

## 1 answers

### Answer by username_1 on 2021-04-19. Score: 2

If I understand the question correctly: yes! You can create a file that is a concatenation of different parts of the input video.
The script you're looking for is something like:
ffmpeg \
-i "$INPUT_FILE" \
-filter_complex \
"[0:v]trim=start=5:duration=10,setpts=PTS-STARTPTS[v0]; \
 [0:a]atrim=start=5:duration=10,asetpts=PTS-STARTPTS[a0]; \
 [0:v]trim=start=20:duration=10,setpts=PTS-STARTPTS[v1];
 [0:a]atrim=start=20:duration=10,asetpts=PTS-STARTPTS[a1]; \
 [v0][a0][v1][a1]concat=n=2:v=1:a=1[final]" \
-map "[final]" concat-video.mp4

You can read a little bit more about this on this blog post
(Disclaimer: I'm one of the co-founder of https://mediamachine.io)
Hope this helps!


---

