Answers.Body: <p>Use the concat demuxer instead:</p>
  
  <p>Create a text file of the following format</p>
  
  <pre><code>file 'C:\source.mp4'
  inpoint 0
  duration 1
  file 'C:\source.mp4'
  inpoint 3
  duration 1
  file 'C:\source.mp4'
  inpoint 6
  duration 1
  file 'C:\source.mp4'
  inpoint 9
  duration 1
  </code></pre>
  
  <p>Then run</p>
  
  <pre><code>ffmpeg -f concat -i file.txt -map 0:v -map 0:a? -vcodec h264 -acodec aac -pix_fmt yuv420p -strict -2 -fflags +genpts C:\output.mp4
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-07T17:06:19.807Z
Answers.LastActivityDate: 2016-04-07T17:06:19.807Z
Answers.UserDisplayName: Gyan
Body: <p>I'm splitting and merging a single video clip using this ffmpeg command:</p>
  
  <pre><code>-ss 0 -t 1 -i C:\source.mp4 
  -ss 3 -t 1 -i C:\source.mp4 
  -ss 6 -t 1 -i C:\source.mp4 
  -ss 9 -t 1 -i C:\source.mp4 
  -filter_complex "[0:v][1:v][2:v][3:v]concat=n=4[outv];
  [0:a][1:a][2:a][3:a]concat=n=4:=v=0:a=1[outa]" -map [outv] -map [outa]
  -vcodec h264 -acodec aac -pix_fmt yuv420p -strict -2 C:\output.mp4
  </code></pre>
  
  <p>But if source file doesn't have audio track, this command fails. if I remove 
      ;[0:a][1:a][2:a][3:a]concat=n=4:=v=0:a=1[outa]
  part it fixes the problem but I need to analyse file before using the command.</p>
  
  <p>is there any parameter that will automaticly remove this part or ignores audio track if source doesnt have any audio track at all.</p>
  
Tags: <ffmpeg><filter>
Title: ffmpeg concat with or without audio
UserDisplayName: Nooneelse
ThreadText: # ffmpeg concat with or without audio
  
  (Asked by: username_0 on 2016-04-07)
  
  I'm splitting and merging a single video clip using this ffmpeg command:
  
  ```
  -ss 0 -t 1 -i C:\source.mp4 
  -ss 3 -t 1 -i C:\source.mp4 
  -ss 6 -t 1 -i C:\source.mp4 
  -ss 9 -t 1 -i C:\source.mp4 
  -filter_complex "[0:v][1:v][2:v][3:v]concat=n=4[outv];
  [0:a][1:a][2:a][3:a]concat=n=4:=v=0:a=1[outa]" -map [outv] -map [outa]
  -vcodec h264 -acodec aac -pix_fmt yuv420p -strict -2 C:\output.mp4
  
  ```
  
  But if source file doesn't have audio track, this command fails. if I remove
  ;[0:a][1:a][2:a][3:a]concat=n=4:=v=0:a=1[outa]
  part it fixes the problem but I need to analyse file before using the command.
  
  is there any parameter that will automaticly remove this part or ignores audio track if source doesnt have any audio track at all.
  
  **Tags:** ffmpeg, filter
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-04-07. Score: 3
  
  Use the concat demuxer instead:
  
  Create a text file of the following format
  
  ```
  file 'C:\source.mp4'
  inpoint 0
  duration 1
  file 'C:\source.mp4'
  inpoint 3
  duration 1
  file 'C:\source.mp4'
  inpoint 6
  duration 1
  file 'C:\source.mp4'
  inpoint 9
  duration 1
  
  ```
  
  Then run
  
  ```
  ffmpeg -f concat -i file.txt -map 0:v -map 0:a? -vcodec h264 -acodec aac -pix_fmt yuv420p -strict -2 -fflags +genpts C:\output.mp4
  
  ```
  
  
  ---
  
  