
onMetaData
Description
This event occurs at time zero and provides general FLV information.
Note: Other software may also add this event.
Captionate will add the event if it doesn't exist. If it is present, Captionate will preserve it
and update the values it knows about and calculates.
Parameters
metadata(Object)
The metadata object has the following properties:
- duration (Number): Length of the FLV in seconds. Captionate computes this value.
This is the timestamp of the last tag, plus the duration of the last audio tag taken into account.
- lasttimestamp (Number): This is the TimeStamp of the last tag in the FLV.
(NetStream.Time will not return the duration, or the actual time as one might expect. It returns the position of the PlayHead which can only be a timestamp in the FLV file. So, lasttimestamp value is useful for detecting the end of the FLV more than the duration value).
- lastkeyframetimestamp (Number): The timestamp value of the last video key frame. This info might be needed because seeking a frame after this time usually does not work.
- width (Number): Width of the video in pixels.
- height (Number): Height of the video in pixels.
- videodatarate (Number): Captionate does not compute this value. If not present Captionate uses 0.
- audiodatarate (Number): Captionate does not compute this value. If not present Captionate uses 0.
- framerate (Number): Frames per second value. Captionate computes this value.
- creationdate (String): Captionate cannot compute this value. If not present Captionate uses 'unknown'.
- filesize (Number): File size in bytes (including all the injected data).
- videosize (Number): Total size of video tags in the file in bytes.
- audiosize (Number): Total size of audio tags in the file in bytes.
- datasize (Number): Total size of data tags in the file in bytes.
- metadatacreator (String): Set to 'Manitu Group Captionate 2.0'. (Note, this string will remain the same until Captionate version 3.0).
- metadatadate (Date): Date and time metadata added. (Note that this is not of type string like 'creationdate').
- audiocodecid (Number): Audio codec ID used in the FLV. (Captionate uses the first audio tag with non-zero data size for this value). Possible values are 0: Uncompressed, 1: ADPCM, 2: MP3, 5: Nellymoser 8kHz Mono, 6: Nellymoser.
- videocodecid (Number): Video codec ID used in the FLV (Captionate uses the first video tag for this value). Possible values are 2: Sorenson H.263, 3: Screen Video, 4: On2 VP6, 5: On2 VP6 with Transparency.
- audiodelay (Number): The delay introduced by the audio codec, in seconds. During encoding, other tags in the FLV are shifted by the same amount, in order to ensure accurate audio/video synchronization. Captionate calculates this value from the difference in time values of the the first audio tag and first video tag.
- canSeekToEnd (Boolean): Indicates whether the last video frame is a key frame or not.
- cuePoints (Array) : Lists all the cue points in the FLV. This is an array of objects which duplicate the information in the cue points and each object has the same properties: name, time, type and parameters. Captionate has an option for not saving 'event' type cue points into this array. See FLV Information Dialog, Metadata tab.
- keyframes (Object) : This object is added only if you select the option in FLV Information Dialog, Metadata tab.
'keyframes' object has 2 arrays: 'filepositions' and 'times'. Both arrays have the same number of elements, which is equal to the number of key frames in the FLV. Values in times array are in 'seconds'. Each correspond to the timestamp of the n'th key frame. Values in filepositions array are in 'bytes'. Each correspond to the fileposition of the nth key frame video tag (which starts with byte tag type 9).
- custommetadata (Object) : This object is added only if you select the option in FLV Information Dialog, Metadata tab.
'custommetadata' holds an associative array of name:value pair strings.
Example
nets.onMetaData = function(metadata){
trace('onMetaData event at '+nets.time);
trace(' duration: '+metadata.duration+newline+
' lasttimestamp: '+metadata.lasttimestamp+newline+
' lastkeyframetimestamp: '+metadata.lastkeyframetimestamp+newline+
' width: '+metadata.width+newline+
' height: '+metadata.height+newline+
' videodatarate: '+metadata.videodatarate+newline+
' audiodatarate: '+metadata.audiodatarate+newline+
' framerate: '+metadata.framerate+newline+
' creationdate: '+metadata.creationdate+newline+
' filesize: '+metadata.filesize+newline+
' videosize: '+metadata.videosize+newline+
' audiosize: '+metadata.audiosize+newline+
' datasize: '+metadata.datasize+newline+
' metadatacreator: '+metadata.metadatacreator+newline+
' metadatadate: '+metadata.metadatadate
);
trace(' audiocodecid: '+metadata.audiocodecid+newline+
' videocodecid: '+metadata.videocodecid+newline+
' audiodelay: '+metadata.audiodelay+newline+
' canseektoend: '+metadata.canSeekToEnd);
trace(' cuePoints:');
for (n=0; n<metadata.cuePoints.length; n++) {
cp = metadata.cuePoints[n];
trace(' '+cp.time+' "'+cp.name+'" ('+cp.type+')');
if (cp.parameters != undefined) {
trace(' parameters: ');
for (paramName in cp.parameters) {
trace(' "'+paramName+'" = "'+cp.parameters[paramName]+'"');
}
}
}
trace(' custommetadata:');
for (paramName in metadata.custommetadata) {
trace(' "'+paramName+'" = "'+metadata.custommetadata[paramName]+'"');
}
trace(' keyframes:');
fp=metadata.keyframes.filepositions;
ti=metadata.keyframes.times;
for (n=0; n<fp.length; n++){
trace(' fileposition: '+fp[n]+' time: '+ti[n]);
}
}
Example 2
nets.onMetaData = function(metadata){
var level;
function levelStr(level){
s='';
for (n=0;n<level;n++){s=s+' '};
return(s);
}
function traceThis(x){
level++;
for (y in x){
switch (typeof(x[y])) {
case 'object':
trace(levelStr(level)+y+' : ');
traceThis(x[y]);
break;
default:
trace(levelStr(level)+y+' = '+x[y]);
break;
}
}
level--;
}
level=0;
traceThis(metadata);
}
See also
onLastSecond, onCuePoint