9

I was trying to cut a 5 second longer sengment from a video test.wmv (10 minutes length) starting from 00:03:00 position. So I used the following ffmpeg command.

ffmpeg -ss 00:03:00 -t 00:00:05 -i test.wmv -acodec libmp3lame -vcodec copy 1.wmv

But it gives me a output wmv that is 11 seconds longer which is twice the duration specified.

What am I doing wrong? Any idea?

Thanks

1
  • 1
    The video has to start at a I-frame. That means it might have to start a lot earlier than 03:00. – Daniel B Oct 3 '16 at 19:32
9

It often happens when using the -ss and -t together with -c copy or -codec copy.

Don't use copy, and use another codecs or simply don't specify -c , -codec options. and this won't happen.

for example: ffmpeg -ss 00:03:00 -t 00:00:05 -i test.wmv -acodec libmp3lame -vcodec libx264 1.mp4

7
  • The video won’t be cut be reencoded, though. – Daniel B Oct 3 '16 at 19:31
  • @DanielB It's not. I mean changing -vcodec copy only. but keeping -ss and -t options. – Behroozfar Oct 3 '16 at 20:18
  • 3
    Yeah. That implies (part of) the original video stream isn't used as is. Instead, it is decoded and then encoded again, leading to quality loss. Even worse, without specifying additional parameter for the encoder, it might look a lot worse. – Daniel B Oct 3 '16 at 21:08
  • 1
    @DanielB he wants accurate seeking and for accurate seeking, we have to decode video stream. yeah decode and encoding process cuases quality loss but that's not too much observable for one cycle. i mean this solution is maybe ok for practical goals. – Behroozfar Oct 3 '16 at 21:50
  • This answer is a workaround for the problem. It has been reported as a bug in ffmpeg, but there won't be a fix for a long time. trac.ffmpeg.org/ticket/4905 – Robin Loxley Jan 24 '18 at 3:35
4

Place the start and end parameters after the input. That should make it more accurate.

ffmpeg -i test.wmv -ss 00:03:00 -to 00:03:05 -c copy 1.wmv

The -t option means go upto this duration. I used -to. So in your case it should be

-to 00:03:05

Also, I did not change the audio codec from the original. That should work.

4
  • Thanks. The option -to didn't work in my case but I tried with -t and the result was better but not accurate. I got 6.4 seconds long segment this time. Also when I place -ss parameter after input it takes long time to complete – Enn Fenn Dec 8 '13 at 17:34
  • @EnnFenn It shouldn't be that inaccurate. Are you using a somewhat recent version of ffmpeg? (See ffmpeg.org/download.html) Can you give us the full, uncut ffmpeg command line output, please? Note that if -ss is specified before -i, the -t and -to options are equivalent. – slhck Dec 8 '13 at 17:37
  • 1
    This answer does not solve the problem. It has been a reported bug. trac.ffmpeg.org/ticket/4905 – Robin Loxley Jan 24 '18 at 3:35
  • @RobinLoxley see comment for the other answer. The ticket seems to be specifically for flac files. – Rajib Jan 28 '18 at 2:48

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.