Creating screenshots with FFmpeg is slow?

Just a quick note for everyone who’s using FFmpeg for creating screenshots from video files. Today I noticed that FFmpeg can be VERY slow on large/long movie files, but there’s a pretty neat trick to speed up the screenshot generation.

I used to create my screenshots this way:

ffmpeg -i /var/www/input.mov -y -f image2 -ss 1234  -sameq -t 0.001 “/var/www/screenshot.jpg” 2>&1

and on huge files it sometimes took minutes. The solution is simple:

ffmpeg -ss 1234 -i /var/www/input.mov -y -f image2  -sameq -t 0.001 “/var/www/screenshot.jpg” 2>&1

Put the -ss parameter in front of the input file and FFmpeg skips to the selected frame almost instantly.

hf! :)


5 Responses to “Creating screenshots with FFmpeg is slow?”

  • fuwaneko Says:

    Lol, this is really funny trick. Maybe you should write a bugreport?

  • alexs Says:

    ooh man, this was good to find out. ffmpeg was REALLLY slow before, with ss param as it was. such an improvement & so simple once u know. thanks for sharing

  • FiloSottile Says:

    Loving you. You saved me a LOT of CPU and time. You should file a bug, anyway.

  • Rafael Nicoletti Says:

    Its not a bug. The way ffmpeg work with parameter is:
    -all_parameters_before_opening_a_file (eg: -f, -t, -ss) -i filename

    The -ss after the -i parameters is use to seek the output file, not the input.

  • Steffen Says:

    @Rafael, thanks for pointing this out! :-)

Leave a Reply