0

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?

1
  • Please include the output of the command ffprobe -hide_banner 1.ts.
    – MarianD
    Jan 31 at 6:22

1 Answer 1

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"

5
  • 1
    Also try putting -i flag last
    – qwr
    Dec 31, 2021 at 4:09
  • @qwr, -i introduced an input file, so it must not be the last.
    – MarianD
    Jan 31 at 6:25
  • -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
    Jan 31 at 6:32
  • 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 :) Jan 31 at 11:15
  • 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
    Jan 31 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.