createMetadataType

Create a VidiCore MetadataType from a simplified object structure

createMetadataType
Parameters
metadata (object = {}) object to create MetadataType from
Returns
object: a MetadataType object

parseMetadataType

Parses MetadataType according to specified options. The attributes can be targeted for each sub-type.

parseMetadataType
Parameters
metadataType (Object = {}) A MetadataType from VidiCore.
options (Object = {}) Options which change how the metadataType is parsed.
Name Description
options.joinValue string String to join the values, eg ','.
options.includeAttributes boolean Include attributes on all objects.
options.includeMetadataAttributes boolean Include attributes on root.
options.includeTimespanAttributes boolean Include attributes on timespans.
options.includeGroupAttributes boolean Include attributes on groups.
options.includeFieldAttributes boolean Include attributes on fields.
options.includeValueAttributes boolean Include attributes on values.
options.flat boolean Flatten to key/value (Note: keys may be overwritten).
options.flatTimespan boolean Flatten timespan.
options.flatGroup boolean Flatten group.
options.sortTimespan boolean Sort timespan by start time.
options.timespanAsList boolean Return timespans as list.
options.groupAsList boolean Return groups as list.
options.fieldAsList boolean Return fields as list.
options.arrayOnSingle boolean (default true) Return fields as array even if single field.
options.arrayOnSingleValue boolean (default true) Return fields as array even if single field value.
Returns
Object: Metadata object parsed according to options.

parseTimespanList

Parses timespanList according to specified options. The attributes can be targeted for each sub-type.

parseTimespanList
Parameters
timespanList (Array<Object> = []) A timespanList from VidiCore.
options (Object = {}) Options which change how the metadataType is parsed.
Name Description
options.joinValue string String to join the values, eg ','.
options.includeAttributes boolean Include attributes on all objects.
options.includeMetadataAttributes boolean Include attributes on root.
options.includeTimespanAttributes boolean Include attributes on timespans.
options.includeGroupAttributes boolean Include attributes on groups.
options.includeFieldAttributes boolean Include attributes on fields.
options.includeValueAttributes boolean Include attributes on values.
options.flat boolean Flatten to key/value (Note: keys may be overwritten).
options.flatTimespan boolean Flatten timespan.
options.flatGroup boolean Flatten group.
options.sortTimespan boolean Sort timespan by start time.
options.timespanAsList boolean Return timespans as list.
options.groupAsList boolean Return groups as list.
options.fieldAsList boolean Return fields as list.
options.arrayOnSingle boolean (default true) Return fields as array even if single field.
options.arrayOnSingleValue boolean (default true) Return fields as array even if single field value.
Returns
Object: Metadata object parsed according to options.

parseTimespan

Parses timespan according to specified options. The attributes can be targeted for each sub-type.

parseTimespan
Parameters
timespan (Object = {}) A timespan from VidiCore.
options (Object = {}) Options which change how the metadataType is parsed.
Name Description
options.joinValue string (default undefined) String to join the values, eg ','.
options.includeAttributes boolean (default false) Include attributes on all objects.
options.includeTimespanAttributes boolean (default false) Include attributes on timespans.
options.includeGroupAttributes boolean (default false) Include attributes on groups.
options.includeFieldAttributes boolean (default false) Include attributes on fields.
options.includeValueAttributes boolean (default false) Include attributes on values.
options.flat boolean (default false) Flatten to key/value (Note: keys may be overwritten).
options.flatTimespan boolean (default false) Flatten timespan.
options.flatGroup boolean (default false) Flatten group.
options.groupAsList boolean (default false) Return groups as list.
options.fieldAsList boolean (default false) Return fields as list.
options.arrayOnSingle boolean (default true) Return fields as array even if single field.
options.arrayOnSingleValue boolean (default true) Return fields as array even if single field value.
Returns
Object: Metadata object parsed according to options.

parseHighlightTimespanList

Parses highlight timespans from VidiCore into key/value object. The attributes can be targeted for each sub-type.

parseHighlightTimespanList
Parameters
highlightTimespanList (Object = []) A list of timespans from VidiCore.
options (Object = {}) Options which change how the timespans are parsed.
Name Description
options.arrayOnSingle boolean (default true) Return an array if there is a single value.
options.joinValue string String to join the values, eg ','.
options.timespanAsList boolean (default false) Return timespans as list.
options.flat boolean (default false) Flatten to field-name/field-value (Note: field-values may be overwritten).
options.flatTimespan boolean (default false) Flatten timespan to object with start/end as key.
options.joinTimespan string (default _) Character to join the start/end timecodes.

parseHighlightTimespan

Parses highlight timespan in VidiCore into key/value object. The attributes can be targeted for each sub-type.

parseHighlightTimespan
Parameters
highlightTimespan (Array<Object> = {}) A VidiCore timespan object.
Name Description
highlightTimespan.field any (default [])
highlightTimespan.start any
highlightTimespan.end any
options (Object = {}) Options which change how the timespans are parsed.
Name Description
options.arrayOnSingle boolean (default true) Return an array if there is a single value.
options.timespanAsList boolean (default false) Return timespans as list.
options.joinValue string String to join the values, eg ','.

metadataTypeToWebVtt

Convert subtitle groups to WebVtt subtitle format

metadataTypeToWebVtt
Parameters
input (Object = {})
Name Description
input.metadataType Object MetadataType response from API.
input.subtitleGroup string (default stl_subtitle) Name of group containing subtitle field/text.
input.subtitleField string (default stl_text) Name of field (text) to use for the subtitles.
Returns
string: WebVtt subtitles

TimeBase

TimeBase class representing the TimeBaseType in VidiCore

For more info, see the Time bases section in VidiCore API Docs

new TimeBase(timeCodeType: object)
Parameters
timeCodeType (object = {}) A time base type object
Instance Members
toConstant()
toText(options)
toRate(options)
toObject()
toJson()

createTimeBase

Create a TimeBase Instance from a string or object representation of a time base

createTimeBase
Parameters
timeBase ((string | object)) Expressed as "denominator:numerator" or { numerator, denominator }
Returns
TimeBase: A TimeBase instance

formatTimeBaseText

Format a string representation of a time base to a TimeBase Instance

formatTimeBaseText
Parameters
timeBaseText (string) The string to format to a TimeBase instance
Returns
TimeBase: A TimeBase Instance

formatTimeBaseType

Create a TimeBase instance of an object

formatTimeBaseType
Parameters
timeBase (object) A TimeBase object ({ numerator, denominator })
Returns
TimeBase: A TimeBase instance

TimeCode

TimeCode class representing the TimeCodeType in VidiCore

For more info, see the Time Codes section of VidiCore API Docs

new TimeCode(timeCodeType: object, options: object)
Parameters
timeCodeType (object = {}) Object to create TimeCode of
options (object = {}) Options for the timeCode
Instance Members
add(timeCodeType)
subtract(timeCodeType)
conformTimeBase(conformTo)
toText(options)
toUnits()
toTime()
toSeconds()
toDuration(options)
toSmpte()
toObject()
toJson()

createTimeCode

Create a TimeCode instance from smpte, seconds/samples, timeCode object or string

createTimeCode
Parameters
timeCode ((object | string | number)) Smpte, seconds/samples, timeCode object or string
options (object = {}) For the format functions
Returns
TimeCode: A TimeCode instance

formatTimeCodeText

Format text to a TimeCode instance

formatTimeCodeText
Parameters
timeCodeText (string) A time code text (e.g. "25@PAL")
options (object = {}) Options for how to format
Name Description
options.timeBase (object | string) The time base the returned TimeCode should have
Returns
TimeCode: A TimeCode instance

formatTimeCodeType

Format an object to a TimeCode instance

formatTimeCodeType
Parameters
timeCode (object) To create TimeCode instance of
options (object) For the TimeCode constructor
Returns
TimeCode: A TimeCode instance

formatTimeCodeSeconds

Format seconds to TimeCode object Input time base is always 1:1 since it expects seconds as input

Note: Max 15 digits accuracy (double precision float64), e.g.

  • 10^6 seconds can have 10^9 decimals (nanosecond) precision
  • 10^9 seconds can have 10^6 decimals (microsecond) precision
  • 10^12 seconds can have 10^3 decimals (millisecond) precision
formatTimeCodeSeconds
Parameters
seconds ((string | number)) With or without decimals ("." and "," are both interpreted as decimal)
options (object = {}) Options for how to format the seconds to a TimeCode
Name Description
options.timeBase (object | string) What TimeBase the resulting TimeCode should have (if unset and useGCD=false, denominator will be 10^ )
options.useGCD boolean (default false) Samples and denominator are divided with GCD (ignored if timeBase is set) (e.g. 1.04 => 104@100 => 26@25)
Returns
TimeCode: A TimeCode instance

formatTimeCodeSmpte

Format smpte text to a TimeCode Instance

exceedingMode:

  • "overflow" exceeding values will be kept (e.g. PAL and 00:00:00:25 => 00:00:01:00)
  • "truncate" exceeding values will be truncated (e.g. PAL and 00:00:00:25 => 00:00:00:24)
  • "error" exceeding values will throw error (e.g. PAL and 00:00:00:25 => Error)
formatTimeCodeSmpte
Parameters
smpte (string) String representation of smpte
options (object = {}) What options to use for creating the time code from smpte (all not specified below are passed to the TimeCode constructor)
Name Description
options.timeBase (object | string | number) TimeBase of smpte (and consequently TimeBase of output TimeCode)
options.exceedingMode string (default error) How to handle exceeding values ( overflow|truncate|error )
options.dropFrame boolean If it should parse and create time code using dropFrame
options.frameSeparator string What frame separator the TimeCode should store (defaults to what the smpte has)
Returns
TimeCode: A TimeCode instance