I have a need to generate a thumbnail for videos for a web application and I am currently doing that with this command:

ffmpeg -ss <seconds> -i <input file> -vframes 1 -y <output file>

Pretty basic, and does the job. But, of course, sometimes the frames aren't very "interesting".

For example, sometimes the video has faded to black as the scene changes, or it could be something which is somewhat boring like credits rolling or similar.

I need some sort of algorithmic way to extract something interesting from the video and essentially filter out the boring bits.

Is there anything in FFmpeg that might be able to make this easier?

If not, then I will need to collect a number of frames and process them outside of FFmpeg; likely using PHP. As a side note, if anyone has any existing code that does this, it would be super helpful!

Many thanks

1 Answer 1


No ffmpeg code can identify interesting frames. At most, there are filters which detect representative frames and filters which identify frames with a scene change. So, at best, there's a thumbnail filter for this, sort of. It can't detect "interesting" frames but it detects representative frames. So, frames from the middle of fades should be out.

Syntax is

ffmpeg -ss 50 -i in.avi -vf thumbnail=300 -vsync 0 thumbs%d.png

This will pick one representative frame from each batch of 300 consecutive frames.

  • This seems to be the answer, thank you. I think the usage is syntax is somewhat different, however. Running the above command results in a single file over 1GB (it must contain a frame every 300 frames), rather than producing a separate image for each frame. Additionally, as we only require one frame I think we can add -frames:v 1 so that it will take the first suitable frame it finds. This seems ok to me. This seems to ignore the -ss parameter as far as I can tell, though. Would be ideal to start finding thumbnails after X seconds, but maybe it won't be needed. Thanks again! Nov 3, 2016 at 12:47
  • Check your ffmpeg version. Both ss before -i works and output is a set of image files (PNG is a still image format, anyway). There's one change needed to avoid a quirk of ffmpeg which will duplicate frames. I've added that to the command.
    – Gyan
    Nov 3, 2016 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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