I need to extract a 30 second interval from the middle of a video, while converting it to webm. ffmpeg seemed like the perfect one liner:

ffmpeg -i long.mkv -vcodec libvpx -b:v 1M -ss 02:00:00 -t 00:00:30 -threads 4 out.webm

To my surprise it almost immediately swallowed all available memory and things started to get swapped so I killed it. After not finding any obvious error - and bare in mind I rarely use ffmpeg - I tried avconv. It didn't report doing anything and memory usage was (slowly) growing in the same direction.

After a few tests with:

 -ss 02:00:00 -t 00:00:01
 -ss 00:00:01 -t 00:00:01
 -ss 00:01:00 -t 00:00:01

It seems ffmpeg is loading the entire movie up to -ss in memory, or something like that. Anyhow it doesn't seem fit for this kind of operation. My question is, am I doing something wrong and ffmpeg can in fact perform this operation with reasonable resource usage? In case ffmpeg is not meant for this or is just being silly on how to do it, are there any alternatives that don't involve dragging and dropping rectangles into a timeline and using little scissors and scrollbars?

debian@pc:~/ ffmpeg -version
ffmpeg version 0.8.16-6:0.8.16-1, Copyright (c) 2000-2014 the Libav developers
  built on Sep 16 2014 23:10:48 with gcc 4.7.2
The ffmpeg program is only provided for script compatibility and will be removed
in a future release. It has been deprecated in the Libav project to allow for
incompatible command line syntax improvements in its replacement called avconv
(see Changelog for details). Please use avconv instead.
ffmpeg 0.8.16-6:0.8.16-1
libavutil    51. 22. 2 / 51. 22. 2
libavcodec   53. 35. 0 / 53. 35. 0
libavformat  53. 21. 1 / 53. 21. 1
libavdevice  53.  2. 0 / 53.  2. 0
libavfilter   2. 15. 0 /  2. 15. 0
libswscale    2.  1. 0 /  2.  1. 0
libpostproc  52.  0. 0 / 52.  0.100

I also tried with the latest version from ffmpeg's site and the results were the same as avconv's -- doesn't swallow my memory all at once, but doesn't seem to do anything:

frame=    0 fps=0.0 q=-1.0 size=       4kB time=00:00:00.00 bitrate=N/A    

And steadily increases memory usage. For a one second clip it seems to me it should be instantaneous and barely use any memory.

  • as far as I know, it has to read some of the 2 hours nothing, this time it does nothing. then 30 secs work and then end. Aug 15, 2015 at 6:43
  • It has to encode the movie and discard anything until reaching the position indicated by ss. I've never observed the memory usage doing things like this, but maybe you can memory-cap the process?
    – slhck
    Aug 16, 2015 at 10:53
  • 1
    @Alex could you use -ss as an input parameter instead ? Would avoid the delay of output seeking. IE: ffmpeg -ss 02:00:00 -i long.mkv -vcodec libvpx -b:v 1M -t 00:00:30 -threads 4 out.webm. Leaving as a comment rather than answer in case you need frame-accurate seeking; if it works for you I'll write it up as an answer :)
    – bertieb
    Aug 16, 2015 at 11:08

1 Answer 1


Using -ss after -i in ffmpeg takes ages!

This is because you are seeking to a point in the output, not the input. Per the ffmpeg manual on seeking:

Input seeking

The -ss parameter needs to be specified somewhere before -i:

...The input will be parsed using keyframes, which is very fast...

as compared with:

Output Seeking

The -ss parameter needs to be specified after -i:

...This will be done very slowly, frame by frame...

in your question you specify the latter. It will be much faster if you use input seeking instead:

ffmpeg -ss 02:00:00 -i long.mkv -vcodec libvpx -b:v 1M -t 00:00:30 -threads 4 out.webm

But if you absolutely do need frame-accurate seeking, you can combine both:

ffmpeg -ss 01:59:30 -i long.mkv -ss 30 -vcodec libvpx -b:v 1M -t 00:00:30 -threads 4 out.webm

(fast seek to 01:59:30, then seek frame-by-frame to 02:00:00, which is +30)

You may already be aware, but if not this should illuminate that ffmpeg is picky about the placement of options and switches!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .