Image sequence
If your CG item is an image sequence and it's needed to define its playback speed, there is a property indicates how fast images will be switched.
Rate is nested in separated XML node <rate>:
<cg-item id='image-000'> <img path=c:\folderWithImages\*.*'/> <cg-props pos-x='36' pos-y='24' show='yes' move-type='accel-both' alpha='255' bg-color='Black(0)' pixel-ar='0.' play-mode='loop' interlace='auto' scale='fit-ar' align='top-left' width='300' height='200' pause='no' edges-smooth='0'> <indent left='0' right='0' top='0' bottom='0' use-for-bg='no'/> <group-indent left='0' right='0' top='0' bottom='0'/> </cg-props> <rate original='yes' speed='1.'/> </cg-item>
Rate node contains 2 attributes: original and speed.
To keep original playback rate (for example for a flash movie) you should set the original attribute to 'yes'. If it is 'no' - the item is updated according to source object playback rate.
To modify the speed of item refreshing you should set speed attribute. For example, to decrease frequency for image sequence you can set speed='0.1' - in this case, the image is updated on each 10 frame of the source object. By default playback rate is 1. It means that new frame from CG item should be received within each frame from the source object.
You can specify item rate from source code with the SetItemRate method. This method contains the following parameters:
- _bsItemID - identifier of item for which rate is set
- _bOriginalRate - indicates whether original rate is used ('1') or not ('0'). This parameter manipulates original attribute.
- _dblSpeed - item rate. This parameter manipulates speed attribute.
string myItemID = "myImageSequence"; int useOriginalRate = 1; double itemRate = 0.1; myCharGen.SetItemRate(myItemID, useOriginalRate, itemRate);
Video item
If your CG item is a video, the previous speed prop doesn't work for the item. Instead of it, you need to define the item open props (frame_get_props='rate=0.1') and add the CG item with that prop:
<ml-chargen>
<video-props colorspace='ARGB32' interlace='bottom' extra-buffer='1'/>
<video-output background='Black(0)' top-video='no'>
<input-rect left='0.000%' right='0.000%' top='0.000%' bottom='0.000%'/>
<output-rect left='0.000%' right='0.000%' top='0.000%' bottom='0.000%'/>
</video-output>
<cg-items>
<cg-item id='item-000' pos-x='0.000' pos-y='0.000' size-x='1' size-y='1'>
<img path='C:\Overlay.mov' in='0.0' out='0.0' frame_get_props='rate=0.1' border='0' color='white(255)'/>
<cg-props pos-x='0' pos-y='0' show='yes' move-type='accel-both' alpha='255' bg-color='Black(0)' pixel-ar='1.0' play-mode='loop' interlace='auto' scale='fit-ar' align='top-left' width='1920' height='1080' pause='no' edges-smooth='0'>
<indent left='0' right='0' top='0' bottom='0' use-for-bg='no'/>
<group-indent left='0' right='0' top='0' bottom='0'/>
</cg-props>
</cg-item>
</cg-items>
</ml-chargen>
You can also change the playback rate of the video CG item through the code:
string graphicsItemId = "item-000";
string propertyName = @"img::frame_get_props";
string propertyValue = @"rate=3.0";
int timeForChange = 0;
string changeType = "";
m_objCharGen.SetItemProperties(graphicsItemId, propertyName, propertyValue, changeType, timeForChange);
Important note! This parameter is added in the 2.10.0.14344 version of the SDK. This prop doesn't exist in the earlier versions of the Video SDK.
Since video CG items are based on MFReader, frame_get_props is _bsHints argument of .SourceFrameGet() method. So that, passing extra parameters into frame_get_props you can manipulate the frames of the video. For example, you can both speed up it and rotate → frame_get_props='rate=0.1 rotate=left'