Bug#448072: Video thumbnailing should not rely on a particular media player

Jean-Michel Philippe jean-michel.philippe at libertysurf.fr
Thu Oct 25 19:39:11 UTC 2007


Package: nautilus
Version: 2.14.3-11+b1
Severity: wishlist
Tags: patch

In nautilus video thumbnails are only displayed if the user has totem
installed. If for any reason this not the case (maybe he prefers another
media player?), he may have not installed or uninstalled totem.
Therefore video thumbnailing in nautilus should rather rely on a small
library, eg. ffmpeg. This is what I did on my system. I wrote a small
Python script in replacement of “totem-video-thumbnailer” and declared
it as a new “gnome-video-thumbnailer” alternative.

======= code of “ffmpeg-video-thumbnailer” =========

#!/usr/bin/env python
#
# Ffmpeg video thumbnailer
#  generates a thumbnail from a video file
#
# requires ffmpeg, imagemagick and filmholes.png from totem
#
# Use:
#	ffmpeg-video-thumbnailer [-s geometry] input output
#
# geometry	= thumbnail geometry, eg. "128" or "128x96"
# input		= video file name
# output	= thumbnail file name
#
# Author: JM. Philippe - http://philipjm.free.fr/blog/
# Public domain

import sys, os, re, commands, urllib

# the ffmpeg command to be executed (extracts 1st video image)
FfmpegCmd = "ffmpeg -i '%s' -vcodec png -vframes 1 -s %s -f rawvideo -y
'%s'"

# the imagemagick command (composes images)
MagickCmd = "composite -compose atop -geometry %s %s %s %s"

# film holes to be overlaid (from totem install)
FilmHoles = '/usr/share/totem/filmholes.png'
HoleHeight = 35		# film holes image dimensions
#HoleWidth = 9

##################
##################
def dims(FileName):
	"""
	gets video dimensions
	"""
	Result = commands.getoutput("ffmpeg -i '%s'" % FileName)
	Orient = re.findall(r'(\d+)x(\d+)', Result)
	if len(Orient):
		return map(int, Orient[0])
	else:
		return 0, 0

##################
##################
def film_holes(FileName, Height):
	"""
	adds film holes on the left side
	"""
	Start = 0
	while Start < Height:	# repeat pattern vertically
		Position = '+%d+%d' % (0, Start)
		commands.getoutput(MagickCmd % (Position, FilmHoles, FileName, FileName))
		Start += HoleHeight

##################
# get parameters
if sys.argv[1] == "-s":
	ThumbSize, Input, Output = sys.argv[2:5]
else:
	ThumbSize = "128"
	Input, Output = sys.argv[1:3]

##################
# URL's to pathnames
Input = urllib.url2pathname(Input.replace('file://', ''))
Output = urllib.url2pathname(Output.replace('file://', ''))

##################
# thumbnail size
if 'x' not in ThumbSize:
	ImgWidth, ImgHeight = dims(Input)
	ThumbWidth = int(ThumbSize)
	if ImgWidth >= ImgHeight:
		ThumbHeight = ThumbWidth * ImgHeight / ImgWidth
	else:
		ThumbHeight = ThumbWidth
		ThumbWidth = ThumbHeight * ImgWidth / ImgHeight
	ThumbSize = '%dx%d' % (ThumbWidth, ThumbHeight)

##################
# make thumbnail
Result = commands.getoutput(FfmpegCmd % (Input, ThumbSize, Output))
film_holes(Output, ThumbHeight)
commands.getoutput("mogrify -flop " + Output)	# flip left to right
film_holes(Output, ThumbHeight)
commands.getoutput("mogrify -flop " + Output)

=========== end of script ============

Caveats:
* doesn't understand gnome URI's (video files are assumed to be local)
* uses the film hole image of totem, “/usr/share/totem/filmholes.png”
* uses ImageMagick to overlay the film hole image over the thumbnail
  (should use a much smaller library)

So I don't think my script is sufficient but I made it to check that
there was another way to do this.

Regards,

JM. Philippe

-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-5-k7
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)

Versions of packages nautilus depends on:
ii  desktop-file-utils     0.11-1            Utilities for .desktop files
ii  gnome-control-center   1:2.14.2-7        utilities to configure the GNOME d
ii  libart-2.0-2           2.3.17-1          Library of functions for 2D graphi
ii  libatk1.0-0            1.12.4-3          The ATK accessibility toolkit
ii  libbonobo2-0           2.14.0-3          Bonobo CORBA interfaces library
ii  libc6                  2.3.6.ds1-13etch2 GNU C Library: Shared libraries
ii  libeel2-2.14           2.14.3-5          Eazel Extensions Library (for GNOM
ii  libesd-alsa0 [libesd0] 0.2.36-3          Enlightened Sound Daemon (ALSA) - 
ii  libexif12              0.6.13-5etch1     library to parse EXIF files
ii  libgail-common         1.8.11-4          GNOME Accessibility Implementation
ii  libgail17              1.8.11-4          GNOME Accessibility Implementation
ii  libgconf2-4            2.16.1-1          GNOME configuration database syste
ii  libglade2-0            1:2.6.0-4         library to load .glade files at ru
ii  libglib2.0-0           2.12.4-2          The GLib library of C routines
ii  libgnome-desktop-2     2.14.3-2          Utility library for loading .deskt
ii  libgnome2-0            2.16.0-2          The GNOME 2 library - runtime file
ii  libgnomecanvas2-0      2.14.0-2          A powerful object-oriented display
ii  libgnomeui-0           2.14.1-2          The GNOME 2 libraries (User Interf
ii  libgnomevfs2-0         1:2.14.2-7        GNOME virtual file-system (runtime
ii  libgtk2.0-0            2.8.20-7          The GTK+ graphical user interface 
ii  libnautilus-extension1 2.14.3-11+b1      libraries for nautilus components 
ii  liborbit2              1:2.14.3-0.2      libraries for ORBit2 - a CORBA ORB
ii  libpango1.0-0          1.14.8-5          Layout and rendering of internatio
ii  libpopt0               1.10-3            lib for parsing cmdline parameters
ii  librsvg2-2             2.14.4-3          SAX-based renderer library for SVG
ii  libstartup-notificatio 0.8-2             library for program launch feedbac
ii  libx11-6               2:1.0.3-7         X11 client-side library
ii  libxml2                2.6.27.dfsg-1     GNOME XML library
ii  nautilus-data          2.14.3-11         data files for nautilus
ii  shared-mime-info       0.19-2            FreeDesktop.org shared MIME databa

Versions of packages nautilus recommends:
ii  desktop-base                 4.0.1etch2  common files for the Debian Deskto
ii  eject                        2.1.4-3     ejects CDs and operates CD-Changer
pn  fam                          <none>      (no description available)
ii  libgnomevfs2-extra           1:2.14.2-7  GNOME virtual file-system (extra m
ii  librsvg2-common              2.14.4-3    SAX-based renderer library for SVG
ii  nautilus-cd-burner           2.14.3-8+b1 CD Burning front-end for Nautilus

-- no debconf information






More information about the pkg-gnome-maintainers mailing list