PDA

View Full Version : HOW-TO create video preview thumbnails automatically


Calmiche
2007-11-15, 07:40
Okay, I just found out about one of these and the other one I wrote. If you have seen them before, then don't complain. They are new to me.

---------------------------------------
Creating XBMC Thumbnails Automatically
---------------------------------------

I wanted to have thumbnails for all my television episodes. (All my episodes are on my windows PC, sheared over my network.) Instead of downloading each file individually, I found a tip on the XBMC wiki page.

http://www.xboxmediacenter.com/wiki/index.php?title=HOW-TO:_Create_video-preview_thumbnails

1. Download this file:
http://ffdshow.faireal.net/mirror/ffmpeg/ffmpeg.rev10908.7z

2. Extract that file (Including the DLL) into your \\Windows\System32 folder.

3. Open up a command prompt window in the root folder of your television shows and then type this command

for /r %i in (*.avi) do ffmpeg -i "%i" -f mjpeg -t 0.001 -ss 5 -y "%~di%~pi%~ni.tbn"

You can replace the (*.avi) with different file formats, including mp4, divx, rmvb, ogm and rm.

This will open up your episodes, skip 5 seconds in, take a screen shot, rename it to *.tbn and then go to the next file. It will also do any sub folder.

---------------------------------------
Seeing *.tbn files in Windows Explorer
---------------------------------------

I bet that you know that you can go into a folder in Windows XP, switch to Thumbnail view, and be presented with an icon of the first screen from a movie. It works for images as well. Unfortunately, it doesn't work for *.tbn files. Until now, that is.

1. Create a new text document.

2. Paste the following block of text into it.

REGEDIT4

[HKEY_CLASSES_ROOT\.tbn\ShellEx\{BB2E617C-0920-11d1-9A0B-00C04FC2D6C1}]
@="{3F30C968-480A-4C6C-862D-EFC0897BB84B}"

3. Rename the file so that the extension is .reg (I named mine "tbn thumbnails.reg")

4. Double-click the file and you are all set. Windows XP will now see TBN thumbnails as images and create a windows thumbnail for them. You can see them in your folders on your computer.

jaredharley
2007-11-15, 21:41
Well done! I'm going to have to try this out, it looks awesome!

Also, thanks for the .tbn preview in Windows.

jaredharley
2007-11-16, 03:54
Well done! I'm going to have to try this out, it looks awesome!

Also, thanks for the .tbn preview in Windows.

Both are awesome! Thanks!

Gamester17
2007-11-16, 13:19
Remember to share your thumbnails with others by uploading them to http://www.thetvdb.com

TheTVDB is the database and scraper that XBMC uses and it is wiki based.

By the users, for the users :;):

sickboy719
2007-11-16, 18:31
Very nice, thank you.
I've been using Frameshots to make my thumbs, I'll give yours a go and see how it works.

HarshReality
2007-11-16, 18:57
Wasnt this in the wiki? Well I know I saw it but I guess its been removed.

jaredharley
2007-11-16, 19:04
Wasnt this in the wiki? Well I know I saw it but I guess its been removed.

No, it's still there, Calmiche linked to it in his post. I've been all over the wiki and had never come across this tip.

Instead of downloading each file individually, I found a tip on the XBMC wiki page.

http://www.xboxmediacenter.com/wiki/index.php?title=HOW-TO:_Create_video-preview_thumbnails

HarshReality
2007-11-16, 20:22
I tried it for a time and worked great... 6 seasons of smallville etc. but after a time just got to be bothersom.

jaredharley
2007-11-16, 22:34
I tried it for a time and worked great... 6 seasons of smallville etc. but after a time just got to be bothersom.

The command Calmiche uses
for /r %i in (*.avi) do ffmpeg -i "%i" -f mjpeg -t 0.001 -ss 5 -y "%~di%~pi%~ni.tbn"does a recursive scan on folders. If you've got a directory called "TV Shows", you could simply navigate to that folder in a cmd window, and then run the command. It will look in all folders and sub-folders for video files matching the parameters (in this case, .avi files).

I can see how it would get irritating to do this with each new episode you download (or create, however you get them). Now that I've done the initial work, I plan on only doing it when a season is complete.

cayotic
2007-11-17, 02:36
I saw the first tutorial before but I couldn't exicute it for whatever reason so I went with frameshots. I'll try it again, as far as the tbn viewer is concerned, I don't think it works in vista, can someone else confirm. I'll try it on my main XP server where I'm sure it will work...

Thanks,

jaredharley
2007-11-17, 19:31
I saw the first tutorial before but I couldn't exicute it for whatever reason so I went with frameshots. I'll try it again, as far as the tbn viewer is concerned, I don't think it works in vista, can someone else confirm. I'll try it on my main XP server where I'm sure it will work...

Thanks,

Vista's registry is just a little bit different. Place the below code into a normal text file, and save as a .reg file (should have the little blue cube of blocks icon).
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.tbn\ShellEx\{BB2E617C-0920-11d1-9A0B-00C04FC2D6C1}]
@="{3F30C968-480A-4C6C-862D-EFC0897BB84B}"This does work on Vista.

As for the screenshot creator - you have to have all 3 of the linked files in the c:\windows\system32 folder. Then, in a cmd window, navigate to the folder with your tv shows (ie, type in: cd d:\tv shows) and then you can use the command he mentioned. If you copied it off of the post, you can right-click and choose "paste" to paste the text into the cmd window (you can't use ctrl+v).

Gamester17
2007-11-20, 15:25
Feel free to update the WIKI article if needed http://xboxmediacenter.com/wiki/index.php?title=HOW-TO:_Create_video-preview_thumbnails :;):

All users who wish to continue providing a valid contribution to the XBox Media Center online manual, please contact one of the XBMC team members and ask for Ninja status on the wiki.http://xboxmediacenter.com/wiki/index.php?title=Main_Page

jaredharley
2007-11-20, 20:50
Feel free to update the WIKI article if needed http://xboxmediacenter.com/wiki/index.php?title=HOW-TO:_Create_video-preview_thumbnails :;):

http://xboxmediacenter.com/wiki/index.php?title=Main_Page

I'd need ninja status for that.... pretty please?

DrDDT
2007-11-21, 16:23
I added an 'if exist' to the batch file so it can run scheduled for automatic run every day.

Does anybody know how to nest the for loop so I can check several root folders in one line?

I now use:


@echo off

setlocal
set FFMPEG=f:\tools\ffmpeg\ffmpeg.exe
set THUMB="%%~di%%~pi%%~ni.tbn"
set MAKETHUMB=%FFMPEG% -i "%%i" -f mjpeg -t 0.001 -ss 5 -y %THUMB%

set FILES="*.avi"
set DIRS=m:\media\series i:\media\series

for /r m:\media\series %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
for /r i:\media\series %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
endlocal


I'd like to merge the two for loops and make use of the DIRS variable.

Gamester17
2007-12-12, 15:50
FYI; this was added to the Linux port branch of XBMC late yesterday:extract frame from video files without thumb. experimental.Let's hope this feature gets ported back to the Xbox trunk as well :;):

R111
2008-01-04, 08:47
i cook up this ver of batch

@echo off

set FFMPEG=C:\Windows\System32\ffmpeg.exe
set THUMB="%%~di%%~pi%%~ni.tbn"
set MAKETHUMB=%FFMPEG% -i "%%i" -f mjpeg -t 0.001 -ss 5 -y %THUMB%
set FILES="*.mov" "*.mpg" "*.avi" "*.flv" "*.wmv" "*.mp4"

ECHO ----------------------------------------------------------------------
ECHO.
ECHO [1] Trailers
ECHO [2] Drags
ECHO [3] Camcorder
ECHO [4] Music
ECHO [5] TV Series
ECHO [6] Quit
ECHO.
SET DirsType=
SET /P DirsType="Please select a Folder and press <ENTER>: "

IF /I "%DirsType%"=="1" (
for /r F:\Videos\Trailers %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="2" (
for /r F:\Videos\Sports\Drag %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="3" (
for /r F:\Videos\Camcorder %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="4" (
for /r F:\Videos\Music %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="5" (
for /r F:\Videos\TV Series %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="6" (
GOTO Quit
)

hope someone can do a proper batch. say with an option to set second to take screenshot

R111
2008-01-04, 09:11
where the edit button?

i redone the batch with the option to set second to skip to take screenshot

@echo off

set FFMPEG="C:\Program Files\FFmpeg\ffmpeg.exe"
set THUMB="%%~di%%~pi%%~ni.tbn"
set /P SEC="Set second to skip to take screenshot and press <ENTER>: "
set MAKETHUMB=%FFMPEG% -i "%%i" -f mjpeg -t 0.001 -ss %SEC% -y %THUMB%
set FILES="*.mov" "*.mpg" "*.avi" "*.flv" "*.wmv" "*.mp4"

ECHO ----------------------------------------------------------------------
ECHO.
ECHO [1] Trailers
ECHO [2] Drags
ECHO [3] Camcorder
ECHO [4] Music
ECHO [5] TV Series
ECHO [6] Quit
ECHO.
SET DirsType=
SET /P DirsType="Please select a Folder and press <ENTER>: "

IF /I "%DirsType%"=="1" (
for /r F:\Videos\Trailers %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="2" (
for /r F:\Videos\Sports\Drag %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="3" (
for /r F:\Videos\Camcorder %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="4" (
for /r F:\Videos\Music %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="5" (
for /r F:\Videos\TV Series %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="6" (
GOTO Quit
)

Gamester17
2008-01-04, 15:41
Does it only grab the next key-frame (http://en.wikipedia.org/wiki/Key_frame) after a certain amounts of seconds into each video, or does it grab just any frame at that second?

The difference is that a key-frame (http://en.wikipedia.org/wiki/Key_frame) has higher quality, which is why you preferably want to grab a key-frame (http://en.wikipedia.org/wiki/Key_frame) instead of just any frame).

Attro
2008-02-21, 19:11
Man this makes thumbs much easier! Once I delete videos I still have the thumbs left over tho. Is there any way add a "cleanup" option to this script to somehow delete unneeded thumbs?

DrDDT
2008-02-25, 13:28
Man this makes thumbs much easier! Once I delete videos I still have the thumbs left over tho. Is there any way add a "cleanup" option to this script to somehow delete unneeded thumbs?

Something like:

set MOVIE=%%~di%%~pi%%~ni
for /r f:\series\ %%i in ( *.tbn ) do if not exist %MOVIE%.mov if not exist %MOVIE%.mpg if not exist %MOVIE%.avi if not exist %MOVIE%.flv if not exist %MOVIE%.wmv if not exist %MOVIE%.mp4 del "%%i"

should do the trick.
Make sure you have an 'if exists' for every file extension you use. This can also be used to clean up other stuff with the same name as the movie, like .srt .edl etc.

jaredharley
2008-02-25, 23:20
Maybe something like this? I can't test it right now, as I'm at work, but I think this should work.

@echo off

set FFMPEG="C:\Program Files\FFmpeg\ffmpeg.exe"
set THUMB="%%~di%%~pi%%~ni.tbn"
set /P SEC="Set second to skip to take screenshot and press <ENTER>: "
set MAKETHUMB=%FFMPEG% -i "%%i" -f mjpeg -t 0.001 -ss %SEC% -y %THUMB%
set FILES="*.mov" "*.mpg" "*.avi" "*.flv" "*.wmv" "*.mp4" "*.mkv"

ECHO ----------------------------------------------------------------------
ECHO.
ECHO [1] TV Series
ECHO [2] Clean old thumbnails
ECHO.
ECHO [3] Quit
ECHO.
SET /P DirsType="Please select a Folder and press <ENTER>: "

IF /I "%DirsType%"=="1" (
for /r M:\TV Shows\ %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="2" (
for /r M:\TV Shows\ %%i in ( *.tbn ) do if not exist %MOVIE%.mov if not exist %MOVIE%.mpg if not exist %MOVIE%.avi if not exist %MOVIE%.flv if not exist %MOVIE%.wmv if not exist %MOVIE%.mp4 if not exist %MOVIE%.mkv del "%%i"
)
IF /I "%DirsType%"=="3" (
GOTO Quit
)

rgviewer
2008-06-04, 23:20
--------------------------------------------------------------------------------

I was wondering if anyone knows how I can create a batch file and if I could use Task Scheduler to auto launch it to update my thumbnails. I am able to open a command prompt in C:\Users\Public\Recorded TV and generate thumbs, but it would be very helpful if it could be done all automaticaly.

Thanks

Hitcher
2008-06-26, 17:02
Does it only grab the next key-frame (http://en.wikipedia.org/wiki/Key_frame) after a certain amounts of seconds into each video, or does it grab just any frame at that second?

The difference is that a key-frame (http://en.wikipedia.org/wiki/Key_frame) has higher quality, which is why you preferably want to grab a key-frame (http://en.wikipedia.org/wiki/Key_frame) instead of just any frame).

I think it's the latter because I get some bad frames when running the cmd.

Maybe something like this? I can't test it right now, as I'm at work, but I think this should work.

@echo off

set FFMPEG="C:\Program Files\FFmpeg\ffmpeg.exe"
set THUMB="%%~di%%~pi%%~ni.tbn"
set /P SEC="Set second to skip to take screenshot and press <ENTER>: "
set MAKETHUMB=%FFMPEG% -i "%%i" -f mjpeg -t 0.001 -ss %SEC% -y %THUMB%
set FILES="*.mov" "*.mpg" "*.avi" "*.flv" "*.wmv" "*.mp4" "*.mkv"

ECHO ----------------------------------------------------------------------
ECHO.
ECHO [1] TV Series
ECHO [2] Clean old thumbnails
ECHO.
ECHO [3] Quit
ECHO.
SET /P DirsType="Please select a Folder and press <ENTER>: "

IF /I "%DirsType%"=="1" (
for /r M:\TV Shows\ %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="2" (
for /r M:\TV Shows\ %%i in ( *.tbn ) do if not exist %MOVIE%.mov if not exist %MOVIE%.mpg if not exist %MOVIE%.avi if not exist %MOVIE%.flv if not exist %MOVIE%.wmv if not exist %MOVIE%.mp4 if not exist %MOVIE%.mkv del "%%i"
)
IF /I "%DirsType%"=="3" (
GOTO Quit
)

I've changed the directory to where I have my TV shows but whenever I run the batch file it just flashs up 'The system cannot find the path specified'.

moonoo
2008-06-27, 20:09
Hello Hitcher,

I've changed the directory to where I have my TV shows but whenever I run the batch file it just flashs up 'The system cannot find the path specified'.

I think all that is missing is quotes around your TV Show directories:

@echo off

set FFMPEG="C:\Program Files\FFmpeg\ffmpeg.exe"
set THUMB="%%~di%%~pi%%~ni.tbn"
set /P SEC="Set second to skip to take screenshot and press <ENTER>: "
set MAKETHUMB=%FFMPEG% -i "%%i" -f mjpeg -t 0.001 -ss %SEC% -y %THUMB%
set FILES="*.mov" "*.mpg" "*.avi" "*.flv" "*.wmv" "*.mp4" "*.mkv"

ECHO ----------------------------------------------------------------------
ECHO.
ECHO [1] TV Series
ECHO [2] Clean old thumbnails
ECHO.
ECHO [3] Quit
ECHO.
SET /P DirsType="Please select an option and press <ENTER>: "

IF /I "%DirsType%"=="1" (
for /r "C:\TVSHOW" %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="2" (
for /r "C:\TVSHOW" %%i in ( *.tbn ) do if not exist %MOVIE%.mov if not exist %MOVIE%.mpg if not exist %MOVIE%.avi if not exist %MOVIE%.flv if not exist %MOVIE%.wmv if not exist %MOVIE%.mp4 if not exist %MOVIE%.mkv del "%%i"
)
IF /I "%DirsType%"=="3" (
GOTO Quit
)

regards
moonoo

Hitcher
2008-06-28, 07:39
Thanks, but still the same message.

Hitcher
2008-06-29, 12:29
It was the location of FFmpeg.exe I'd overlooked.

set FFMPEG=C:\Windows\System32\ffmpeg.exe

I feel stupid.:rolleyes:

joebrady
2008-07-02, 21:42
Tried this last night, worked good for a lot of TV episodes I didn't have thumbs for. Thanks!:)

Hitcher
2008-07-02, 22:44
Don't forget to upload them to TVDB.

joebrady
2008-07-02, 23:18
Yea, that's on my agenda for tonight. Too bad tvdb doesn't have a section for "Chilly Willy" cartoons tho.... But I do have some good ones to upload for "Man Vs. Wild Season 2" and "Saving Planet Earth"

Gamester17
2008-07-03, 01:52
Too bad tvdb doesn't have a section for "Chilly Willy" cartoons tho.... But I do have some good ones to upload for "Man Vs. Wild Season 2" and "Saving Planet Earth"Try posting in TheTVDB.com (http://www.thetvdb.com) forums and asking them to add it or something similar:
http://forums.thetvdb.com

:;):

rgviewer
2008-08-29, 00:00
I was wondering if someone could help me create a batch file to create thumbs. I can create thumbs by opening a command window in my folder using the line (for %i in (*.dvr-ms) do ffmpeg -i "%i" -f mjpeg -t 0.001 -ss 5 -y "%~ni.tbn") but so far I can't seem to use any of the batch files you all have suggested. I want to create thumbs for dvr-ms files that are storred in C:\Users\Public\Recorded TV. I may be doing this wrong but what I have done is copy your scripts and put them in a text file, saved it as test.bat and when I double click on it nothing happens. I think I set up the dirrectories correct. Any help would be much appreciated.

Hitcher
2008-08-29, 00:18
Post the exact batch file.

rgviewer
2008-08-29, 00:35
here is what I put in a txt document and saved as test.bat

@echo off

setlocal
set FFMPEG=C:\Windows\System32\ffmpeg.exe
set THUMB="%%~di%%~pi%%~ni.tbn"
set MAKETHUMB=%FFMPEG% -i "%%i" -f mjpeg -t 0.001 -ss 5 -y %THUMB%

set FILES="*.dvr-ms"
set DIRS=C:\Users\Public\Recorded TV\Sample Media

for /r C:\Users\Public\Recorded TV\Sample Media %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%

endlocal

Hitcher
2008-08-29, 08:42
Is ffmpeg.exe in the corrent directory? ie C:\Windows\System32\ffmpeg.exe
That was causing me problems.

rgviewer
2008-08-29, 18:51
Is ffmpeg.exe in the corrent directory? ie C:\Windows\System32\ffmpeg.exe
That was causing me problems.

yes I checked that also. I have tried this on two different computers, one xp and one vista.

I appreciate you taking the time to help me. Any more suggestions would be great.
Thanks

kingtiger01
2008-09-25, 12:27
http://xbmc.org/forum/showthread.php?t=29699
Wouldnt this all be easier to just make a Service installer, that Has a menu that contains "Directory's" "file types" and "Date/times to run".

And have it update a batch file written directly to system32, that would run on a service base, that would loop the end of the script, endlessly, until the time specified is reached(best if written in hex), then run the begining of the batch. containing the Thumbnail Creation script...

I dont know about you, but it make it alot easier on alot of people. id do it but i dont have a scriptable installer creator. only thing i have or ever used is install4j...

and that wont do anyone any good :laugh:.

Just thoughts...

--

Some one should also write a Python script to parse these pictures as thumbnails for files, for XBMC Xbox Flavor.. dont you think!?..

CASHMON3Y
2008-09-25, 13:51
Are video thumb nails whats supposed to go in that blank icon in aeon when you highlight over a tv show?

CASHMON3Y
2008-09-25, 14:14
NVM, I thought this for for video preview like the PS3 has. Where it shows like 5 seconds OF the video.

PantsOnFire
2008-10-04, 12:55
Would it be hard to implement this feature into xbmc tho?

I mean we already have a screengrab feature which captures to a BMP. Could xbmc be expanded to turn that into a TBN file with the same filename as the video?

matador4
2009-01-21, 12:40
Pls.I know that this post have a long time to activated but someone may help.

I have 2 computers and i run the script in both of them.

In the first comp is running perfect and i have have thumnail in the folder.

In the second one the thumnail is next to the folder.

ANY IDEA??????? HELPPPPPP

theophile
2009-02-06, 23:08
I just worked up a bash script for Linux that will generate thumbs. Let me know if it works:

#!/bin/bash
ls *.wmv *.avi *.mkv *.ogm *.mpg | while read file; do
ffmpeg -itsoffset -5 -i $file -vcodec mjpeg -vframes 1 -an -f rawvideo ${file:0:${#file}-3}tbn </dev/null
done

It assumes the video file extension is three characters, so it won't work on, say, a *.mpeg file.

rgviewer
2009-02-26, 23:18
I have a Win MCE2005 that I record all my shows on to D:\Recorded TV (they have a .dvr-ms extension) and would like to be able to auto create thumbs to play back on xbmc. I am able to run this line in a cmd prompt to create thumbs using the following: but only by opening up a cmd prompt in the folder D:\Recorded TV and then pasting the line in.This works but I cann't run a task schedual.

"for /r %i in (*.dvr-ms) do ffmpeg -i "%i" -f mjpeg -t 0.001 -ss 5 -y "%~di%~pi%~ni.tbn"



I am able to run a batch file like this and use task schedual and it works perfect, but only if I move a recording inot a folder "C:\test" but if I subsitute "C:\test" with "D:\Recorded TV" it doesn't work. I don't want to manually move all my recording daily and plus the d:\recorded tv is where mce reads the file from.

@echo off

set FFMPEG=C:\Windows\System32\ffmpeg.exe
set THUMB="%%~di%%~pi%%~ni.tbn"
set MAKETHUMB=%FFMPEG% -i "%%i" -f mjpeg -t 0.001 -ss 5 -y %THUMB%
set FILES="*.mov" "*.dvr-ms" "*.avi" "*.flv" "*.wmv" "*.mp4"

for /r C:\test %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%



Does anyone have any suggestions? Do I need to move all my recordings into another folder because of some permissions not allowing me to run a batch file into my recorded tv folder in MCE2005.
Hope this all makes sense.
Thanks Agian

LaTropa64
2009-04-06, 01:18
Vista's registry is just a little bit different. Place the below code into a normal text file, and save as a .reg file (should have the little blue cube of blocks icon).
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.tbn\ShellEx\{BB2E617C-0920-11d1-9A0B-00C04FC2D6C1}]
@="{3F30C968-480A-4C6C-862D-EFC0897BB84B}"This does work on Vista.

Sorry for pulling up an old thread but I can't seem to get this to work. It did add to my registry but all tbn's still show as a generic icon in explorer instead of a preview of the pic like regular jpeg's do.



edit: Nevermind. I restarted the computer and it's working now.