8

I am wondering how to use ffmpeg to create video thumbnails something like this (taken from a VLC forum):

7x3 grid of video stills

I know totem can do this but totem does not support the video format that I am using

This article says that ffmpeg can do it.

Zanna
  • 72,471
Levan
  • 11,138
  • search for FFMpegThumbs which is in the standard Ubuntu repository – thom Nov 15 '13 at 18:03
  • Thank you for the reply but I do not think it does the thing I want it to do I want to output an image from a video. and the description of that software does not say that it does that – Levan Nov 15 '13 at 18:07
  • Aha...so you don't want thumbnails (like you asked) but complete stills ? – thom Nov 15 '13 at 18:39
  • You see the image I took from vlc forums that is what I want to tern video into an image like that. – Levan Nov 15 '13 at 18:43

1 Answers1

8

Create a mosaic of screenshots from a movie with ffmpeg

create a mosaic of screenshots

If you're using anything older than Ubuntu 15.04, then the so-called "ffmpeg" package from the repository refers to a fake version from the Libav fork which does not have the functionality you need, so you will have to download a static build of ffmpeg or follow a step-by-step guide to compile ffmpeg.

Example command using select, scale, and tile filters:

./ffmpeg -i input -vf "select=gt(scene\,0.4),scale=160:-1,tile" -frames:v 1 \
-qscale:v 3 preview.jpg

In this example the output will be 960x450. You can add an additional scale filter if you want to change that, or you can change the size of each tile. Example for 600 pixel wide output:

./ffmpeg -i input -vf "select=gt(scene\,0.4),scale=160:-1,tile,scale=600:-1" \
-frames:v 1 -qscale:v 3 preview.jpg

You can even add text to the output. This example will add 24 pixels of black padding to the top of the image and add the text "Iron Man" in the center of the padding.

./ffmpeg -i input -vf "select=gt(scene\,0.4), \
  scale=160:-1, \
  tile, \
  scale=600:-1, \
  pad=iw:ih+24, \
  drawtext=fontsize=30:box=1:fontfile=/usr/share/fonts/TTF/Vera.ttf:text='Iron Man':x=(w-text_w)/2:0"
  -frames:v 1 -qscale:v 3 preview.jpg

Other stuff

  • You can control output quality with -qscale:v. Effective range is a linear scale of 2-31; where 2 is best quality.

  • See the select filter documentation for more info.

llogan
  • 12,378
  • Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used) – evandrix May 27 '19 at 17:17
  • @evandrix Worked for me. You can use a pastebin site to show your command and the complete log and provide a link here. – llogan May 28 '19 at 23:19
  • The problem with this approach is that it's very slow. Better is to run ffmpeg few times to seek and convert a frame into an image, and then tile those images. – Ondra Žižka Apr 12 '20 at 15:53
  • @OndraŽižka how can I do something like that can you provide an example? –  May 11 '20 at 06:43