Please help with a basic script or .bat for a "simple" task in 2.6 Win64

Started by OzBrickie, February 24, 2013, 03:08:44 AM

Previous topic - Next topic

OzBrickie

I wonder if someone could help me with a script or batch file to convert .vob into .mkv in v2.6.1 Win64?

Basically I have a heap of music videos I ripped from a DVD into individual vobs.  I can convert them perfectly one at a time using these settings:

Open the file
The xxxx in decoder changes to lavcodec
Video codec "Copy"
Audio codec "Copy"
Output format "Mkv muxer" . No change to default in configure dialog.

I just want to convert all files in a folder, hopefully creating a file with .mkv and not .avi.mkv extension and maybe even place them in another folder although thats not a big issue in itself.

I have a little experience with scripts in 2.5 however I have no idea what to do in 2.6.

Any help would be greatly appreciated

Cheers
Johno

mean

It is a lightweight version of python
The following example will enable you to get all files in a folder with a given suffix
Then you can process them
There's small examples for every functions in the autononreg folder of avidemux source (no need to recompile anything)

print("Get folder content")
root="/work/samples/avi"
ext="avi"
list=get_folder_content(root,ext)
for i in list:
   print(">>"+i)
print("Done")

OzBrickie

Thanks mean

Unfortunately I am not sure what to do with that script.
I tried saving it in a text document with the .py extension and then running from the File-Run Script in the gui but nothing happens.
Also, I have looked in the source for what you suggested but until I figure out what to do I am afraid it is all just Greek to me.

Thanks for you patience with me, I may be a dumbarse but I learn quick  ;)

xpmule

i had a batch script i made before that converted everything from one folder to another
by setting the source and destination directories inside the script but i just checked and
it seems i deleted every one of my old scripts etc from Avidemux v2.5 :(
that sucks !

I take it that is what you want to do ?

I think i found the basis of my script by doing a google search a couple years ago..
you can convert old scripts to new ones pretty easily i think.. so far its been easy for me.

OzBrickie

Yeah but she don't work in 2.6 (see post#1) and 2.6 is a ball tearer IMHO
I modded it for what I wanted to do at the time however I haven't the foggiest what to do now. (See post #2)

If you reckon you can do it easy then knock yourself out mate. Anything so I don't need to do them one at a time.  ;) This script muxes way more than I need to BTW (see post #1 again)

//AD  <-
/*
  Simple script that scans the orgDir directory
  and loads all .xyz files and encodes them to Xvid+MP3 AVI (whatever, changed now by Oz to AC3)
  The resulting file is put in destDir directory

  Using new directorySearch API
*/
var app = new Avidemux ();
var ds = new DirectorySearch();
var srcDir;
var dstDir;
var reg = new RegExp(".$");
var extReg = new RegExp(".*[.](.+)$");

//this is the directory separator char for WINDOWS! for *nix, it should be: sep = "/";
var sep = "\\";
var fileExt;
var pickedExt;
var dstPath;

var filesDone = 0;
var filesSkip = 0;
var filesErrd = 0;

displayInfo("Pick any file in the source directory. All files of that type (.xyz) will be processed. Filename will be ignored but the file extension will be used! \r\n\r\ne.g. If you want to process AVIs, be sure to pick any .avi file!");

//pop up a dialog asking for a source file. We will remove the file name leaving just the dir
srcDir = fileReadSelect();

//run the extReg regex designed to pull out just the extension of this file
pickedExt = srcDir.replace(extReg, "$1").toLowerCase();

displayInfo(pickedExt + "Pick the destination directory and enter a random filename. Filename will be ignored");

//pop up a dialog asking for a destination file. We will remove the file name leaving just the dir
dstDir = fileWriteSelect();

//extract just the path part of each picked file
srcDir = pathOnly(srcDir);
dstDir = pathOnly(dstDir);

//if the path ends with a directory separator characters, remove them
//it shouldnt be more than one, but a while loop will cater for any number of them
//so c:\temp\\\\ becomes c:\temp
while(srcDir.charAt(srcDir.length-1) == sep){
  srcDir=srcDir.replace(reg,"");
}
while(dstDir.charAt(dstDir.length-1) == sep){
  dstDir=dstDir.replace(reg,"");
}

//initalise the directory search by telling it the directory
if(ds.Init(srcDir))
{
  //while we havent reached the end of the files list in the directory
  // --> note that every call to ds.NextFile() moves it on by one
  // --> until ds.NextFIle() returns false meaning it finished the list
  while(ds.NextFile())
  {
    //pull the filename out (no path)
    dstPath=ds.GetFileName();

    //only process valid files that are not directories
    if(!ds.isNotFile && !ds.isDirectory && !ds.isSingleDot && !ds.isDoubleDot)
    {
      //we want to do some work with the extension so pull it out now
      ext=ds.GetExtension();

      //is the extension of this file the same as the one we picked?
      if(ext.toLowerCase() == pickedExt)
      {
        //build the output file name. To avoid ovwriting source file, if dir is the same prefix a _       
        if(srcDir.toLowerCase() == dstDir.toLowerCase()){
          dstPath = dstDir + sep + "_" + ds.GetFileName() + ".avi";
        }else{
          dstPath = dstDir + sep + ds.GetFileName() + ".avi";
        }

        //build the source file path
        srcPath = srcDir + sep + ds.GetFileName();

        //we set this option first. If Avidemux loads a file it thinks need unpacking/time mapping
        //then setting this option now will ensure that operation is done when we load
        app.forceUnpack();

        //load the file. this action also purges all the video filters and codec settings
        app.load(srcPath);

        //see if the audio is VBR. if it is, this builds a time map. if it is not, this does nothing
        app.audio.scanVbr();

        //this might not need doing if forceUnpack has been stated. I dont think it can be done
        //twice though so its safe to repeat here
        app.rebuildIndex();

        //all the code in this section was generated by the app. if you want to write a script and use filters
        //you can get the app to do the hard work by:
        // load one of the files you will script
        // set all the video and audio options you want
        // on file menu, pick Save Project as (note: NOT save avi file!!)
        //the job file you save will have a section detailing the filters. copy it

        //re-encode to xvid 2 pass, bitrate = 1000 (plus 128 for audio = 1128 kbps, 507.6 megs per hour)
        //all options are set to simple, no GMC, no Qpel etc so that standalone simple players are ok
       

//** Filters **
app.video.addFilter("telecide","order=1","back=0","chroma=0","guide=1","gthresh=10.000000","post=0","vthresh=50.000000","bthresh=50.000000","dthresh=7.000000","blend=0","nt=10","y0=0","y1=0","hints=1","show=0","debug=0");

//** Video Codec conf **
app.video.codecPlugin("92B544BE-59A3-4720-86F0-6AD5A2526FD2", "Xvid", "CQ=2", "<?xml version='1.0'?><XvidConfig><XvidOptions><threads>0</threads><vui><sarAsInput>true</sarAsInput><sarHeight>1</sarHeight><sarWidth>1</sarWidth></vui><motionEstimation>high</motionEstimation><rdo>dct</rdo><bFrameRdo>false</bFrameRdo><chromaMotionEstimation>true</chromaMotionEstimation><qPel>false</qPel><gmc>false</gmc><turboMode>false</turboMode><chromaOptimiser>false</chromaOptimiser><fourMv>false</fourMv><cartoon>false</cartoon><greyscale>false</greyscale><interlaced>none</interlaced><frameDropRatio>0</frameDropRatio><maxIframeInterval>300</maxIframeInterval><maxBframes>2</maxBframes><bFrameSensitivity>0</bFrameSensitivity><closedGop>false</closedGop><packed>false</packed><quantImin>1</quantImin><quantPmin>1</quantPmin><quantBmin>1</quantBmin><quantImax>31</quantImax><quantPmax>31</quantPmax><quantBmax>31</quantBmax><quantBratio>150</quantBratio><quantBoffset>100</quantBoffset><quantType>h.263</quantType><intraMatrix><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value><value>8</value></intraMatrix><interMatrix><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value><value>1</value></interMatrix><trellis>true</trellis><singlePass><reactionDelayFactor>16</reactionDelayFactor><averagingQuantiserPeriod>100</averagingQuantiserPeriod><smoother>100</smoother></singlePass><twoPass><keyFrameBoost>10</keyFrameBoost><maxKeyFrameReduceBitrate>20</maxKeyFrameReduceBitrate><keyFrameBitrateThreshold>1</keyFrameBitrateThreshold><overflowControlStrength>5</overflowControlStrength><maxOverflowImprovement>5</maxOverflowImprovement><maxOverflowDegradation>5</maxOverflowDegradation><aboveAverageCurveCompression>0</aboveAverageCurveCompression><belowAverageCurveCompression>0</belowAverageCurveCompression><vbvBufferSize>0</vbvBufferSize><maxVbvBitrate>0</maxVbvBitrate><vbvPeakBitrate>0</vbvPeakBitrate></twoPass></XvidOptions></XvidConfig>");

//** Audio **
app.audio.reset();
app.audio.codec("Aften",384,8,"80 01 00 00 00 00 00 00 ");
app.audio.normalizeMode=1;
app.audio.normalizeValue=0;
app.audio.delay=0;
app.audio.mixer="NONE";
app.setContainer("AVI");

        //write that file
        app.save(dstPath);

      } else{ //we decide not to process this file
        //some diagnostic info incase you wonder why a whole dir of files arent processing
        whyNot = dstPath + " wasnt processed because: ";
        if(ds.isNotFile)
          whyNot += "it is not a file, ";
        if(ds.isDirectory)
          whyNot += "it is a directory, ";
        if(ds.isHidden)
          whyNot += "it is hidden, ";
        if(ds.isArchive)
          whyNot += "it is marked for archive, ";
        if(ds.isSingleDot)
          whyNot += "it is a meta-ref to the current dir (.), ";
        if(ds.isDoubleDot)
          whyNot += "it is a meta-ref to the parent dir (..), ";

        //whats that reason now? 
        print(whyNot);
      }
    }
  }
  ds.Close();
}


Alternatively help me to get means' suggestion to work.

Cheers
Oz

DÅ‚ugosz

BTW, I just tried saving a project, and the file did not begin with //AD.  I was looking for how to run the file again after I created it, and the docs only show examples of creating one by hand, not how to make it work (on Windows) once you have one by any means.