3.7.5.99 VwVw-obj
LabTalk Object Type:
- External Object
The vw object does the following:
- Creates a video and set its file name, file path and video dimensions.
- Sets the compression method of the generated video and checks to see that the method is supported on the local computer.
- Adds a specified graph as one or more frames, to write the video.
Methods:
Method
|
Description
|
vw.Create(fileName, codec, framepersec, width, height)
|
Start creating a video with the specified file name (include complete file path), codec, frames per second (range from 0.001 to 120) and dimensions. Return value:
- 0:successful.
- Other values:failure and the value is the standard error code
|
vw.FourCC( )
|
Return the unique codec value from the four character code. The characters are case sensitive. For example: vw.FourCC('F', 'M', 'P', '4'). This value is used as the codec in vw.Create. See the FourCC Table for details.
|
vw.IsCodecInstalled(int codec)
|
Check whether the codec is supported on your computer. Return value:
- 0:The compression method is not supported on the computer.
- 1:The compression method is supported on the computer.
|
vw.WriteGraph(WindowName, numFrames)
|
Write a specified window to the video being created and, optionally, specify the number of frames. While generally intended for graph windows, the function works with workbooks, matrixbooks, graphs, function plots and layout windows. If the number of frames is not specified, then one frame is written. If WindowName is not specified, then the active window is written. Return value:
- 0:successful.
- Other values:failure and the value is the standard error code
|
vw.Release( )
|
Release the video writer and generate the video using previously chosen settings and the written frames. Return value:
|
Examples:
This script specifies a codec and checks to see that it is supported on the local computer. If not, the codec value is changed to 0, indicating no compression.
int codec = vw.FourCC('F','M','P','4'); //The compression method of MPEG4
if(vw.IsCodecInstalled(codec) == 0) //Check whether this compression method is supported
codec = 0; //If it's not supported.
//Showing whether a compression method is chosen
if(codec)
{
type "The compression method is MPEG4";
}
else
{
type "MPEG4 not supported, no compression is chosen";
}
The following script shows how to create a video with existing graphs.
//Create a video example.avi under d:\ disk use default settings.
int err = vw.Create(d:\example.avi);
//Write existing graphs into the video if the video can be created.
if(0 == err)
{
//Write specified graphs to video as one or more frames.
vw.WriteGraph(Graph1,3);//Add Graph1 as 3 frames
vw.WriteGraph(Graph2,2);//Add Graph2 as 2 frames
vw.WriteGraph(Graph3,1);//Add Graph3 as 1 frame
vw.WriteGraph( );//Add the active graph as 1 frame by default
}
//Release the video writer
vw.Release();
Note: the vw.Create( ) method does not have a default value for the first parameter: fileName. You need to specify it along with the full file path. Other parameters have default values: codec = 0 (no compression), framepersec = 1, width= 640, height=480. Also, each time you use the vw.Create( ) method, you must use vw.Release( ) to release the video writer before you use vw.Create( ) again. So you cannot, for example, change the codec, frame rate or video dimensions in a single file.
There is also a full example of how to create graph animation.
|