Search code examples
c#c++performanceffmpegbmp

How to increase image export/extract speed when using ffmpeg?


I'm extracting all frames from mp4 video (video fps: 25) with fps -r 25 param, using ffmpeg.

Here is command that I used: ffmpeg -i input.mp4 -r 25 frame_%%02d.bmp. It works.

In start of extracting proccess ffmpeg have speed=~4x and after 200-300 frame speed slow down to ~0.3x. But CPU using is only 3% max, memory also ok. Output Metadata:

    Encoder         : Lavf58.12.100
    Stream #0:0(und): Video: bmp, bgr24, 1920x1080, q=2-31, 200 kb/s, 25 fps, 25
 tbn, 25 tbc (default)

Question: How can extract faster?

I've tried with this parameters, but speed not changed:

  • -threads 4 threads count has changed but speed not,
  • -preset with veryfast and ultrafast also nothing.

Solution

  • To recap the answers in the comments: you are limited by disk speed. BMP images are uncompressed, meaning that a single 1920x1080 frame export will be about 6MB in size. At 25fps that will be a 150MB/s data stream. At the 4x speed you are expecting this would be 600MB/s. Only the fastest SSD's would be able to keep up with this, and then even just in theory.

    If image quality is an important factor i'd recommend exporting to PNG files instead. This provides good image quality while still producing significantly smaller files. Otherwise just use JPG, depending on the compression setting used they also produce good image quality at even smaller file sizes.