thumbnailin

I have always used tumbler as my thumbnail handler. tumbler is very configurable, but the configuration is maze-like. Removing the movie-strip from video thumbnails is something that involves most of the stuff one needs to know about tumbler, so that will be used as an example in this article.

~/img/video-thumbnails.jpg (635x833 175kB)
image with three windows, one without thumbnails,
one with strip(internal), one without strip
(external).
top: no thumbnails
middle: internal FfmpegThumbnailer
bottom: external/desktop ffmpegthumbnailer without strip

If ffmpegthumbnailer is installed, tumbler will use it to generate thumbnails for video files.

Executing ffmpegthumbnailer in a terminal with -h flag, shows us the following output:

$ ffmpegthumbnailer -h
Usage: ffmpegthumbnailer [options]

Options:
  -i<s>   : input file
  -o<s>   : output file
  -s<n>   : thumbnail size (use 0 for original size) (default: 128)
  -t<n|s> : time to seek to (percentage or absolute time hh:mm:ss) (default: 10%)
  -q<n>   : image quality (0 = bad, 10 = best) (default: 8)
  -c      : override image format (jpeg, png or rgb) (default: determined by filename)
  -a      : ignore aspect ratio and generate square thumbnail
  -f      : create a movie strip overlay
  -m      : prefer embedded image metadata over video content
  -w      : workaround issues in old versions of ffmpeg
  -v      : print version number
  -h      : display this help

Notice the -f : create a movie strip overlay. When I installed the ffmpegthumbnailer package, it came with the desktop thumbnailer: /usr/share/thumbnailers/ffmpegthumbnailer.desktop , which looks like this:

[Thumbnailer Entry]
TryExec=ffmpegthumbnailer
Exec=ffmpegthumbnailer -i %i -o %o -s %s -f
MimeType=... long list of video mime types

The Exec command, has the -f option, so one would think that to remove the movie-strip from the thumbnails would be as easy as just removing that trailing -f, but it will not work..

The desktop thumbnailer will never execute with the default tumbler configuration. It conflicts with the internal tumbler FfmpegThumbnailer. The default tumbler settings in /etc/xdg/tumbler/tumbler.rc related to this are:

# ffmpegthumbnailer plugin
[FfmpegThumbnailer]
Disabled=false
Priority=2
Locations=
Excludes=
MaxFileSize=0

# All the properties below can be overridden per desktop file, in the "X-Tumbler Settings" group,
# for example:
# [X-Tumbler Settings]
# Priority=4
[DesktopThumbnailer]
Disabled=false
Priority=0
Locations=
Excludes=
MaxFileSize=0
The internal tumbler FfmpegThumbnailer is actually a complex little C program that does the exact same thing as the desktop thumbnailer, the internal thumbnailer is hardcoded to always render the movie strip..

Looking at the tumbler.rc we can draw the following conclusions:

So to have our desktop thumbnailer execute, we could either disable the internal FfmpegThumbnailer, or change the priorities. There is a comment in tumbler.rc, that tells us that we can override tumbler settings in the desktop thumbnailer, by adding the section [X-Tumbler Settings].

edit the configuration

It is recommended that you don’t edit the default configuration files, instead copy/create the files to you home directory.

First make sure that your XDG environment variables are setup correctly:

$ export | grep XDG
declare -x XDG_CACHE_HOME=~/.cache
declare -x XDG_CONFIG_HOME=~/.config
declare -x XDG_DATA_HOME=~/.local/share

Next, create the following two directories:

$ mkdir -p "$XDG_DATA_HOME/thumbnailers"
$ mkdir -p "$XDG_CONFIG_HOME/tumbler"

Copy the configuration files:

$ cp /usr/share/thumbnailers/ffmpegthumbnailer.thumbnailer "$XDG_DATA_HOME/thumbnailers/ffmpegthumbnailer.thumbnailer"
$ cp /etc/xdg/tumbler/tumbler.rc "$XDG_CONFIG_HOME/tumbler/tumbler.rc"

Now, we can edit ~/.local/share/thumbnailers/ffmpegthumbnailer.thumbnailer
Remove the -f flag from the Exec command and raise the tumbler priority:

[Thumbnailer Entry]
TryExec=ffmpegthumbnailer
Exec=ffmpegthumbnailer -i %i -o %o -s %s
MimeType=video/jpeg;video/mp4;video/mpeg;video/quicktime;video/x-ms-asf;video/x-ms-wm;video/x-ms-wmv;video/x-ms-asx;video/x-ms-wmx;video/x-ms-wvx;video/x-msvideo;video/x-flv;video/x-matroska;application/mxf;video/3gp;video/3gpp;video/dv;video/divx;video/fli;video/flv;video/mp2t;video/mp4v-es;video/msvideo;video/ogg;video/vivo;video/vnd.divx;video/vnd.mpegurl;video/vnd.rn-realvideo;application/vnd.rn-realmedia;video/vnd.vivo;video/webm;video/x-anim;video/x-avi;video/x-flc;video/x-fli;video/x-flic;video/x-m4v;video/x-mpeg;video/x-mpeg2;video/x-nsv;video/x-ogm+ogg;video/x-theora+ogg

[X-Tumbler Settings]
Priority=777

restart tumbler

I have tumbler running from a systemd service, so restarting tumbler itself, is just systemctl --user restart tumblerd.service (notice --user). This is, however, not enough to see the changes to the configuration. tumbler operates like a “middleman” between applications that wants to show a thumbnail and the programs that generates thumbnails. tumbler also caches generated thumbnails.

If a thumbnail has been generated and cached, when we change the tumbler configuration, a new thumbnail will not get created because a cached version for the same path already exist. So we also need to remove the cached version. By default the thumbnail cache is located at: $XDG_CACHE_HOME/thumbnails (~/.cache/thumbnails). A brutal way to clean the thumbnail cache is:

$ rm -r "$XDG_CACHE_HOME/thumbnails"
This will obviously remove all cached thumbnails. A more graceful method is possible but would need an in-depth look at the structure of the thumbnail cache, which is out of scope for this article, we can revisit this in a future post..

Sometimes this is not enough either, depending on what filemanager you are using and how it is running, you might need to restart that as well. If you use thunar, this will restart it: thunar --quit ; thunar

I would advise setting up a test directory with some files you would like to test thumbnailing for. Something like this:

~/thumb-test/
  some-directory/
    folder.jpg
  some-video-file.mkv
  some-audio-file.mp3
  some-image.jpg
  some-image2.webp
  some-pdf.pdf
  some-ebook.epub

And make a simple script to restart tumbler, and filemanager:

#!/bin/bash
thunar --quit
systemctl --user stop tumblerd.service
rm -r "$XDG_CACHE_HOME/thumbnails"
systemctl --user start tumblerd.service
exec thunar ~/thumb-test

If this method doesn’t work, try logging in and out (which is the recommended way in the tumbler documentation)..