Little windows-script to batch convert with aviConverter

Worlds cheapest 1.8" color 8GB MicroSD Mp3 player: $48 on Amazon.com
Post Reply
divx118
Archos Guru
Archos Guru
Posts: 595
Joined: Tue Dec 04, 2007 9:48 pm
Contact:

Little windows-script to batch convert with aviConverter

Post by divx118 »

I was irritated by the fact that you cannot add multiple files at once in aviConverter. So I wrote a little script which when run will try to convert all the video files in the folder from where it is run. It uses the commandline and mencoder from the installed aviConverter.
I use it for my Archos 1.8 Vision. The commandline options for mencoder are below. This can be different when having another target device and should be changed in the script.

Code: Select all

-ofps 15 -vf-add scale=160:128 -vf-add expand=160:128:-1:-1:1 -srate 44100 -ovc xvid -stereo 0 -xvidencopts bitrate=400:max_bframes=0:quant_type=h263:me_quality=0 -oac lavc -lavcopts acodec=mp2:abitrate=128


What you need:
- Windows
- aviConverter installed which comes with your mp3/mp4 player.

The code I used is below:

Code: Select all

<job id="main">
  <script language="JScript">


var WshShell = new ActiveXObject("WScript.Shell");

function ShowFolderFileList()

{

   var fso, f, fc, s;

   fso = new ActiveXObject("Scripting.FileSystemObject");
   folderspec=fso.GetFolder(".");
   f = fso.GetFolder(folderspec);

   fc = new Enumerator(f.files);
   var i=0;
   var fail=0
   for (; !fc.atEnd(); fc.moveNext())

   {

        s= fc.item();
        t = fso.GetFile(s);
        var extension=getFileExtension(t.Name)
       
        //If you want more file extensions supported add them in the below if statement
        if (extension.toLowerCase() in {'mp4':'', 'mpg':'','avi':''})
            {
            var newName=t.Name
            newName=newName.substring(0,newName.length-extension.length)+"avi"
            //WScript.Echo("test: "+newName)
            if (!fso.FolderExists(folderspec+"\\converted")) {fso.CreateFolder(folderspec+"\\converted")}
         if (!fso.FolderExists(folderspec+"\\done")) {fso.CreateFolder(folderspec+"\\done")}
            if (!fso.FolderExists(folderspec+"\\failed")) {fso.CreateFolder(folderspec+"\\failed")}
           
            i++
            WScript.Sleep(1500)
            try {
                var temp='"%PROGRAMFILES%\\AVIConverter\\MENCODER.EXE" -ofps 15 -vf-add scale=160:128 -vf-add expand=160:128:-1:-1:1 -srate 44100 -ovc xvid -stereo 0 -xvidencopts bitrate=400:max_bframes=0:quant_type=h263:me_quality=0 -oac lavc -lavcopts acodec=mp2:abitrate=128 "'+folderspec+'\\'+t.Name+'" -o "'+folderspec+'\\converted\\'+newName+'"'
               

                Return = WshShell.Run(temp,1,true)
               
                }
            catch (e)
                {
                var temp='"%ProgramFiles(x86)%\\AVIConverter\\MENCODER.EXE" -ofps 15 -vf-add scale=160:128 -vf-add expand=160:128:-1:-1:1 -srate 44100 -ovc xvid -stereo 0 -xvidencopts bitrate=400:max_bframes=0:quant_type=h263:me_quality=0 -oac lavc -lavcopts acodec=mp2:abitrate=128 "'+folderspec+'\\'+t.Name+'" -o "'+folderspec+'\\converted\\'+newName+'"'
               

                Return = WshShell.Run(temp,1,true)
               
                }
            if (!fso.FileExists(folderspec+"\\converted\\"+newName)) {fso.MoveFile (s, folderspec+"\\failed\\"+t.Name);fail++}
                else {fso.MoveFile (s, folderspec+"\\done\\"+t.Name);}
            }






   }

   
   return("Converted "+(i-fail)+" files.\nFailed "+fail+" files.");

}

function getFileExtension(n)
{
var p=n.split(".");
return p[p.length-1]
}

WshShell.Popup("NOTE: You must have AVIconverter installed!!\nThis is a little script to batch convert all the videofiles in this folder with mencoder. I wrote it for the archos 1.8 Vision mp3/mp4 player.\n After it is finished you will have 3 folders converted, done and failed. In converted are all your converted video files, in failed the original files that failed to convert and in done the original files that are succesfully converted.\n\nEnjoy...\n\nThe script will start after 40 seconds or when you press OK.",40,"Mencoder batch converter script",0)
WshShell.Popup(ShowFolderFileList(),0,"Mencoder batch converter script",0)

//2010 Maurice van Kruchten
  </script>


</job>


You can download the script here use save target as.
Copy it to your folder with the videofiles and double click it to run.
It will create 3 subfolders "converted, failed and done". After it is finished you will see a popup which will show you the amount of files failed and the amount of files successfully converted.
The script will support the following file extensions ".mpg .mp4 and .avi" You can however easily add other extensions in the script. I use it mainly to convert downloaded youtube vids in mp4 format.

Maurice 8)
Post Reply

Return to “Archos 2”