MediaPortal Forums HTPC/MediaCenter

Go Back   MediaPortal Forum » MediaPortal 1 » Main Features (talk, share your ideas, get support) » Watch / Listen Media » watch/edit Videos » Tips and Tricks


Tips and Tricks Post Tips and Tricks here.

Reply
 
Thread Tools Display Modes
Old 2007-04-20, 15:25   #1 (permalink)
Portal User
 
Join Date: Apr 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts


Default Video thumbnails script

While waiting for a video thumbnail/preview plugin you can use this Jscript to create thumbnails for your movies.
You need Avisynth

Open notepad, paste the code and save as ThumbnailCreator.js
Edit the settings and doubleclick it

EDITorry code format is wrong, please download the zip file (next post)
(Or break the lines js style...)

Code:
/*########## Dirty ThumbnailCreator Script by MonsterMagnet ################################################
############################################################################################################

### Best viewed >= 1024x768

### Requires Avisynth 2.5 (http://sourceforge.net/projects/avisynth2/)(tested with 2.56 and 2.57)
### and mplayer2 (included in WinXP C:\Programme\Windows Media Player\mplayer2.exe).

### This script creates thumbnail and preview images from your movies, for use with Mediaportal.
### Only missing thumbs or previews are created.(so you can run this script every time you add new movies !)
### 100 movie thumbs and 100 previews are created in 3:10 min (Athlon64 3500).

### TIP 1: Try this script with a test movie directory.
### TIP 2: You can use this script inside Mediaportal with the MyPrograms plugin.
### TIP 3: In directory: C:\Programme\Team MediaPortal\MediaPortal\Skin\BlueTwo\myvideo.xml change 
###        <import>common.facade.video.xml</import> to <import>common.facade.pictures.xml</import> 
### TIP 4: Eventghost.org (open-source automation tool for MS Windows, supports infrared or wireless remotes)
 
#############################################################################################################
############ SETTINGS (Edit carefully !!!) ################################################################*/

/*----------- Path to AviSynth "DirectShowSource.dll" (double backslashes !) --------------------------------
-----------------------------------------------------------------------------------------------------------*/

var AviSynth = "C:\\Programme\\AviSynth 2.5\\plugins"

/*----------- VideoFrame to use as thumbnail (use lower value for small and higher for large files !) -------
-----------------------------------------------------------------------------------------------------------*/

var imageframe = 500

/*----------- MediaPortal video title thumbnail directory (double backslashes !) ----------------------------
-----------------------------------------------------------------------------------------------------------*/

var MPdir = "C:\\Programme\\Team MediaPortal\\MediaPortal\\Thumbs\\videos\\Title"

/*----------- Directories to scan (double backslashes !, remove leading double slashes for more directories!)
-----------------------------------------------------------------------------------------------------------*/

dirs = new Array();

dirs[0] = "F:\\Shared saved\\Movies"
//dirs[1] = "D:\\Test2"
//dirs[2] = "E:\\Test3"
//dirs[3] = "F:\\Test4"

/*---------- Mplayer exe path (Only edit if mplayer2 was not found or you want to use another player --------
------------ (no blanks !, double backslashes !) ------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------*/

var mplayer ="mplayer2.exe"

/*############# END SETTINGS ################################################################################
###########################################################################################################*/

var counterS = 0;
var counterL = 0;

var fso = new ActiveXObject("Scripting.FileSystemObject");
var wshshell = new ActiveXObject("Wscript.shell");


function scan ()
{
   for (i=0; i < dirs.length; i++)
   { 
      scandir (dirs[i])
   }
   wshshell.Popup(counterS + " Thumbnails and " + counterL + " Preview images created", 1, "ThumbnailCreator", 0+64)
}

function scandir( dir )
{
   if (fso.FolderExists( dir ) == true)
   {
      var srcFolder = fso.GetFolder( dir );
      var files = new Enumerator( srcFolder.files );

      do 
      {
         var ext = fso.GetExtensionName (files.item());
         ext = ext.toLowerCase();

         if (ext == "avi" || ext == "mpg" || ext == "wmv" || ext == "rmvb" || ext == "mov")
         {  
            var search = files.item().name.lastIndexOf(".");
            var part = files.item().name.substring(0,search);
            var thumbS = part + ".jpg";
            var thumbL = part + "L.jpg";


            if (fso.FileExists(dir + '\\' + thumbS) == false && fso.FileExists(MPdir + '\\' + thumbS) == false)
            { 
              var tf = fso.CreateTextFile(AviSynth + "\\Tempscript.avs",true)
              tf.WriteLine('LoadPlugin ("' +AviSynth+ '\\DirectShowSource.dll")')
              tf.WriteLine('input=(DirectShowSource("'+files.item().path+ '", fps=25, seek=true, audio=false))')
              tf.WriteLine("converttorgb24(input)")
              tf.WriteLine("Crop(16, 16, -16, -16)")
              tf.WriteLine("BilinearResize(128,96)")
              tf.WriteLine('Trim(' + imageframe + ',' + imageframe + ')')
              tf.WriteLine('ImageWriter("' +AviSynth+ '\\" ,0,0,"jpg")')
              tf.Close()              
              wshshell.run (mplayer + " /play /close " +AviSynth+ "\\Tempscript.avs",7, true)
              fso.CopyFile (AviSynth + '\\000000.jpg',dir + '\\' + thumbS)
              counterS++;
            }

            if (fso.FileExists(dir + '\\' + thumbL) == false && fso.FileExists(MPdir + '\\' + thumbL) == false)
            { 
              var tf = fso.CreateTextFile(AviSynth + "\\Tempscript.avs",true)
              tf.WriteLine('LoadPlugin ("' +AviSynth+ '\\DirectShowSource.dll")')
              tf.WriteLine('input=(DirectShowSource("'+files.item().path+ '", fps=25, seek=true, audio=false))')
              tf.WriteLine("converttorgb24(input)")
              tf.WriteLine("Crop(16, 16, -16, -16)")
              tf.WriteLine("BilinearResize(512,384)")
              tf.WriteLine('Trim(' + imageframe + ',' + imageframe + ')')
              tf.WriteLine('ImageWriter("' +AviSynth+ '\\" ,0,0,"jpg")')
              tf.Close()              
              wshshell.run (mplayer + " /play /close " +AviSynth+ "\\Tempscript.avs",7, true)
              fso.CopyFile (AviSynth + '\\000000.jpg',dir + '\\' + thumbL)
              counterL++;
            }

         }

         files.moveNext();
        
      }

      while (!files.atEnd() );      

   }

}

scan()

Last edited by MonsterM; 2007-04-20 at 16:39. Reason: Code format
MonsterM is offline   Reply With Quote
Old 2007-04-20, 16:27   #2 (permalink)
Portal User
 
Join Date: Apr 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts


Default

Here's the code as zip...
Attached Files
File Type: zip videothumbnails.zip (1.9 KB, 59 views)
MonsterM is offline   Reply With Quote
Old 2007-04-20, 19:44   #3 (permalink)
Portal Member
 
Join Date: Jul 2005
Location: Copenhagen
Age: 36
Posts: 57
Thanks: 2
Thanked 1 Time in 1 Post

Country:

My System

Send a message via MSN to classico
Question

Hi,

Thank you for a perfect script :-)

....do you know what kind of files it supports?
....do you know how to get it to support .m2t files?

Best regards,
Jesper
classico is offline   Reply With Quote
Old 2007-04-21, 11:15   #4 (permalink)
Portal User
 
Join Date: Apr 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts


Default

Hello,

i don't have movies in m2t format, so i can't test it but you can give it a try, just change

Code:
if (ext == "avi" || ext == "mpg" || ext == "wmv" || ext == "rmvb" || ext == "mov")
to

Code:
if (ext == "avi" || ext == "mpg" || ext == "wmv" || ext == "rmvb" || ext == "mov" || ext ==  "m2t")

http://avisynth.org/DirectShowSource
MonsterM is offline   Reply With Quote
Old 2007-04-23, 16:38   #5 (permalink)
Portal Member
 
Join Date: Jul 2005
Location: Copenhagen
Age: 36
Posts: 57
Thanks: 2
Thanked 1 Time in 1 Post

Country:

My System

Send a message via MSN to classico
Default

Hi,

Thanks for your reply, but it does not create thumbs of the m2t files :-(
classico is offline   Reply With Quote
Old 2007-04-29, 22:47   #6 (permalink)
Portal Member
 
Join Date: Aug 2006
Age: 26
Posts: 49
Thanks: 0
Thanked 1 Time in 1 Post

Country:

My System

Default

is it possible to make it recurse subdirectories?
Ynot is offline   Reply With Quote
Reply

Bookmarks

Tags
script, thumbnails, video

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Thumbnails, album & video cover art frodo Tips and Tricks 29 2008-05-14 22:04
Where are the My Video thumbnails stored at? Jeomite Support 2 2007-03-04 22:30
No Video thumbnails? Lexen Support 9 2007-02-12 19:32
Video thumbnails create multiple threads gloomyandy 0.2.0.0 Final and SVN Builds 6 2006-12-31 18:02
My Video Thumbnails dman_lfc Improvement Suggestions 5 2004-10-20 17:46


All times are GMT +1. The time now is 06:36.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 Protected by Akismet Blog with WordPress