Multiple / Sequential Video Thumbnails

Share your own howto's etc. Not for support questions!

Multiple / Sequential Video Thumbnails

Postby julian67 » 2009-05-22 17:08

These things:

Image

image full size

Note to users, mods and admins: this is from my own rip of my own purchased copy of Salaam Bombay! No copyright infringement here, only fair use.

These contact sheet style video thumbnails are easily done in Windows using Media Player Classic (typically) but free operating systems have never had a great tool to make this quick and easy. There are some nice things like ffmpegthumbnailer and imagemagick but it would be truly laborious to use those to make a single sheet of multiple images. I've been looking for quite a while for a reasonable way to accomplish this and I stumbled across it today:

dhyana

It's a perl script which uses mplayer, imagemagick, ffmpeg and various perl modules. Get the latest version from http://tobyinkster.co.uk/tag/dhyana/

Because it's a script it doesn't depend on any desktop environment, you can just as easily use it in Gnome, KDE, Xfce, Fluxbox etc or with no graphical environment at all (install mplayer-nogui instead of mplayer).

Download the latest version of the script from the author.

Adapting it for Debian

First make sure you have the main dependencies already installed, that is mplayer, Perl, ImageMagick and ffmpeg.

dhyana needs an mplayer script, midentify, which is not found in the Debian packages. So download the mplayer source from http://www.mplayerhq.hu. Unpack the source and midentify.sh is found in the directory mplayer-<version>/TOOLS/
It needs to be in /usr/bin/ to work (I tried it in /usr/local/bin/ and it failed) so copy it and make it executable:

Code: Select all
# cp mplayer-<version>/TOOLS/midentify.sh /usr/bin/midentify & chmod +x /usr/bin/midentify


Perl modules: install from the Debian repos libgetopt-argvfile-perl and libfile-chdir-perl

Fonts: dhyana's author is not using Debian and the path to fonts described in his script are a little different from on a Debian system. Open dhyana.pl in a text editor and find the lines describing the font paths. In the current version that's lines 45 & 49. On each line change '/usr/share/fonts/TTF/' to '/usr/share/fonts/truetype/ttf-bitstream-vera/' (or choose another font if you prefer). Save the changes.

Now you need only put the script in your path and make it executable. My preference is to keep an original archived in ~/scripts/ and to move an edited version, as root, into /usr/local/bin/ and use chmod +x to make it executable.

You can now produce a thumbnail sheet as easily as

Code: Select all
$ dhyana.pl your_video_file


and the result will be saved in the same directory as the video file.

There are various options available, as described by the author:

Usage

dhyana.pl MovieFile.avi 8 4 ‘240×180+10+10’

The first parameter is required and is the file name for the movie file. dhyana.pl has been tested with videos in AVI, WMV and MPEG formats. MPEG videos come out looking like crap, but AVI and WMV look much better.

The second and third parameters are the numbers of rows and columns in the output file. These parameters are optional and default to 6 rows and 4 columns = 24 thumbnails.

The fourth parameter is a geometry setting to be passed to ImageMagick. This is also optional. It takes the form of WxH+L+T where:

* W is the thumbnail width
* H is the thumbnail height
* L is the left and right padding
* T is the top and bottom padding

Thumbnails will be resized keeping their aspect ratio, so images don’t look squished. Normally with ImageMagick you can precede the width with an exclamation mark to force the image to be resized to exactly the sepcified dimensions. I’ve not tried this with dhyana.pl, but it should work. The default geometry is ‘240×180+10+10’.


For example to make the image above I used
Code: Select all
$ dhyana.pl Video/Salaam_Bombay.mkv 10 4
Wisdom from my inbox: "do not mock at your pottenocy"
User avatar
julian67
 
Posts: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

Re: Multiple / Sequential Video Thumbnails

Postby garrincha » 2009-05-23 11:44

julian67 wrote:I've been looking for quite a while for a reasonable way to accomplish this and I stumbled across it today:

dhyana

It's a perl script which uses mplayer, imagemagick, ffmpeg and various perl modules. Get the latest version from http://tobyinkster.co.uk/tag/dhyana/


The links does not work.
Maurice Green on Usain Bolt's 9.58: "The Earth stopped for a second, and he went to Mars."
User avatar
garrincha
 
Posts: 2340
Joined: 2006-06-02 16:38

Re: Multiple / Sequential Video Thumbnails

Postby julian67 » 2009-05-23 13:44

garrincha wrote:
julian67 wrote:I've been looking for quite a while for a reasonable way to accomplish this and I stumbled across it today:

dhyana

It's a perl script which uses mplayer, imagemagick, ffmpeg and various perl modules. Get the latest version from http://tobyinkster.co.uk/tag/dhyana/


The links does not work.


You're right. I checked them before I posted them, in fact I had the pages open while I posted, but today....nothing. I guess it's his personal blog and no guarantee of permanency or uptime. I'll keep checking and update as appropriate, meanwhile I'm attaching the gzipped perl script to this post. Once it's set up you can run
Code: Select all
$ dhyana.pl --help
for short help or
Code: Select all
$ dhyana.pl --man
for full documentation.
Attachments
dhyana.pl.gz
(5.55 KiB) Downloaded 302 times
Wisdom from my inbox: "do not mock at your pottenocy"
User avatar
julian67
 
Posts: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

Re: Multiple / Sequential Video Thumbnails

Postby julian67 » 2009-05-24 16:40

Links are good again.
Wisdom from my inbox: "do not mock at your pottenocy"
User avatar
julian67
 
Posts: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

Re: Multiple / Sequential Video Thumbnails

Postby garrincha » 2009-05-25 15:31

julian67 wrote:Links are good again.

Thanks, I tried it on a small *.avi video and it worked very well, but when I tried on one of my *.mpg movie files (~ 1.5GB) that I recorded via DVB-T card it seems to take forever and I had to kill the process without it ever completing.

Did you managed to get it working for an *.mpg movie file?
Maurice Green on Usain Bolt's 9.58: "The Earth stopped for a second, and he went to Mars."
User avatar
garrincha
 
Posts: 2340
Joined: 2006-06-02 16:38

Re: Multiple / Sequential Video Thumbnails

Postby julian67 » 2009-05-25 16:12

The author mentions it's not good with mpg and now I've tried it I found the same thing. I thought it might be just a container issue so then extracted an mp4 video using matroska tools and tried again. The jpeg gets made quickly but it's lousy, so it looks like the it struggles with the H.264 codec itself, and the container :cry: Same with a movie decoded with libmpeg2 in mpg container. I find ffmpeg and mplayer also struggle playing some H264 movies so that seems to be part of the issue. It looks like the codecs which aren't perfectly supported work the worst....H264 (some implementaions), MPEG (libmepg2). But others I thought might be trouble were fine, such as MPEG-4 (mp4v) in .mov container.

I guess the script is good but mplayer and ffmpeg decoders don't do the exact same thing as the proprietary originals (if you watch HD you'll have experienced this for sure). I have some movies which they can't play but which work with the proprietary codecs, and others which play but cause the decoder to try to work the cpu to death.

edit: switched brain on and remembered I have a lot of mpg movies on my Rockbox'd iRiver H340. These have all been transcoded and scaled down for the player, using ffmpeg. The script works absolutely perfectly on those so I'm convinced it has to do with the differences between the proprietary and free codecs, not the container or the script itself.

another edit!: It's a bit slow on those ffmpeg mpg files bit it produces the goods.
Wisdom from my inbox: "do not mock at your pottenocy"
User avatar
julian67
 
Posts: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

Re: Multiple / Sequential Video Thumbnails

Postby garrincha » 2009-05-29 10:15

julian67 wrote:edit: switched brain on and remembered I have a lot of mpg movies on my Rockbox'd iRiver H340. These have all been transcoded and scaled down for the player, using ffmpeg. The script works absolutely perfectly on those so I'm convinced it has to do with the differences between the proprietary and free codecs, not the container or the script itself.

another edit!: It's a bit slow on those ffmpeg mpg files bit it produces the goods.


I had suspected that it was some issues with ffmpeg and maybe codec since it works o.k. with some format like *.avi. It was really slow, but I have no idea how long it's going to take so I didn't bother and killed the process.
Maurice Green on Usain Bolt's 9.58: "The Earth stopped for a second, and he went to Mars."
User avatar
garrincha
 
Posts: 2340
Joined: 2006-06-02 16:38

Re: Multiple / Sequential Video Thumbnails

Postby noonespecial » 2010-01-12 14:33

Hello

i did everything as descriped in that post and dhyana seems to work BUT... It only captures two frames.

Code: Select all
debug: Capturing frame 1, at 1 seconds.
debug: Capturing frame 2, at -1 seconds.
debug: Capturing frame 3, at -1 seconds.
debug: Capturing frame 4, at -1 seconds.
debug: Capturing frame 5, at -1 seconds.
debug: Capturing frame 6, at -1 seconds.
debug: Capturing frame 7, at -1 seconds.
debug: Capturing frame 8, at -1 seconds.
debug: Capturing frame 9, at -1 seconds.
debug: Capturing frame 10, at -1 seconds.
debug: Capturing frame 11, at -1 seconds.
debug: Capturing frame 12, at -1 seconds.
debug: Capturing frame 13, at -1 seconds.
debug: Capturing frame 14, at -1 seconds.
debug: Capturing frame 15, at -1 seconds.
debug: Capturing frame 16, at -1 seconds.
debug: Capturing frame 17, at -1 seconds.
debug: Capturing frame 18, at -1 seconds.
debug: Capturing frame 19, at -1 seconds.
debug: Capturing frame 20, at -1 seconds.
debug: Capturing frame 21, at -1 seconds.
debug: Capturing frame 22, at -1 seconds.
debug: Capturing frame 23, at -1 seconds.
debug: Capturing frame 24, at -1 seconds.
debug: Creating montage.
debug: Annotating montage.
convert: unable to get type metrics `-'.
convert: unable to open image `/tmp/dhyana-87684//annotation.png': Datei oder Verzeichnis nicht gefunden.
debug: Saving final file.
debug: Cleaning up temporary files.


In the output file i only have to caputres at the 1st second of the video. Does anyone have a sugestion what goes wrong?
noonespecial
 
Posts: 2
Joined: 2010-01-12 14:29

Re: Multiple / Sequential Video Thumbnails

Postby julian67 » 2010-01-12 14:43

It will help if you post information about the video file. You can use the mplayer script midentify (as mentioned in the first post) or an application like mediainfo.
Wisdom from my inbox: "do not mock at your pottenocy"
User avatar
julian67
 
Posts: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

Re: Multiple / Sequential Video Thumbnails

Postby noonespecial » 2010-01-12 14:46

I tryed with a .wmv file

Code: Select all
General
Complete name                    : cb-tlibigmmha0112.wmv
Format                           : Windows Media
File size                        : 2.98 GiB
Duration                         : 35mn 4s
Overall bit rate                 : 12.2 Mbps
Maximum Overall bit rate         : 12.1 Mbps
Encoded date                     : UTC 2010-01-08 23:19:10.000


and with a mkv file

Code: Select all
Format                           : Matroska
File size                        : 4.37 GiB
Duration                         : 1h 30mn
Overall bit rate                 : 6 941 Kbps
Encoded date                     : UTC 2010-01-12 13:16:01
Writing application              : mkvmerge v2.7.0 ('Do It Again') built on Apr 15 2009 00:27:10
Writing library                  : libebml v0.7.7 + libmatroska v0.8.1


Both already worked with ubuntu by the way.
noonespecial
 
Posts: 2
Joined: 2010-01-12 14:29

Re: Multiple / Sequential Video Thumbnails

Postby julian67 » 2010-01-12 15:12

Well that just shows the containers, nothing about the codecs used. Anyway, a possibility:

You're using regular Debian repository version of ffmpeg? If so then upgrade to the version from debian-multimedia which is built with many more codecs enabled (official Debian version is built without any undistributable/patent encumbered formats/codecs being enabled).

I just converted a quicktime .mov file to a .wmv file and have no trouble having dhyana make a thumbnail sheet of either version:

Code: Select all
$ mediainfo Master\ Plan.mov
General
Complete name                    : Master Plan.mov
Format                           : MPEG-4
Format profile                   : QuickTime
Codec ID                         : qt 
File size                        : 48.0 MiB
Duration                         : 3mn 15s
Overall bit rate                 : 2 066 Kbps
Encoded date                     : UTC 2007-01-31 15:52:52
Tagged date                      : UTC 2007-01-31 15:52:56
Writing library                  : Apple QuickTime

Video
ID                               : 2
Format                           : AVC
Format/Info                      : Advanced Video Codec
Format profile                   : Main@L3.1
Format settings, CABAC           : No
Format settings, ReFrames        : 2 frames
Codec ID                         : avc1
Codec ID/Info                    : Advanced Video Coding
Duration                         : 3mn 15s
Bit rate mode                    : Variable
Bit rate                         : 1 934 Kbps
Width                            : 1 280 pixels
Height                           : 576 pixels
Display aspect ratio             : 2.222
Frame rate mode                  : Constant
Frame rate                       : 25.000 fps
Resolution                       : 24 bits
Colorimetry                      : 4:2:0
Scan type                        : Progressive
Bits/(Pixel*Frame)               : 0.105
Stream size                      : 45.0 MiB (94%)
Encoded date                     : UTC 2007-01-31 15:52:34
Tagged date                      : UTC 2007-01-31 15:52:56

Audio
ID                               : 1
Format                           : AAC
Format/Info                      : Advanced Audio Codec
Format version                   : Version 4
Format profile                   : LC
Format settings, SBR             : No
Codec ID                         : 40
Duration                         : 3mn 15s
Bit rate mode                    : Constant
Bit rate                         : 128 Kbps
Channel(s)                       : 2 channels
Channel positions                : L R
Sampling rate                    : 44.1 KHz
Resolution                       : 16 bits
Stream size                      : 2.97 MiB (6%)
Encoded date                     : UTC 2007-01-31 15:52:34
Tagged date                      : UTC 2007-01-31 15:52:56


Code: Select all
$ mediainfo Master\ Plan.wmv
General
Complete name                    : Master Plan.wmv
Format                           : Windows Media
File size                        : 19.0 MiB
Duration                         : 3mn 15s
Overall bit rate                 : 819 Kbps
Maximum Overall bit rate         : 264 Kbps
Encoded date                     : UTC 1970-01-01 00:00:00.000

Video
ID                               : 1
Format                           : S-Mpeg 4 v3
Codec ID                         : MP43
Codec ID/Info                    : Microsoft MPEG-4 V3
Description of the codec         : msmpeg4
Duration                         : 3mn 15s
Bit rate                         : 714 Kbps
Width                            : 1 280 pixels
Height                           : 576 pixels
Display aspect ratio             : 2.222
Frame rate                       : 25.000 fps
Resolution                       : 24 bits
Bits/(Pixel*Frame)               : 0.039
Stream size                      : 16.6 MiB (87%)

Audio
ID                               : 2
Format                           : MPEG Audio
Codec ID                         : 55
Codec ID/Hint                    : MP3
Description of the codec         : libmp3lame
Duration                         : 3mn 15s
Bit rate                         : 64.0 Kbps
Channel(s)                       : 2 channels
Sampling rate                    : 44.1 KHz
Resolution                       :  bit0
Stream size                      : 1.49 MiB (8%)


wmv thumb:

Image

quicktime thumb:

Image

I have made many thumbnail sheets of movies in matroska mkv container, never had an issue.

I think you need to double check you have everything installed, especially mplayer.
Wisdom from my inbox: "do not mock at your pottenocy"
User avatar
julian67
 
Posts: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

Re: Multiple / Sequential Video Thumbnails

Postby stevepusser » 2010-02-06 08:52

Thanks for the tip.

Recent (within the last 6 months or so) versions of SMPlayer can do this too, you may want to give that program a try.
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: Chromium 78.0.3904.87, Hedgewars 1.0.0, PulseEffects 4.6.8, Telegram-desktop 1.8.15, Pale Moon 28.7.2, KeepassXC 2.5.0
User avatar
stevepusser
 
Posts: 11231
Joined: 2009-10-06 05:53

Re: Multiple / Sequential Video Thumbnails

Postby julian67 » 2010-02-06 12:56

Thanks for pointing this out. I've used smplayer's facility and it's very good. It can handle some containers/files that the script can't, such as .mp4 so it will definitely be useful, but it can only handle one movie at a time and it can't batch preview multiple video files. Of course it needs smplayer to be running as well. One advantage of the dhyana script is that it doesn't require X, and another is that it can be run as a file manager context menu item i.e. I can highlight a movie or a several movies in my file manager and have dhyana make previews of each in the background (doesn't even need to open a terminal), or in a terminal I can just run 'dhyana.pl --multi <file> <file> <file>' and so on.
Wisdom from my inbox: "do not mock at your pottenocy"
User avatar
julian67
 
Posts: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around


Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable