Video thumbnails script (1 Viewer)

MonsterM

New Member
April 20, 2007
3
0
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 :D

EDIT:confused:orry 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()
 

classico

Portal Pro
July 27, 2005
63
1
Copenhagen
Home Country
Denmark Denmark
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
 

MonsterM

New Member
April 20, 2007
3
0
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
 

Users who are viewing this thread

Top Bottom