<p>Idk know why you are having this issue, but a basic thing to try in your code line it's switch the position of time parameters to input, like this:</p>
<pre><code>ffmpeg -i input.ts -c copy -ss 1:40 -t 0:40 40s_ts.ts
</code></pre>
<p>For FFmpeg really matter the order, so try do in this order, other thing which you can do it's <a href="http://ffmpeg.org/ffmpeg-all.html#trim" rel="nofollow noreferrer">try trimming use the -vf filter</a></p>
<pre><code>ffmpeg -i input.ts -c copy -vf &quot;trim=50:150&quot; 50s_ts.ts
</code></pre>
<p>In this case the defaults are all the input is kept. So it is possible to set just the end values to keep everything before the specified time. So you are telling to ffmpeg &quot;give me the final 50 seconds from 150 seconds of the input&quot; if this don't work, maybe you'll need write in a verbose way: <code>-vf &quot;trim=start=100:duration=50&quot;</code></p>

CC BY-SA 4.0
2021-12-31T04:09:07.867Z
Also try putting `-i` flag last
qwr
CC BY-SA 4.0
2022-01-31T06:25:08.287Z
@qwr, `-i` introduced an input file, so it must not be the last.
MarianD
CC BY-SA 4.0
2022-01-31T06:32:16.657Z
`-vf "trim=50:150"` is the same as `-vf "trim=start=50:end=150"`, i.e., the result will be NOT 50-seconds, but **100-seconds** long output.
MarianD
CC BY-SA 4.0
2022-01-31T11:15:51.750Z
that's why i wrote -vf ' "trim=start=100,duration=50" ', but it's just another way to do the same thing... I wanna improve this type of techniqué, you had any clue @MarianD how to rewrite the same trim with -filter_complex? I'll appreciate that :)
Elber Valim
CC BY-SA 4.0
2022-01-31T13:27:54.347Z
`trim=start=100,duration=50` is *incorrect*, the correct form is `trim=start=100:duration=50` (`:` instead of `,`), and it is the same as `trim=100:150` (instead of yours `trim=50:150`). It would be nice from you to edit your answer and correct both of them. The `trim` is the only one filter in your answer, so there is no need to use `-filter_complex` (which is the same as `-lavfi`), but you may do it: `-filter_complex trim=100:150`  or `-lavfi trim=100:150`.
MarianD
CC BY-SA 4.0
2021-12-27T13:50:04.227Z
2022-05-14T18:57:06.657Z
2022-05-14T18:57:06.657Z
Elber Valim
<p>I want to cut a video using ffmpeg.</p>
<p>This is the command I used.</p>
<p><code>ffmpeg -ss 1:40 -t 0:40 -i &quot;1.ts&quot; -c copy 100sts.ts</code></p>
<p>Duration of the result file is 1m 43s.</p>
<p>I guessed there is no keyframe in that section, but I was wrong.</p>
<p>Below is the list of the command I typed, and duration of them respectively.</p>
<pre><code>ffmpeg -ss 1:40 -t 0:30 -i &quot;1.ts&quot; -c copy 100sts_2.ts
ffmpeg -ss 1:40 -t 0:10 -i &quot;1.ts&quot; -c copy 100sts_3.ts
ffmpeg -ss 1:40 -to 2:20 -i &quot;1.ts&quot; -c copy 100sts_4.ts
ffmpeg -ss 1:40 -to 1:50 -i &quot;1.ts&quot; -c copy 100sts_5.ts
ffmpeg -ss 1:40 -to 1:41 -i &quot;1.ts&quot; -c copy 100sts_6.ts
</code></pre>
<pre><code>1min 30s
1min 13s
1min 43s
1min 13s
1min 4s
</code></pre>
<p>I want to cut this video so that its duration would be around 30~40s.</p>
<p>But ffmpeg is cutting it 1 min more than specified time.
What have i done wrong?</p>

CC BY-SA 4.0
2022-01-31T06:22:49.910Z
Please include the output of the command `ffprobe -hide_banner 1.ts`.
MarianD
<ffmpeg>
Cutting a video by specific time
helming
# Cutting a video by specific time

(Asked by: username_0 on 2021-12-27)

I want to cut a video using ffmpeg.
This is the command I used.
ffmpeg -ss 1:40 -t 0:40 -i "1.ts" -c copy 100sts.ts
Duration of the result file is 1m 43s.
I guessed there is no keyframe in that section, but I was wrong.
Below is the list of the command I typed, and duration of them respectively.
ffmpeg -ss 1:40 -t 0:30 -i "1.ts" -c copy 100sts_2.ts
ffmpeg -ss 1:40 -t 0:10 -i "1.ts" -c copy 100sts_3.ts
ffmpeg -ss 1:40 -to 2:20 -i "1.ts" -c copy 100sts_4.ts
ffmpeg -ss 1:40 -to 1:50 -i "1.ts" -c copy 100sts_5.ts
ffmpeg -ss 1:40 -to 1:41 -i "1.ts" -c copy 100sts_6.ts

1min 30s
1min 13s
1min 43s
1min 13s
1min 4s

I want to cut this video so that its duration would be around 30~40s.
But ffmpeg is cutting it 1 min more than specified time.
What have i done wrong?

**Tags:** ffmpeg

> **Comments:**
> **username_1**: Please include the output of the command `ffprobe -hide_banner 1.ts`.  

---

## 1 answers

### Answer by username_2 on 2021-12-27. Score: 0

Idk know why you are having this issue, but a basic thing to try in your code line it's switch the position of time parameters to input, like this:
ffmpeg -i input.ts -c copy -ss 1:40 -t 0:40 40s_ts.ts

For FFmpeg really matter the order, so try do in this order, other thing which you can do it's try trimming use the -vf filter
ffmpeg -i input.ts -c copy -vf "trim=50:150" 50s_ts.ts

In this case the defaults are all the input is kept. So it is possible to set just the end values to keep everything before the specified time. So you are telling to ffmpeg "give me the final 50 seconds from 150 seconds of the input" if this don't work, maybe you'll need write in a verbose way: -vf "trim=start=100:duration=50"

> **Comments:**
> **username_3**: Also try putting `-i` flag last  
> **username_1**: @username_3, `-i` introduced an input file, so it must not be the last.  
> **username_1**: `-vf "trim=50:150"` is the same as `-vf "trim=start=50:end=150"`, i.e., the result will be NOT 50-seconds, but **100-seconds** long output.  
> **username_2**: that's why i wrote -vf ' "trim=start=100,duration=50" ', but it's just another way to do the same thing... I wanna improve this type of techniqué, you had any clue @username_1 how to rewrite the same trim with -filter_complex? I'll appreciate that :)  
> **username_1**: `trim=start=100,duration=50` is *incorrect*, the correct form is `trim=start=100:duration=50` (`:` instead of `,`), and it is the same as `trim=100:150` (instead of yours `trim=50:150`). It would be nice from you to edit your answer and correct both of them. The `trim` is the only one filter in your answer, so there is no need to use `-filter_complex` (which is the same as `-lavfi`), but you may do it: `-filter_complex trim=100:150`  or `-lavfi trim=100:150`.  

---

