View Full Version : HOW-TO create video-preview thumbnails on a PC for XBMC
hoki_goujons
2006-09-22, 08:38
This is a way of getting a thumbnail for videos that show a screenshot from the vid. I find it useful for folders of TV shows, where I forget which ep I'm up to if I just leave it as the name foo-s01-e01.avi :)
You need ffmpeg on your PC, preferably in your path - put the exe in windows\system32 or add its location to your path.
Then open a command prompt, go to the folder containing your vids and do
for %i in (*.avi) do ffmpeg -i %i -f mjpeg -t 0.001 -ss 5 -y %~ni.tbn
That goes through all the avi files in the folder and creates a jpeg (actually with a .tbn extension for XBMC) of the frame 5 seconds in, with the same name as the avi. Then set that folder in XBMC to show in thumbs view and you're away!. Alter the number after '-ss' to change how far in you want the grab taken. Change *.avi to be whatever the extension of your vids is.
Not rocket science, but I found it useful and thought I'd share.
Thanks, so simple, so cool.
Nice idea. Here are my embellishments.
You need quotes to deal with filenames with spaces:
for %i in (*.avi) do ffmpeg -i "%i" -f mjpeg -t 0.001 -ss 5 -y "%~ni.tbn"
And here is one for recursively doing directories:
for /r %i in (*.avi) do ffmpeg -i "%i" -f mjpeg -t 0.001 -ss 5 -y "%~di%~pi%~ni.tbn"
gzusrawx
2006-09-28, 20:07
Has anyone or does anyone know how to do this in linux?
"unable to find a suitable output format for 'videoname.tbn'"
i keep getting this error
any ideas?
hoki_goujons
2006-09-29, 22:24
Kugai - good stuff, I was just looking around for how to do spaces :-)
gzusrawx - Not off the top of my head. Some kind of find -exec with a bit of awk goodness to do the filename would be my guess.
Bazzio - are you using a current version of ffmpeg? Try changing '.tbn' for 'jpg' or try -singlejpeg instead of -mjpeg
Just wanted to say thanks to you guys for sharing your ideas and tricks. :;):
I just created a page in the online-manual for creating the preview-thumbnails.
http://www.xboxmediacenter.com/wiki/index.php?title=HOW-TO:_Create_video-preview_thumbnails
Please have a look at that page and tell me if i have included any mistakes/typos.. :grin:
no i dont think i do have the latest.
is is mplayer i need?
I cant seem to find just ffmpeg to put in windows/system32
if you could give me some links or explain this that would be great!
Thanks
ok i got the latest version sorted, but now i have a new error
"swScaler: 0x0 ( is not supported as output format
Cannot get resampling context"
hoki_goujons
2006-09-30, 21:37
sCAPe - I'm honoured :-) Looks good to me.
Bazzio - I don't know what that error is. Maybe your version is too recent (http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2006-August/013856.html) - what damn fool told you to use the latest version? ;-) The one I'm using is SVN-r5570, you can try mine if you like (http://homepages.nildram.co.uk/~pravda/foo/ffmpeg.exe).
Have you tried it with a few different types of file?
what verison do you have?
aparently pthreadGC2.dll is missing, so i cant use your version
grrrr
ok
finally got it working
Rather than 5 seconds, i wanted to do it with about a min in. Sometimes expecially on movies there is only an intro around 5 secs, so it doesnt make a very good thumbnail.
however this takes a lot more time to process.
Is there a way you can tell it to ignore the file if a tbn is present, this way updates will be a lot quicker
If there is interest I can probably throw together a perl script or something like that to make this a little easier. I'll try to get something up in the next few days.
huscoolcal
2006-10-05, 00:40
Hi Bazzio, how did you resolve the error I m getting the same issue.
huscoolcal
2006-10-05, 01:07
No problem was able to get it to work using the link for the previous version provided thanks!!
kugai - any luck with that script?
Here is what I'll call beta1 of the perl script. I have tested it under windows and linux. If you need perl for windows you can get it here (http://www.activestate.com/store/activeperl/download/).
Here are the options for the script:
-d DIRECTORY Set the directory to start in. This must be the full path i.e. D:/media/video (windows) or /home/media/video (*nix). The default will be the current directory.
-r Recurse directories. This will read every file in every directory under the starting folder.
-s SECONDS Set where, in seconds, to grab the thumbnail from the video. Default is 5 seconds.
-o Overwrite existing thumbnails. Default will skip files that already have thumbnails.
EXAMPLE:
Create thumbnails at 5 minutes in for all files in the current folder and all files in the directories below
xbmctbn.pl -r -s 300
Let me know if you have any problems or requests. Currently it will work on .mpg .mpeg .avi .mov .wmv and .vob files. It should be pretty obvious how to add others in the script or just ask and I will add them.
DOWNLOAD:
xbmctbn_b01.zip (http://slowsong.com/xbmc/xbmctbn_b01.zip)
Again, thanks to hoki_goujons for the original idea.
Ok, I've aleady noticed that there is a problem with the recurision (-r) mode not working right. It should work ok otherwise. I will post a new fixed version soon. Sorry for the inconvience.
any chance of a noob tutorial to go with this?
Here is the fixed version of the script.
Download:
xbmctbn_b02.zip (http://slowsong.com/xbmc/xbmctbn_b02.zip)
I guess you can't edit your posts on here or I would keep this in the original post. All the options are the same except this one works :)
I'll try to post a more basic tutorial soon and possibly even add a GUI frontend if enough people are interested.
that would be awesome if you could!!
did anything ever become of the gui version?