Log in

View Full Version : Question about scripting (VD)


mikeathome
3rd February 2003, 16:56
Hi,

I emailed the author twice, never receive an answer, pls. help me !

The following script:
// $script

declare framesAVS;
declare framesVOB;
declare framerate;

VirtualDub.Open("d:\\tmp\\Vts_01_V01C__.vob", 0, 0);
framerate=VirtualDub.video.GetFrameRate(0);
Sylia.dprint("Framerate: ",framerate,"\n");
framesVOB=VirtualDub.video.GetRange(0);
Sylia.dprint("Number of Frames in VOB: ",framesVOB,"\n");
VirtualDub.Close();
VirtualDub.Open("d:\\tmp\\Vts_01_V01C__.avs", 0, 0);
framesAVS=VirtualDub.video.GetRange(0);
Sylia.dprint("Number of frames in AVS: ",framesAVS,"\n");
VirtualDub.Close();
Sylia.dprint("DVD2AVI missed frames: ",framesVOB-framesAVS,"\n");

// $endjob


delivers:

Framerate: 0
Number of frames in VOB: 0
Number of frames in AVS: 0
DVD2AVI missed frames: 0

Drives me crazy...
What ever I try alwys '0' even the scriptversion:

declare frames;
frames = VirtualDub.video;
Sylia.dprint(frames.GetRange(0));

delivers something odd but not the number of frames.
I use the special VD version with direct VOB support. I get the right number of frames in the File/Information dialog.

I changed the object.cpp:
#include <windows.h>
#include <stdio.h>

#include "ScriptInterpreter.h"
#include "ScriptValue.h"
#include "ScriptError.h"

static void func_Sylia_dprint(IScriptInterpreter *, CScriptObject *, CScriptValue *argv, int argc) {
char lbuf[12];

while(argc--) {
if (argv->isInt()) {
wsprintf(lbuf, "%ld", argv->asInt());
OutputDebugString(lbuf);
printf(lbuf);
} else if (argv->isString()) {
OutputDebugString(*argv->asString());
printf(*argv->asString());
} else
SCRIPT_ERROR(TYPE_INT_REQUIRED);

++argv;
}
}

static ScriptFunctionDef objFL_Sylia[]={
{ (ScriptFunctionPtr)func_Sylia_dprint, "dprint", "0." },
{ NULL }
};

CScriptObject obj_Sylia={
NULL,
objFL_Sylia
};

This enables output of the Sylia.dprint function to stdout where you can redirect it into a file.

Why I am doing this, ok, I am working on an automatic solution for correcting the DVD2AVI projects wrong framecount. I have already a reliable patch solution, only missing is an automatic framecount function.

Suiryc
3rd February 2003, 18:39
The GetRange(int index) function doesn't work like you think.
This function returns the starting offset (in ms) of your selection when using index=0. And it returns the ending offset otherwise.
However the ending offset is the time between the end of your selection and the end of the clip.
In other words when opening a file you will always get 0 with this function (because the selection is the whole clip).

Unfortunately there is no function returning the number of frames in the clip.

mikeathome
4th February 2003, 10:13
Originally posted by Suiryc
The GetRange(int index) function doesn't work like you think.
This function returns the starting offset (in ms) of your selection when using index=0. And it returns the ending offset otherwise.
However the ending offset is the time between the end of your selection and the end of the clip.
In other words when opening a file you will always get 0 with this function (because the selection is the whole clip).

Unfortunately there is no function returning the number of frames in the clip.

Ok, thx. for the answer.
Why does the Framerate is always reported as 0 ?
I am desparately looking for a tool which can give me the numbers of frames from a clip (be a VOB and be a AVS) onto the stdout. I am working on a solution to correct the DVD2AVI frame count issue. The CLI version of DVD2AVI gives back wrong number of frames so does Ver. 1.76 only 1-5 frames missing but this causes a de-sync when authoring by VobID. In the moment the frame count'n'compare is the only manual job in the procedure, what a nightmare with titles >40 VobIDs...

mike

Suiryc
4th February 2003, 18:10
Originally posted by mikeathome
Why does the Framerate is always reported as 0 ?
GetFrameRate(int index) will return :
- frameRateDecimation (so 0 if you don't use rate decimation) for index=0
- frameRateNewMicroSecs (the number of microseconds a frame last) for index=1
- fInvTelecine (if Inverse Telecine is selected, so 0 when opening a clip) for index=2

What you want is 1000000/GetFrameRate(1) = FrameRate (I think this is the correct one).

mikeathome
5th February 2003, 09:18
@Suiryc:

Thanks for your help. So I would need to find a workarround for the GetRange or a similar framecount function, I'll try to find something. If you folks get an idea in the meantime I would highly appreciate if you could share that with me.

regards, mike

mikeathome
10th February 2003, 11:17
Hello,

status report, it works !
This:
// $script

declare framesAVS;
declare framesVOB;
declare framesAVSms;
declare framesVOBms;
declare framerate;

VirtualDub.Open("e:\\matrix\\Vts_02_V02C__.vob", 0, 0);
framesVOBms=VirtualDub.video.GetRange(2);
framesVOB=VirtualDub.video.GetRange(3);
Sylia.dprint("\n\nFrames im VOB [ms]:",framesVOBms,"\n");
Sylia.dprint("Frames im VOB:",framesVOB,"\n");
VirtualDub.Close();
VirtualDub.Open("e:\\matrix\\Vts_02_V02C__.avs", 0, 0);
framerate=VirtualDub.video.GetFrameRate(3)/1000;
Sylia.dprint("Framerate [fps]:",framerate,"\n");
framesAVSms=VirtualDub.video.GetRange(2);
framesAVS=VirtualDub.video.GetRange(3);
Sylia.dprint("Frames im AVS [ms]:",framesAVSms,"\n");
Sylia.dprint("Frames im AVS:",framesAVS,"\n");
VirtualDub.Close();
Sylia.dprint("Fehlende Frames:",framesVOB-framesAVS,"\n");

// $endjob

delivers this:

Frames im VOB [ms]: 173080
Frames im VOB: 4327
Framerate [fps]: 25
Frames im AVS [ms]: 172920
Frames im AVS: 4323
Fehlende Frames: 4


Exactly as I wanted it. I added a few lines in VD source code, recompiled and it worked...

mike

ChristianHJW
11th February 2003, 10:14
Originally posted by mikeathome
Exactly as I wanted it. I added a few lines in VD source code, recompiled and it worked...

Pls. send the mod to suiryc at matroska dot org .. we may have a look at adding that ...

mikeathome
11th February 2003, 12:44
Originally posted by ChristianHJW
Pls. send the mod to suiryc at matroska dot org .. we may have a look at adding that ...

... sent

regards, mike