Answers.Body: <p><strong>#1</strong> Using concat filter i.e. without textfile</p>
  
  <pre><code>ffmpeg -ss 0 -t 20:00 -i inputA.avi -ss 0 -t 10:00 -i inputB.avi -filter_complex "[0:v][0:a][1:v][1:a]concat=n=2:v=1:a=1" out.mp4
  </code></pre>
  
  <p>--OR--</p>
  
  <p><strong>#2</strong> Using concat demuxer i.e. with textfile</p>
  
  <pre><code>file inputA-trim.avi
  inpoint 0
  outpoint 20:00
  file inputB-trim.avi
  inpoint 0
  outpoint 10:00
  </code></pre>
  
  <p>and then your final command</p>
  
  <pre><code>ffmpeg -f concat -i inputList.txt [rest of command] final.mp4
  </code></pre>
  
  <hr>
  
  <p>See <a href="https://trac.ffmpeg.org/wiki/Concatenate" rel="noreferrer">https://trac.ffmpeg.org/wiki/Concatenate</a> for details.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-27T23:05:39.320Z
Answers.Text: I have tested the second option listed, with the input txt file. I had to add `-safe 0` to avoid an "unsafe filename" error. The final command I used was `ffmpeg -f concat -safe 0 -i inputList.txt -vf "scale=1280:720,setsar=1" -crf 30 -an -movflags +faststart final.mp4`. I'll test the first option some other time. Thanks.
Answers.UserDisplayName: user3643
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-27T23:17:26.113Z
Answers.Text: I guess I had to use `-safe 0` because I had absolute full paths in my input txt file.
Answers.UserDisplayName: user3643
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-29T21:38:24.287Z
Answers.Text: I've been using the first option for some time now. Just noticed I mentioned I would test it, but never reported back.
Answers.UserDisplayName: user3643
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-11T22:07:20.000Z
Answers.Text: Does the concat filter re-encode?
Answers.UserDisplayName: Hashim Aziz
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-12T04:05:41.537Z
Answers.Text: The concat filter will require a re-encode. All frame filters will lead to a re-encode.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-27T05:59:33.220Z
Answers.LastActivityDate: 2019-05-18T05:18:14.503Z
Answers.LastEditDate: 2019-05-18T05:18:14.503Z
Answers.UserDisplayName: Gyan
Body: <p>I'm trying to make a single ffmpeg command that will take multiple inputs, seek specific times within them, then output to a single file.</p>
  
  <p>For example, I have <code>inputA.avi</code> and <code>inputB.avi</code> and each is 1 hour long. I want a single output file that takes <code>inputA.avi</code> from 00:00:00 to 00:20:00 for the beginning and <code>inputB.avi</code> from 00:00:00 to 00:10:00 for the end. The end result should be a 30 minute video file that has the first 20 minutes of <code>inputA</code> then the first 10 minutes of <code>inputB</code>.</p>
  
  <p>I currently can do the following three commands to get the job done:</p>
  
  <pre><code>ffmpeg -ss 00:00:00 -t 00:20:00 -i inputA.avi [rest of command] inputA-trim.avi
  ffmpeg -ss 00:00:00 -t 00:10:00 -i inputB.avi [rest of command] inputB-trim.avi
  ffmpeg -f concat -i inputList.txt [rest of command] final.mp4
  </code></pre>
  
  <p>where inputList.txt contains only</p>
  
  <pre><code>file inputA-trim.avi
  file inputB-trim.avi
  </code></pre>
  
  <p>This works, but has unnecessary steps and creates intermediary files. I also have to create a batch file and txt file to get everything to run in succession. I'd like to be able to create a single ffmpeg command that can take multiple inputs with individual <code>-ss</code> and <code>-t</code> commands, then put them in a single output.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-26T21:41:01.673Z
Comments.Text: [This question seemed to be asking for close to the same thing](https://video.stackexchange.com/questions/20985/extract-multiples-images-from-multiples-videos-with-ffmpeg), but the OP accepted a solution that essentially is what I am doing with the three commands in my question.
Comments.UserDisplayName: user3643
Tags: <ffmpeg>
Title: How to take multiple inputs with specific trim times to one output, single command ffmpeg
UserDisplayName: user3643
ThreadText: # How to take multiple inputs with specific trim times to one output, single command ffmpeg
  
  (Asked by: username_0 on 2018-10-26)
  
  I'm trying to make a single ffmpeg command that will take multiple inputs, seek specific times within them, then output to a single file.
  
  For example, I have `inputA.avi` and `inputB.avi` and each is 1 hour long. I want a single output file that takes `inputA.avi` from 00:00:00 to 00:20:00 for the beginning and `inputB.avi` from 00:00:00 to 00:10:00 for the end. The end result should be a 30 minute video file that has the first 20 minutes of `inputA` then the first 10 minutes of `inputB`.
  
  I currently can do the following three commands to get the job done:
  
  ```
  ffmpeg -ss 00:00:00 -t 00:20:00 -i inputA.avi [rest of command] inputA-trim.avi
  ffmpeg -ss 00:00:00 -t 00:10:00 -i inputB.avi [rest of command] inputB-trim.avi
  ffmpeg -f concat -i inputList.txt [rest of command] final.mp4
  
  ```
  
  where inputList.txt contains only
  
  ```
  file inputA-trim.avi
  file inputB-trim.avi
  
  ```
  
  This works, but has unnecessary steps and creates intermediary files. I also have to create a batch file and txt file to get everything to run in succession. I'd like to be able to create a single ffmpeg command that can take multiple inputs with individual `-ss` and `-t` commands, then put them in a single output.
  
  **Tags:** ffmpeg
  
  > **Comments:**
  > **username_0**: [This question seemed to be asking for close to the same thing](https://video.stackexchange.com/questions/20985/extract-multiples-images-from-multiples-videos-with-ffmpeg), but the OP accepted a solution that essentially is what I am doing with the three commands in my question.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-10-27. Score: 7 | Accepted answer
  
  **#1** Using concat filter i.e. without textfile
  
  ```
  ffmpeg -ss 0 -t 20:00 -i inputA.avi -ss 0 -t 10:00 -i inputB.avi -filter_complex "[0:v][0:a][1:v][1:a]concat=n=2:v=1:a=1" out.mp4
  
  ```
  
  --OR--
  
  **#2** Using concat demuxer i.e. with textfile
  
  ```
  file inputA-trim.avi
  inpoint 0
  outpoint 20:00
  file inputB-trim.avi
  inpoint 0
  outpoint 10:00
  
  ```
  
  and then your final command
  
  ```
  ffmpeg -f concat -i inputList.txt [rest of command] final.mp4
  
  ```
  
  ---
  
  See <https://trac.ffmpeg.org/wiki/Concatenate> for details.
  
  > **Comments:**
  > **username_0**: I have tested the second option listed, with the input txt file. I had to add `-safe 0` to avoid an "unsafe filename" error. The final command I used was `ffmpeg -f concat -safe 0 -i inputList.txt -vf "scale=1280:720,setsar=1" -crf 30 -an -movflags +faststart final.mp4`. I'll test the first option some other time. Thanks.  
  > **username_0**: I guess I had to use `-safe 0` because I had absolute full paths in my input txt file.  
  > **username_0**: I've been using the first option for some time now. Just noticed I mentioned I would test it, but never reported back.  
  > **username_2**: Does the concat filter re-encode?  
  > **username_1**: The concat filter will require a re-encode. All frame filters will lead to a re-encode.  
  
  ---
  
  