Answers.Body: <p>Thanks to <a href="https://video.stackexchange.com/users/4273/celdor">Celdor</a> for identifying the problem.</p>
  <p>The build of ffmpeg I had installed on my system was the culprit. Here's the output of running <code>ffmpeg -version</code> in the command line</p>
  <pre><code>ffmpeg version N-113032-g76cd71bf0c-20231219 Copyright (c) 2000-2023 the FFmpeg developers built with gcc 13.2.0 (crosstool-NG 1.25.0.232_c175b21)
  </code></pre>
  <p>The problem was solved after I installed the build of ffmpeg from <a href="https://github.com/BtbN/FFmpeg-Builds/releases" rel="nofollow noreferrer">BtbN</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-11T19:37:38.013Z
Answers.LastActivityDate: 2024-02-11T19:37:38.013Z
Answers.UserDisplayName: icyGuy
Body: <p>I'm trying to split &amp; combine multiple portions of the same video file.</p>
  <p>Since there are multiple portions that I want to combine, I want to use filtercomplex to do this.</p>
  <p>Also, since some of the portions are quite small in duration, I want to use precise timestamps (setpts=PTS-STARTPTS)</p>
  <p>The &quot;script.txt&quot; file contains the code below.</p>
  <pre><code>[0:v]trim=0.823625:5.88717,setpts=PTS-STARTPTS[v0];
  [0:a]atrim=0.823625:5.88717,asetpts=PTS-STARTPTS[a0];
  [0:v]trim=6.87858:10.2093,setpts=PTS-STARTPTS[v1];
  [0:a]atrim=6.87858:10.2093,asetpts=PTS-STARTPTS[a1];
  [0:v]trim=10.5683:11.5989,setpts=PTS-STARTPTS[v2];
  [0:a]atrim=10.5683:11.5989,asetpts=PTS-STARTPTS[a2];
  [0:v]trim=11.9066:13.2301,setpts=PTS-STARTPTS[v3];
  [0:a]atrim=11.9066:13.2301,asetpts=PTS-STARTPTS[a3];
  [0:v]trim=14.2123:14.903,setpts=PTS-STARTPTS[v4];
  [0:a]atrim=14.2123:14.903,asetpts=PTS-STARTPTS[a4];
  [0:v]trim=15.2467:16.5819,setpts=PTS-STARTPTS[v5];
  [0:a]atrim=15.2467:16.5819,asetpts=PTS-STARTPTS[a5];
  [0:v]trim=17.1012:20.1223,setpts=PTS-STARTPTS[v6];
  [0:a]atrim=17.1012:20.1223,asetpts=PTS-STARTPTS[a6];
  [0:v]trim=20.9504:22.5714,setpts=PTS-STARTPTS[v7];
  [0:a]atrim=20.9504:22.5714,asetpts=PTS-STARTPTS[a7];
  [0:v]trim=23.4482:24.8745,setpts=PTS-STARTPTS[v8];
  [0:a]atrim=23.4482:24.8745,asetpts=PTS-STARTPTS[a8];
  [0:v]trim=25.5697:26.8718,setpts=PTS-STARTPTS[v9];
  [0:a]atrim=25.5697:26.8718,asetpts=PTS-STARTPTS[a9];
  [0:v]trim=27.5758:27.9942,setpts=PTS-STARTPTS[v10];
  [0:a]atrim=27.5758:27.9942,asetpts=PTS-STARTPTS[a10];
  [0:v]trim=28.5431:30,setpts=PTS-STARTPTS[v11];
  [0:a]atrim=28.5431:30,asetpts=PTS-STARTPTS[a11];
  [v0][a0][v1][a1][v2][a2][v3][a3][v4][a4][v5][a5][v6][a6][v7][a7][v8][a8][v9][a9][v10][a10][v11][a11]
  concat=n=12:v=1:a=1[outv][outa]
  </code></pre>
  <p>The command that I am using to run ffmpeg with this script file is as below</p>
  <pre><code>ffmpeg -i &quot;input.mp4&quot; -c:v libx265 -filter_complex_script &quot;script.txt&quot; -map [outv] -map [outa] &quot;output.mp4&quot;
  </code></pre>
  <p>But after running this command, the output video file is only ~5 seconds long (the very first portion of the input video).</p>
  <p>As we can see from the first line of the &quot;script.txt&quot;, the start timestamp is ~0.8 and the end timestamp is ~5.8 giving a duration of ~5s for the first piece of the output video.</p>
  <p>So, ffmpeg is not joining any other parts of the input video after the first part. I am unable to understand why so.</p>
  <p>I am facing this problem since the past couple of months after I updated ffmpeg. The same syntax of script file and command line used to work fine before that. Did any changes in the update alter the syntax that ffmpeg expects for this task?</p>
  <p>Any help is much appreciated.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-02-11T12:58:01.423Z
Comments.Text: Hey, I tried to edit your answer on a tablet to improve code formatting. I don't know why but it messed  up the whole line. I can't see history and now I am not sure what your output was. Was it `"output.txt`? Probably not.
Comments.UserDisplayName: Celdor
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-02-11T13:07:24.603Z
Comments.Text: Everything seems to work on my end. Just copied the command line assuming output is `output.mp4` and have a 22 sec. long video. The question is how did you install FFMpeg. Are you using any non-standard version? This could be important because I used to have a similar issue. There are two version for Windows [gyan.dev](https://www.gyan.dev/ffmpeg/builds/) and [BtbN](https://github.com/BtbN/FFmpeg-Builds/releases). My script for splitting a video only worked using the second version BtbN. BTW your script works on BtbN.
Comments.UserDisplayName: Celdor
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-02-11T19:30:51.763Z
Comments.Text: The output was output.mp4.
  
  This is the result of running ffmpeg -version on my current installed ffmpeg.
  
  ffmpeg version N-113032-g76cd71bf0c-20231219 Copyright (c) 2000-2023 the FFmpeg developers built with gcc 13.2.0 (crosstool-NG 1.25.0.232_c175b21)
  
  I tried the above script file & command line with this version of ffmpeg & got the output video that's only ~5s long.
  
  Then I tried the same script & command line on the ffmpeg build from the BtbN link you suggested & got ~22s long output video. So now the problem has been identified & I can solve it now. Thanks
Comments.UserDisplayName: icyGuy
Tags: <ffmpeg>
Title: ffmpeg problem with split & combine portions of same video
UserDisplayName: icyGuy
ThreadText: # ffmpeg problem with split & combine portions of same video
  
  (Asked by: username_0 on 2024-02-10)
  
  I'm trying to split & combine multiple portions of the same video file.
  
  Since there are multiple portions that I want to combine, I want to use filtercomplex to do this.
  
  Also, since some of the portions are quite small in duration, I want to use precise timestamps (setpts=PTS-STARTPTS)
  
  The "script.txt" file contains the code below.
  
  ```
  [0:v]trim=0.823625:5.88717,setpts=PTS-STARTPTS[v0];
  [0:a]atrim=0.823625:5.88717,asetpts=PTS-STARTPTS[a0];
  [0:v]trim=6.87858:10.2093,setpts=PTS-STARTPTS[v1];
  [0:a]atrim=6.87858:10.2093,asetpts=PTS-STARTPTS[a1];
  [0:v]trim=10.5683:11.5989,setpts=PTS-STARTPTS[v2];
  [0:a]atrim=10.5683:11.5989,asetpts=PTS-STARTPTS[a2];
  [0:v]trim=11.9066:13.2301,setpts=PTS-STARTPTS[v3];
  [0:a]atrim=11.9066:13.2301,asetpts=PTS-STARTPTS[a3];
  [0:v]trim=14.2123:14.903,setpts=PTS-STARTPTS[v4];
  [0:a]atrim=14.2123:14.903,asetpts=PTS-STARTPTS[a4];
  [0:v]trim=15.2467:16.5819,setpts=PTS-STARTPTS[v5];
  [0:a]atrim=15.2467:16.5819,asetpts=PTS-STARTPTS[a5];
  [0:v]trim=17.1012:20.1223,setpts=PTS-STARTPTS[v6];
  [0:a]atrim=17.1012:20.1223,asetpts=PTS-STARTPTS[a6];
  [0:v]trim=20.9504:22.5714,setpts=PTS-STARTPTS[v7];
  [0:a]atrim=20.9504:22.5714,asetpts=PTS-STARTPTS[a7];
  [0:v]trim=23.4482:24.8745,setpts=PTS-STARTPTS[v8];
  [0:a]atrim=23.4482:24.8745,asetpts=PTS-STARTPTS[a8];
  [0:v]trim=25.5697:26.8718,setpts=PTS-STARTPTS[v9];
  [0:a]atrim=25.5697:26.8718,asetpts=PTS-STARTPTS[a9];
  [0:v]trim=27.5758:27.9942,setpts=PTS-STARTPTS[v10];
  [0:a]atrim=27.5758:27.9942,asetpts=PTS-STARTPTS[a10];
  [0:v]trim=28.5431:30,setpts=PTS-STARTPTS[v11];
  [0:a]atrim=28.5431:30,asetpts=PTS-STARTPTS[a11];
  [v0][a0][v1][a1][v2][a2][v3][a3][v4][a4][v5][a5][v6][a6][v7][a7][v8][a8][v9][a9][v10][a10][v11][a11]
  concat=n=12:v=1:a=1[outv][outa]
  
  ```
  
  The command that I am using to run ffmpeg with this script file is as below
  
  ```
  ffmpeg -i "input.mp4" -c:v libx265 -filter_complex_script "script.txt" -map [outv] -map [outa] "output.mp4"
  
  ```
  
  But after running this command, the output video file is only ~5 seconds long (the very first portion of the input video).
  
  As we can see from the first line of the "script.txt", the start timestamp is ~0.8 and the end timestamp is ~5.8 giving a duration of ~5s for the first piece of the output video.
  
  So, ffmpeg is not joining any other parts of the input video after the first part. I am unable to understand why so.
  
  I am facing this problem since the past couple of months after I updated ffmpeg. The same syntax of script file and command line used to work fine before that. Did any changes in the update alter the syntax that ffmpeg expects for this task?
  
  Any help is much appreciated.
  
  **Tags:** ffmpeg
  
  > **Comments:**
  > **username_1**: Hey, I tried to edit your answer on a tablet to improve code formatting. I don't know why but it messed  up the whole line. I can't see history and now I am not sure what your output was. Was it `"output.txt`? Probably not.  
  > **username_1**: Everything seems to work on my end. Just copied the command line assuming output is `output.mp4` and have a 22 sec. long video. The question is how did you install FFMpeg. Are you using any non-standard version? This could be important because I used to have a similar issue. There are two version for Windows [gyan.dev](https://www.gyan.dev/ffmpeg/builds/) and [BtbN](https://github.com/BtbN/FFmpeg-Builds/releases). My script for splitting a video only worked using the second version BtbN. BTW your script works on BtbN.  
  > **username_0**: The output was output.mp4.  This is the result of running ffmpeg -version on my current installed ffmpeg.  ffmpeg version N-113032-g76cd71bf0c-20231219 Copyright (c) 2000-2023 the FFmpeg developers built with gcc 13.2.0 (crosstool-NG 1.25.0.232_c175b21)  I tried the above script file & command line with this version of ffmpeg & got the output video that's only ~5s long.  Then I tried the same script & command line on the ffmpeg build from the BtbN link you suggested & got ~22s long output video. So now the problem has been identified & I can solve it now. Thanks  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2024-02-11. Score: 0
  
  Thanks to [username_1](https://video.stackexchange.com/users/4273/username_1) for identifying the problem.
  
  The build of ffmpeg I had installed on my system was the culprit. Here's the output of running `ffmpeg -version` in the command line
  
  ```
  ffmpeg version N-113032-g76cd71bf0c-20231219 Copyright (c) 2000-2023 the FFmpeg developers built with gcc 13.2.0 (crosstool-NG 1.25.0.232_c175b21)
  
  ```
  
  The problem was solved after I installed the build of ffmpeg from [BtbN](https://github.com/BtbN/FFmpeg-Builds/releases)
  
  
  ---
  
  