@vidispine/vdt-js 22.3.0-pre.5 → 22.3.1-pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +1280 -614
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1287 -619
- package/dist/index.js.map +1 -1
- package/package.json +26 -25
package/dist/index.es.js
CHANGED
|
@@ -7,9 +7,28 @@ import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
|
7
7
|
import _createClass from '@babel/runtime/helpers/createClass';
|
|
8
8
|
import parseFileSize from 'filesize';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
var gcd = function gcd(a, b) {
|
|
11
|
+
return b ? gcd(b, a % b) : a;
|
|
12
|
+
};
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
var parseAspectRatio = function parseAspectRatio(_ref) {
|
|
15
|
+
var width = _ref.width,
|
|
16
|
+
height = _ref.height;
|
|
17
|
+
var denominator = gcd(width, height);
|
|
18
|
+
var widthRatio = width / denominator;
|
|
19
|
+
var heightRatio = height / denominator;
|
|
20
|
+
|
|
21
|
+
if (widthRatio > 21) {
|
|
22
|
+
heightRatio = 1;
|
|
23
|
+
widthRatio = (width / height).toFixed(2);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return [widthRatio, heightRatio].join(':');
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function ownKeys$b(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
30
|
+
|
|
31
|
+
function _objectSpread$b(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$b(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$b(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
13
32
|
|
|
14
33
|
var parseKeyValuePairType = function parseKeyValuePairType() {
|
|
15
34
|
var keyValuePairType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
@@ -17,7 +36,7 @@ var parseKeyValuePairType = function parseKeyValuePairType() {
|
|
|
17
36
|
var keyValuePairTypeReducer = function keyValuePairTypeReducer(a, _ref) {
|
|
18
37
|
var key = _ref.key,
|
|
19
38
|
value = _ref.value;
|
|
20
|
-
return _objectSpread$
|
|
39
|
+
return _objectSpread$b(_objectSpread$b({}, a), {}, _defineProperty({}, key, value));
|
|
21
40
|
};
|
|
22
41
|
|
|
23
42
|
return keyValuePairType.reduce(keyValuePairTypeReducer, {});
|
|
@@ -244,19 +263,19 @@ var roles = /*#__PURE__*/Object.freeze({
|
|
|
244
263
|
VXA_READ: VXA_READ
|
|
245
264
|
});
|
|
246
265
|
|
|
247
|
-
var _excluded$
|
|
266
|
+
var _excluded$8 = ["value"],
|
|
248
267
|
_excluded2$2 = ["start", "end"];
|
|
249
268
|
|
|
250
|
-
function ownKeys$
|
|
269
|
+
function ownKeys$a(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
251
270
|
|
|
252
|
-
function _objectSpread$
|
|
271
|
+
function _objectSpread$a(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$a(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$a(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
253
272
|
|
|
254
273
|
var COMBINED_PROPERTY_KEYS = ['uuid', 'user', 'timestamp', 'change', 'conflict', 'mode', 'name', 'id', 'referenced', 'data', 'inheritance'];
|
|
255
274
|
var GROUP_PROPERTY_KEYS = [].concat(COMBINED_PROPERTY_KEYS, ['cycle']);
|
|
256
275
|
var FIELD_PROPERTY_KEYS = [].concat(COMBINED_PROPERTY_KEYS, ['value', 'reference', 'type', 'track']);
|
|
257
276
|
var FIELD_VALUE_PROPERTY_KEYS = [].concat(COMBINED_PROPERTY_KEYS, ['value', 'lang']);
|
|
258
277
|
|
|
259
|
-
var isObject = function isObject(o) {
|
|
278
|
+
var isObject$1 = function isObject(o) {
|
|
260
279
|
return Object.prototype.toString.call(o) === '[object Object]';
|
|
261
280
|
};
|
|
262
281
|
|
|
@@ -272,7 +291,7 @@ var isField = function isField(value) {
|
|
|
272
291
|
};
|
|
273
292
|
|
|
274
293
|
var isFieldObject = function isFieldObject(v) {
|
|
275
|
-
return isObject(v) && (v.value === null || isObject(v.value) || isFieldType(v.value));
|
|
294
|
+
return isObject$1(v) && (v.value === null || isObject$1(v.value) || isFieldType(v.value));
|
|
276
295
|
};
|
|
277
296
|
|
|
278
297
|
if (value === null) {
|
|
@@ -288,7 +307,7 @@ var isField = function isField(value) {
|
|
|
288
307
|
|
|
289
308
|
var isGroup = function isGroup(value) {
|
|
290
309
|
var isGroupObject = function isGroupObject(v) {
|
|
291
|
-
return isObject(v) && v.value === undefined && Object.entries(value);
|
|
310
|
+
return isObject$1(v) && v.value === undefined && Object.entries(value);
|
|
292
311
|
};
|
|
293
312
|
|
|
294
313
|
if (Array.isArray(value)) {
|
|
@@ -334,13 +353,13 @@ var parseValueObject = function parseValueObject(valueObject) {
|
|
|
334
353
|
}
|
|
335
354
|
|
|
336
355
|
var parsedValue = parseValue(valueObject === null || valueObject === void 0 ? void 0 : valueObject.value);
|
|
337
|
-
return _objectSpread$
|
|
356
|
+
return _objectSpread$a(_objectSpread$a({}, valueObject), parsedValue !== undefined ? parsedValue : {});
|
|
338
357
|
};
|
|
339
358
|
|
|
340
359
|
var parseFieldValue = function parseFieldValue(value) {
|
|
341
360
|
if ([undefined, null].includes(value)) return undefined;
|
|
342
361
|
if (Array.isArray(value)) return value.map(parseFieldValue);
|
|
343
|
-
if (isObject(value)) return parseValueObject(value);
|
|
362
|
+
if (isObject$1(value)) return parseValueObject(value);
|
|
344
363
|
return parseValue(value);
|
|
345
364
|
};
|
|
346
365
|
|
|
@@ -350,18 +369,18 @@ var parseFieldObject = function parseFieldObject(fieldObject) {
|
|
|
350
369
|
|
|
351
370
|
if (parsedFieldValue === undefined) {
|
|
352
371
|
fieldObject.value;
|
|
353
|
-
var fieldObjectWithoutValue = _objectWithoutProperties(fieldObject, _excluded$
|
|
372
|
+
var fieldObjectWithoutValue = _objectWithoutProperties(fieldObject, _excluded$8);
|
|
354
373
|
|
|
355
374
|
return fieldObjectWithoutValue;
|
|
356
375
|
}
|
|
357
376
|
|
|
358
|
-
return _objectSpread$
|
|
377
|
+
return _objectSpread$a(_objectSpread$a({}, fieldObject), {}, {
|
|
359
378
|
value: _toConsumableArray(Array.isArray(parsedFieldValue) ? parsedFieldValue : [parsedFieldValue])
|
|
360
379
|
});
|
|
361
380
|
};
|
|
362
381
|
|
|
363
382
|
var parseField$1 = function parseField(field) {
|
|
364
|
-
if (isObject(field)) {
|
|
383
|
+
if (isObject$1(field)) {
|
|
365
384
|
return parseFieldObject(field);
|
|
366
385
|
}
|
|
367
386
|
|
|
@@ -386,10 +405,10 @@ var parseGroupsAndFields = function parseGroupsAndFields(groupOrField) {
|
|
|
386
405
|
value = _ref2[1];
|
|
387
406
|
|
|
388
407
|
if (GROUP_PROPERTY_KEYS.includes(name)) {
|
|
389
|
-
groupAttributes = _objectSpread$
|
|
408
|
+
groupAttributes = _objectSpread$a(_objectSpread$a({}, groupAttributes), {}, _defineProperty({}, name, value));
|
|
390
409
|
} else if (isField(value)) {
|
|
391
410
|
try {
|
|
392
|
-
field.push(_objectSpread$
|
|
411
|
+
field.push(_objectSpread$a({
|
|
393
412
|
name: name
|
|
394
413
|
}, parseField$1(value)));
|
|
395
414
|
} catch (error) {
|
|
@@ -397,7 +416,7 @@ var parseGroupsAndFields = function parseGroupsAndFields(groupOrField) {
|
|
|
397
416
|
}
|
|
398
417
|
} else if (isGroup(value)) {
|
|
399
418
|
(Array.isArray(value) ? value : [value]).forEach(function (v) {
|
|
400
|
-
group.push(_objectSpread$
|
|
419
|
+
group.push(_objectSpread$a({
|
|
401
420
|
name: name
|
|
402
421
|
}, parseGroupsAndFields(v)));
|
|
403
422
|
});
|
|
@@ -405,7 +424,7 @@ var parseGroupsAndFields = function parseGroupsAndFields(groupOrField) {
|
|
|
405
424
|
throw Error("Unhandled value for \"".concat(name, "\""));
|
|
406
425
|
}
|
|
407
426
|
});
|
|
408
|
-
return _objectSpread$
|
|
427
|
+
return _objectSpread$a(_objectSpread$a(_objectSpread$a({}, groupAttributes), group.length > 0 ? {
|
|
409
428
|
group: group
|
|
410
429
|
} : {}), field.length > 0 ? {
|
|
411
430
|
field: field
|
|
@@ -426,7 +445,7 @@ var parseTimespan$1 = function parseTimespan() {
|
|
|
426
445
|
group = _parseGroupsAndFields.group,
|
|
427
446
|
field = _parseGroupsAndFields.field;
|
|
428
447
|
|
|
429
|
-
return _objectSpread$
|
|
448
|
+
return _objectSpread$a(_objectSpread$a(_objectSpread$a({}, group ? {
|
|
430
449
|
group: group
|
|
431
450
|
} : {}), field ? {
|
|
432
451
|
field: field
|
|
@@ -436,10 +455,10 @@ var parseTimespan$1 = function parseTimespan() {
|
|
|
436
455
|
});
|
|
437
456
|
};
|
|
438
457
|
/**
|
|
439
|
-
* Create a MetadataType
|
|
458
|
+
* Create a VidiCore MetadataType from a simplified object structure
|
|
440
459
|
*
|
|
441
|
-
* @param {
|
|
442
|
-
* @returns {
|
|
460
|
+
* @param {object} metadata - object to create MetadataType from
|
|
461
|
+
* @returns {object} a MetadataType object
|
|
443
462
|
*/
|
|
444
463
|
|
|
445
464
|
|
|
@@ -475,13 +494,13 @@ var sortTimespanList = function sortTimespanList(timespan1, timespan2) {
|
|
|
475
494
|
return 0;
|
|
476
495
|
};
|
|
477
496
|
|
|
478
|
-
var _excluded$
|
|
497
|
+
var _excluded$7 = ["value"],
|
|
479
498
|
_excluded2$1 = ["field", "group"],
|
|
480
499
|
_excluded3 = ["field", "group"];
|
|
481
500
|
|
|
482
|
-
function ownKeys$
|
|
501
|
+
function ownKeys$9(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
483
502
|
|
|
484
|
-
function _objectSpread$
|
|
503
|
+
function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$9(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$9(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
485
504
|
|
|
486
505
|
var parseValueList = function parseValueList() {
|
|
487
506
|
var valueList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
@@ -520,10 +539,10 @@ var parseField = function parseField() {
|
|
|
520
539
|
|
|
521
540
|
var _field$value = field.value,
|
|
522
541
|
value = _field$value === void 0 ? [] : _field$value,
|
|
523
|
-
attributes = _objectWithoutProperties(field, _excluded$
|
|
542
|
+
attributes = _objectWithoutProperties(field, _excluded$7);
|
|
524
543
|
|
|
525
544
|
var parsedValueList = parseValueList(value, options);
|
|
526
|
-
if (includeAttributes || includeFieldAttributes) return _objectSpread$
|
|
545
|
+
if (includeAttributes || includeFieldAttributes) return _objectSpread$9(_objectSpread$9({}, attributes), {}, {
|
|
527
546
|
value: parsedValueList
|
|
528
547
|
});
|
|
529
548
|
return parsedValueList;
|
|
@@ -658,8 +677,8 @@ var parseGroupList = function parseGroupList() {
|
|
|
658
677
|
currentGroup = _output$key.group;
|
|
659
678
|
var parsedField = parsedGroup.field,
|
|
660
679
|
parsedGroupList = parsedGroup.group;
|
|
661
|
-
output[key].field = _objectSpread$
|
|
662
|
-
output[key].group = _objectSpread$
|
|
680
|
+
output[key].field = _objectSpread$9(_objectSpread$9({}, currentField), parsedField);
|
|
681
|
+
output[key].group = _objectSpread$9(_objectSpread$9({}, currentGroup), parsedGroupList);
|
|
663
682
|
} else {
|
|
664
683
|
output[key] = parsedGroup;
|
|
665
684
|
}
|
|
@@ -669,21 +688,21 @@ var parseGroupList = function parseGroupList() {
|
|
|
669
688
|
/**
|
|
670
689
|
* Parses timespan according to specified options.
|
|
671
690
|
* The attributes can be targeted for each sub-type.
|
|
672
|
-
* @param {Object} timespan={} -
|
|
673
|
-
* @param {Object} options={} - Options which change how the metadataType is parsed.
|
|
674
|
-
* @param {string} options.joinValue=undefined - String to join the values, eg ','.
|
|
675
|
-
* @param {boolean} options.includeAttributes=false - Include attributes on all objects.
|
|
676
|
-
* @param {boolean} options.includeTimespanAttributes=false - Include attributes on timespans.
|
|
677
|
-
* @param {boolean} options.includeGroupAttributes=false - Include attributes on groups.
|
|
678
|
-
* @param {boolean} options.includeFieldAttributes=false - Include attributes on fields.
|
|
679
|
-
* @param {boolean} options.includeValueAttributes=false - Include attributes on values.
|
|
680
|
-
* @param {boolean} options.flat=false - Flatten to key/value (Note: keys may be overwritten).
|
|
681
|
-
* @param {boolean} options.flatTimespan=false - Flatten timespan.
|
|
682
|
-
* @param {boolean} options.flatGroup=false - Flatten group.
|
|
683
|
-
* @param {boolean} options.groupAsList=false - Return groups as list.
|
|
684
|
-
* @param {boolean} options.fieldAsList=false - Return fields as list.
|
|
685
|
-
* @param {boolean} options.arrayOnSingle=true - Return fields as array even if single field.
|
|
686
|
-
* @param {boolean} options.arrayOnSingleValue=true - Return fields as array even if single field value.
|
|
691
|
+
* @param {Object} [timespan={}] - A timespan from VidiCore.
|
|
692
|
+
* @param {Object} [options={}] - Options which change how the metadataType is parsed.
|
|
693
|
+
* @param {string} [options.joinValue=undefined] - String to join the values, eg ','.
|
|
694
|
+
* @param {boolean} [options.includeAttributes=false] - Include attributes on all objects.
|
|
695
|
+
* @param {boolean} [options.includeTimespanAttributes=false] - Include attributes on timespans.
|
|
696
|
+
* @param {boolean} [options.includeGroupAttributes=false] - Include attributes on groups.
|
|
697
|
+
* @param {boolean} [options.includeFieldAttributes=false] - Include attributes on fields.
|
|
698
|
+
* @param {boolean} [options.includeValueAttributes=false] - Include attributes on values.
|
|
699
|
+
* @param {boolean} [options.flat=false] - Flatten to key/value (Note: keys may be overwritten).
|
|
700
|
+
* @param {boolean} [options.flatTimespan=false] - Flatten timespan.
|
|
701
|
+
* @param {boolean} [options.flatGroup=false] - Flatten group.
|
|
702
|
+
* @param {boolean} [options.groupAsList=false] - Return groups as list.
|
|
703
|
+
* @param {boolean} [options.fieldAsList=false] - Return fields as list.
|
|
704
|
+
* @param {boolean} [options.arrayOnSingle=true] - Return fields as array even if single field.
|
|
705
|
+
* @param {boolean} [options.arrayOnSingleValue=true] - Return fields as array even if single field value.
|
|
687
706
|
* @returns {Object} Metadata object parsed according to options.
|
|
688
707
|
*/
|
|
689
708
|
|
|
@@ -742,13 +761,14 @@ var parseTimespan = function parseTimespan() {
|
|
|
742
761
|
return output;
|
|
743
762
|
};
|
|
744
763
|
|
|
745
|
-
function ownKeys$
|
|
764
|
+
function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
746
765
|
|
|
747
|
-
function _objectSpread$
|
|
766
|
+
function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$8(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
748
767
|
/**
|
|
749
768
|
* Parses timespanList according to specified options.
|
|
750
769
|
* The attributes can be targeted for each sub-type.
|
|
751
|
-
*
|
|
770
|
+
*
|
|
771
|
+
* @param {Object[]} timespanList - A timespanList from VidiCore.
|
|
752
772
|
* @param {Object} options - Options which change how the metadataType is parsed.
|
|
753
773
|
* @param {string} options.joinValue - String to join the values, eg ','.
|
|
754
774
|
* @param {boolean} options.includeAttributes - Include attributes on all objects.
|
|
@@ -764,8 +784,8 @@ function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) {
|
|
|
764
784
|
* @param {boolean} options.timespanAsList - Return timespans as list.
|
|
765
785
|
* @param {boolean} options.groupAsList - Return groups as list.
|
|
766
786
|
* @param {boolean} options.fieldAsList - Return fields as list.
|
|
767
|
-
* @param {boolean} options.arrayOnSingle=true - Return fields as array even if single field.
|
|
768
|
-
* @param {boolean} options.arrayOnSingleValue=true - Return fields as array even if single field value.
|
|
787
|
+
* @param {boolean} [options.arrayOnSingle=true] - Return fields as array even if single field.
|
|
788
|
+
* @param {boolean} [options.arrayOnSingleValue=true] - Return fields as array even if single field value.
|
|
769
789
|
* @returns {Object} Metadata object parsed according to options.
|
|
770
790
|
*/
|
|
771
791
|
|
|
@@ -792,15 +812,15 @@ var parseTimespanList = function parseTimespanList() {
|
|
|
792
812
|
var parsedTimespan = parseTimespan(thisTimespan, options);
|
|
793
813
|
|
|
794
814
|
if (flat) {
|
|
795
|
-
output = _objectSpread$
|
|
815
|
+
output = _objectSpread$8(_objectSpread$8({}, output), parsedTimespan);
|
|
796
816
|
} else if (output[key]) {
|
|
797
817
|
var _output$key = output[key],
|
|
798
818
|
currentField = _output$key.field,
|
|
799
819
|
currentGroup = _output$key.group;
|
|
800
820
|
var parsedField = parsedTimespan.field,
|
|
801
821
|
parsedGroup = parsedTimespan.group;
|
|
802
|
-
output[key].field = _objectSpread$
|
|
803
|
-
output[key].group = _objectSpread$
|
|
822
|
+
output[key].field = _objectSpread$8(_objectSpread$8({}, currentField), parsedField);
|
|
823
|
+
output[key].group = _objectSpread$8(_objectSpread$8({}, currentGroup), parsedGroup);
|
|
804
824
|
} else {
|
|
805
825
|
output[key] = parsedTimespan;
|
|
806
826
|
}
|
|
@@ -808,11 +828,11 @@ var parseTimespanList = function parseTimespanList() {
|
|
|
808
828
|
return output;
|
|
809
829
|
};
|
|
810
830
|
|
|
811
|
-
var _excluded$
|
|
831
|
+
var _excluded$6 = ["timespan"];
|
|
812
832
|
/**
|
|
813
833
|
* Parses MetadataType according to specified options.
|
|
814
834
|
* The attributes can be targeted for each sub-type.
|
|
815
|
-
* @param {Object} metadataType -
|
|
835
|
+
* @param {Object} metadataType - A MetadataType from VidiCore.
|
|
816
836
|
* @param {Object} options - Options which change how the metadataType is parsed.
|
|
817
837
|
* @param {string} options.joinValue - String to join the values, eg ','.
|
|
818
838
|
* @param {boolean} options.includeAttributes - Include attributes on all objects.
|
|
@@ -828,8 +848,8 @@ var _excluded$2 = ["timespan"];
|
|
|
828
848
|
* @param {boolean} options.timespanAsList - Return timespans as list.
|
|
829
849
|
* @param {boolean} options.groupAsList - Return groups as list.
|
|
830
850
|
* @param {boolean} options.fieldAsList - Return fields as list.
|
|
831
|
-
* @param {boolean} options.arrayOnSingle=true - Return fields as array even if single field.
|
|
832
|
-
* @param {boolean} options.arrayOnSingleValue=true - Return fields as array even if single field value.
|
|
851
|
+
* @param {boolean} [options.arrayOnSingle=true] - Return fields as array even if single field.
|
|
852
|
+
* @param {boolean} [options.arrayOnSingleValue=true] - Return fields as array even if single field value.
|
|
833
853
|
* @returns {Object} Metadata object parsed according to options.
|
|
834
854
|
*/
|
|
835
855
|
|
|
@@ -845,7 +865,7 @@ var parseMetadataType = function parseMetadataType() {
|
|
|
845
865
|
var _ref2 = metadataType || {},
|
|
846
866
|
_ref2$timespan = _ref2.timespan,
|
|
847
867
|
timespanList = _ref2$timespan === void 0 ? [] : _ref2$timespan,
|
|
848
|
-
attributes = _objectWithoutProperties(_ref2, _excluded$
|
|
868
|
+
attributes = _objectWithoutProperties(_ref2, _excluded$6);
|
|
849
869
|
|
|
850
870
|
if (sortTimespan) timespanList.sort(sortTimespanList);
|
|
851
871
|
var timespan = parseTimespanList(timespanList, options);
|
|
@@ -865,91 +885,7 @@ var parseSimpleMetadataType = function parseSimpleMetadataType() {
|
|
|
865
885
|
return parseKeyValuePairType(field);
|
|
866
886
|
};
|
|
867
887
|
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
871
|
-
|
|
872
|
-
/**
|
|
873
|
-
* Parses highlight timespan responses from the api into key/value object.
|
|
874
|
-
* The attributes can be targeted for each sub-type.
|
|
875
|
-
* @param {Object[]} highlightTimespan - A timespan object from the api response.
|
|
876
|
-
* @param {Object} options - Options which change how the timespans are parsed.
|
|
877
|
-
* @param {boolean} options.arrayOnSingle=true - Return an array if there is a single value.
|
|
878
|
-
* @param {boolean} options.timespanAsList=false - Return timespans as list.
|
|
879
|
-
* @param {string} options.joinValue - String to join the values, eg ','.
|
|
880
|
-
*/
|
|
881
|
-
var parseHighlightTimespan = function parseHighlightTimespan() {
|
|
882
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
883
|
-
_ref$field = _ref.field,
|
|
884
|
-
field = _ref$field === void 0 ? [] : _ref$field,
|
|
885
|
-
start = _ref.start,
|
|
886
|
-
end = _ref.end;
|
|
887
|
-
|
|
888
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
889
|
-
var _options$arrayOnSingl = options.arrayOnSingle,
|
|
890
|
-
arrayOnSingle = _options$arrayOnSingl === void 0 ? true : _options$arrayOnSingl,
|
|
891
|
-
_options$joinValue = options.joinValue,
|
|
892
|
-
joinValue = _options$joinValue === void 0 ? undefined : _options$joinValue,
|
|
893
|
-
_options$timespanAsLi = options.timespanAsList,
|
|
894
|
-
timespanAsList = _options$timespanAsLi === void 0 ? undefined : _options$timespanAsLi;
|
|
895
|
-
var initialValue = timespanAsList ? {
|
|
896
|
-
start: start,
|
|
897
|
-
end: end
|
|
898
|
-
} : {};
|
|
899
|
-
var fieldList = field.reduce(function (a, _ref2) {
|
|
900
|
-
var name = _ref2.name,
|
|
901
|
-
_ref2$value = _ref2.value,
|
|
902
|
-
valueList = _ref2$value === void 0 ? [] : _ref2$value;
|
|
903
|
-
if (valueList.length === 0) return a;
|
|
904
|
-
var fieldValue;
|
|
905
|
-
|
|
906
|
-
if (arrayOnSingle === false && valueList.length === 1) {
|
|
907
|
-
var _valueList = _slicedToArray(valueList, 1);
|
|
908
|
-
|
|
909
|
-
fieldValue = _valueList[0];
|
|
910
|
-
} else if (joinValue) fieldValue = valueList.join(joinValue);else fieldValue = valueList;
|
|
911
|
-
|
|
912
|
-
return _objectSpread$4(_objectSpread$4({}, a), {}, _defineProperty({}, name, fieldValue));
|
|
913
|
-
}, initialValue);
|
|
914
|
-
return fieldList;
|
|
915
|
-
};
|
|
916
|
-
|
|
917
|
-
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
918
|
-
|
|
919
|
-
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
920
|
-
/**
|
|
921
|
-
* Parses highlight timespans responses from the api into key/value object.
|
|
922
|
-
* The attributes can be targeted for each sub-type.
|
|
923
|
-
* @param {Object} highlightTimespanList - A list of timespans from the api response.
|
|
924
|
-
* @param {Object} options - Options which change how the timespans are parsed.
|
|
925
|
-
* @param {boolean} options.arrayOnSingle=true - Return an array if there is a single value.
|
|
926
|
-
* @param {string} options.joinValue - String to join the values, eg ','.
|
|
927
|
-
* @param {boolean} options.timespanAsList=false - Return timespans as list.
|
|
928
|
-
* @param {boolean} options.flat=false - Flatten to field-name/field-value (Note: field-values may be overwritten).
|
|
929
|
-
* @param {boolean} options.flatTimespan=false - Flatten timespan to object with start/end as key.
|
|
930
|
-
* @param {string} options.joinTimespan=_ - Character to join the start/end timecodes.
|
|
931
|
-
*/
|
|
932
|
-
|
|
933
|
-
var parseHighlightTimespanList = function parseHighlightTimespanList() {
|
|
934
|
-
var highlightTimespanList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
935
|
-
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
936
|
-
var flat = opts.flat,
|
|
937
|
-
timespanAsList = opts.timespanAsList,
|
|
938
|
-
_opts$joinTimespan = opts.joinTimespan,
|
|
939
|
-
joinTimespan = _opts$joinTimespan === void 0 ? '_' : _opts$joinTimespan,
|
|
940
|
-
flatTimespan = opts.flatTimespan;
|
|
941
|
-
if (timespanAsList === true) return highlightTimespanList.map(function (timespan) {
|
|
942
|
-
return parseHighlightTimespan(timespan, opts);
|
|
943
|
-
});
|
|
944
|
-
if (flat === true || flatTimespan === true) return highlightTimespanList.reduce(function (a, timespan) {
|
|
945
|
-
return _objectSpread$3(_objectSpread$3({}, a), parseHighlightTimespan(timespan, opts));
|
|
946
|
-
}, {});
|
|
947
|
-
return highlightTimespanList.reduce(function (a, timespan) {
|
|
948
|
-
return _objectSpread$3(_objectSpread$3({}, a), {}, _defineProperty({}, [timespan.start, timespan.end].join(joinTimespan), parseHighlightTimespan(timespan, opts)));
|
|
949
|
-
}, {});
|
|
950
|
-
};
|
|
951
|
-
|
|
952
|
-
var CONSTANT_TIMEBASES = {
|
|
888
|
+
var MAP_CONSTANT_TO_DEN_NUM = {
|
|
953
889
|
PAL: {
|
|
954
890
|
denominator: 25,
|
|
955
891
|
numerator: 1
|
|
@@ -969,59 +905,61 @@ var CONSTANT_TIMEBASES = {
|
|
|
969
905
|
59.94: {
|
|
970
906
|
denominator: 60000,
|
|
971
907
|
numerator: 1001
|
|
972
|
-
}
|
|
973
|
-
};
|
|
974
|
-
var FRAME_SEPARATORS = {
|
|
975
|
-
':': {
|
|
976
|
-
dropFrame: false,
|
|
977
|
-
field: 2
|
|
978
|
-
},
|
|
979
|
-
';': {
|
|
980
|
-
dropFrame: true,
|
|
981
|
-
field: 2
|
|
982
908
|
},
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
909
|
+
23.976: {
|
|
910
|
+
denominator: 48000,
|
|
911
|
+
numerator: 2002
|
|
986
912
|
},
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
913
|
+
23.98: {
|
|
914
|
+
denominator: 48000,
|
|
915
|
+
numerator: 2002
|
|
990
916
|
}
|
|
991
917
|
};
|
|
918
|
+
var TIME_BASE_CONSTANTS = Object.keys(MAP_CONSTANT_TO_DEN_NUM);
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* TimeBase class representing the TimeBaseType in VidiCore
|
|
922
|
+
*
|
|
923
|
+
* For more info, see the [Time bases section in VidiCore API Docs](https://apidoc.vidispine.com/latest/time.html#time-bases)
|
|
924
|
+
*/
|
|
992
925
|
|
|
993
926
|
var TimeBase = /*#__PURE__*/function () {
|
|
994
|
-
|
|
995
|
-
|
|
927
|
+
/**
|
|
928
|
+
* Constructor for TimeBase
|
|
929
|
+
*
|
|
930
|
+
* @param {object} [timeCodeType={}] A time base type object
|
|
931
|
+
* @param {number} [timeCodeType.numerator=1] The numerator for the TimeBase
|
|
932
|
+
* @param {number} [timeCodeType.denominator=1] The denominator for the TimeBase
|
|
933
|
+
*/
|
|
934
|
+
function TimeBase(timeCodeType) {
|
|
935
|
+
_classCallCheck(this, TimeBase);
|
|
936
|
+
|
|
937
|
+
var _ref = timeCodeType || {},
|
|
996
938
|
_ref$numerator = _ref.numerator,
|
|
997
939
|
numerator = _ref$numerator === void 0 ? 1 : _ref$numerator,
|
|
998
940
|
_ref$denominator = _ref.denominator,
|
|
999
941
|
denominator = _ref$denominator === void 0 ? 1 : _ref$denominator;
|
|
1000
942
|
|
|
1001
|
-
_classCallCheck(this, TimeBase);
|
|
1002
|
-
|
|
1003
943
|
this.numerator = Number(numerator);
|
|
1004
944
|
this.denominator = Number(denominator);
|
|
1005
945
|
}
|
|
946
|
+
/**
|
|
947
|
+
* Get TimeBase in a constant representation (e.g. "PAL") if possible, otherwise undefined
|
|
948
|
+
* @returns {string} Constant representation of the TimeBase
|
|
949
|
+
*/
|
|
950
|
+
|
|
1006
951
|
|
|
1007
952
|
_createClass(TimeBase, [{
|
|
1008
|
-
key: "toJSON",
|
|
1009
|
-
value: function toJSON() {
|
|
1010
|
-
return {
|
|
1011
|
-
denominator: this.denominator,
|
|
1012
|
-
numerator: this.numerator
|
|
1013
|
-
};
|
|
1014
|
-
}
|
|
1015
|
-
}, {
|
|
1016
953
|
key: "toConstant",
|
|
1017
954
|
value: function toConstant() {
|
|
1018
955
|
var _this = this;
|
|
1019
956
|
|
|
1020
|
-
var constant;
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
957
|
+
var constant; // If multiple equal den/num, it selects first in MAP_CONSTANT_TO_DEN_NUM
|
|
958
|
+
|
|
959
|
+
Object.entries(MAP_CONSTANT_TO_DEN_NUM).find(function (timeBaseConstant) {
|
|
960
|
+
var _timeBaseConstant = _slicedToArray(timeBaseConstant, 2),
|
|
961
|
+
thisTimeBaseText = _timeBaseConstant[0],
|
|
962
|
+
thisTimeBaseType = _timeBaseConstant[1];
|
|
1025
963
|
|
|
1026
964
|
var numerator = thisTimeBaseType.numerator,
|
|
1027
965
|
denominator = thisTimeBaseType.denominator;
|
|
@@ -1035,18 +973,36 @@ var TimeBase = /*#__PURE__*/function () {
|
|
|
1035
973
|
});
|
|
1036
974
|
return constant;
|
|
1037
975
|
}
|
|
976
|
+
/**
|
|
977
|
+
* Get TimeBase as a VidiCore TimeBaseType string
|
|
978
|
+
*
|
|
979
|
+
* Default format: denominator(:numerator if > 1)
|
|
980
|
+
* `constant` has precedence over `fraction` if both are true (e.g. NTSC > 30000:1001)
|
|
981
|
+
*
|
|
982
|
+
* @param {object} [options={}] For how to display it as text
|
|
983
|
+
* @param {boolean} [options.constant=false] Show time base as constant (e.g. PAL)
|
|
984
|
+
* @param {boolean} [options.fraction=false] Show time base as fraction (25:1) even when numerator is 1
|
|
985
|
+
* @returns {string} Text representation of the TimeBase
|
|
986
|
+
*/
|
|
987
|
+
|
|
1038
988
|
}, {
|
|
1039
989
|
key: "toText",
|
|
1040
990
|
value: function toText() {
|
|
1041
|
-
var
|
|
991
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1042
992
|
|
|
1043
|
-
|
|
993
|
+
var _ref2 = options || {},
|
|
994
|
+
_ref2$constant = _ref2.constant,
|
|
995
|
+
constant = _ref2$constant === void 0 ? false : _ref2$constant,
|
|
996
|
+
_ref2$fraction = _ref2.fraction,
|
|
997
|
+
fraction = _ref2$fraction === void 0 ? false : _ref2$fraction;
|
|
998
|
+
|
|
999
|
+
if (constant) {
|
|
1044
1000
|
var _timeBaseText = this.toConstant();
|
|
1045
1001
|
|
|
1046
1002
|
if (_timeBaseText) return _timeBaseText;
|
|
1047
1003
|
}
|
|
1048
1004
|
|
|
1049
|
-
if (this.numerator > 1) {
|
|
1005
|
+
if (fraction || this.numerator > 1) {
|
|
1050
1006
|
var _timeBaseText2 = [this.denominator, this.numerator].join(':');
|
|
1051
1007
|
|
|
1052
1008
|
return _timeBaseText2;
|
|
@@ -1055,13 +1011,40 @@ var TimeBase = /*#__PURE__*/function () {
|
|
|
1055
1011
|
var timeBaseText = String(this.denominator);
|
|
1056
1012
|
return timeBaseText;
|
|
1057
1013
|
}
|
|
1014
|
+
/**
|
|
1015
|
+
* Output TimeBase as frame rate (by default max 16 decimal places)
|
|
1016
|
+
*
|
|
1017
|
+
*
|
|
1018
|
+
* For `options.fixed`:
|
|
1019
|
+
* - `true` gives two decimal places
|
|
1020
|
+
* - `false` gives max amount of decimal places
|
|
1021
|
+
* - `number` gives that amount of decimal places
|
|
1022
|
+
*
|
|
1023
|
+
* Default format: rate with two decimals if needed (i.e. decimals are > 0)
|
|
1024
|
+
* Option precedence (when all true): `constant` > `rounded` > `fixed`
|
|
1025
|
+
*
|
|
1026
|
+
* @param {object} [options={}] For how to display it as rate
|
|
1027
|
+
* @param {boolean|number} [options.fixed=true] Amount of decimal places (true gives 2 decimal places)
|
|
1028
|
+
* @param {boolean} [options.constant=false] Use constant representation (if applicable)
|
|
1029
|
+
* @param {boolean} [options.rounded=false] Rounded to nearest integer
|
|
1030
|
+
*
|
|
1031
|
+
* @returns {number} Rate of the TimeBase
|
|
1032
|
+
*/
|
|
1033
|
+
|
|
1058
1034
|
}, {
|
|
1059
1035
|
key: "toRate",
|
|
1060
1036
|
value: function toRate() {
|
|
1061
|
-
var
|
|
1062
|
-
var round = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1037
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1063
1038
|
|
|
1064
|
-
|
|
1039
|
+
var _ref3 = options || {},
|
|
1040
|
+
_ref3$constant = _ref3.constant,
|
|
1041
|
+
constant = _ref3$constant === void 0 ? false : _ref3$constant,
|
|
1042
|
+
_ref3$rounded = _ref3.rounded,
|
|
1043
|
+
rounded = _ref3$rounded === void 0 ? false : _ref3$rounded,
|
|
1044
|
+
_ref3$fixed = _ref3.fixed,
|
|
1045
|
+
fixed = _ref3$fixed === void 0 ? true : _ref3$fixed;
|
|
1046
|
+
|
|
1047
|
+
if (constant) {
|
|
1065
1048
|
var _rate = this.toConstant();
|
|
1066
1049
|
|
|
1067
1050
|
if (_rate) return _rate;
|
|
@@ -1073,56 +1056,110 @@ var TimeBase = /*#__PURE__*/function () {
|
|
|
1073
1056
|
return rate;
|
|
1074
1057
|
}
|
|
1075
1058
|
|
|
1076
|
-
|
|
1059
|
+
if (rounded) {
|
|
1060
|
+
return Math.round(rate);
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
if (fixed === true || typeof fixed === 'number') {
|
|
1064
|
+
return Number(rate.toFixed(fixed === true ? 2 : fixed));
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
return rate;
|
|
1068
|
+
}
|
|
1069
|
+
/**
|
|
1070
|
+
* Get TimeBase in a object representation
|
|
1071
|
+
*
|
|
1072
|
+
* @returns {object} TimeBase as `{denominator, numerator}` object
|
|
1073
|
+
*/
|
|
1074
|
+
|
|
1075
|
+
}, {
|
|
1076
|
+
key: "toObject",
|
|
1077
|
+
value: function toObject() {
|
|
1078
|
+
return {
|
|
1079
|
+
denominator: this.denominator,
|
|
1080
|
+
numerator: this.numerator
|
|
1081
|
+
};
|
|
1082
|
+
}
|
|
1083
|
+
/**
|
|
1084
|
+
* @deprecated Use {@link TimeBase#toObject|toObject} instead
|
|
1085
|
+
*
|
|
1086
|
+
* @returns {object} TimeBase as `{denominator, numerator}` object
|
|
1087
|
+
*/
|
|
1088
|
+
|
|
1089
|
+
}, {
|
|
1090
|
+
key: "toJson",
|
|
1091
|
+
value: function toJson() {
|
|
1092
|
+
// eslint-disable-next-line no-console
|
|
1093
|
+
console.warn('Deprecated - use toObject instead');
|
|
1094
|
+
return this.toObject();
|
|
1077
1095
|
}
|
|
1078
1096
|
}]);
|
|
1079
1097
|
|
|
1080
1098
|
return TimeBase;
|
|
1081
1099
|
}();
|
|
1082
1100
|
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1101
|
+
/**
|
|
1102
|
+
* Format a string representation of a time base to a TimeBase Instance
|
|
1103
|
+
*
|
|
1104
|
+
* @param {string} timeBaseText The string to format to a TimeBase instance
|
|
1105
|
+
* @returns {TimeBase} A TimeBase Instance
|
|
1106
|
+
*/
|
|
1086
1107
|
|
|
1087
1108
|
var formatTimeBaseText = function formatTimeBaseText(timeBaseText) {
|
|
1088
1109
|
if (timeBaseText === undefined) {
|
|
1089
|
-
return
|
|
1110
|
+
return new TimeBase();
|
|
1090
1111
|
}
|
|
1091
1112
|
|
|
1092
1113
|
if (typeof timeBaseText === 'number') {
|
|
1093
|
-
return
|
|
1114
|
+
return new TimeBase({
|
|
1094
1115
|
denominator: timeBaseText
|
|
1095
1116
|
});
|
|
1096
1117
|
}
|
|
1097
1118
|
|
|
1098
|
-
if (timeBaseText.includes(':')) {
|
|
1119
|
+
if (typeof timeBaseText === 'string' && timeBaseText.includes(':')) {
|
|
1099
1120
|
var _timeBaseText$split = timeBaseText.split(':'),
|
|
1100
1121
|
_timeBaseText$split2 = _slicedToArray(_timeBaseText$split, 2),
|
|
1101
|
-
|
|
1122
|
+
denominator = _timeBaseText$split2[0],
|
|
1102
1123
|
numerator = _timeBaseText$split2[1];
|
|
1103
1124
|
|
|
1104
|
-
return
|
|
1105
|
-
denominator:
|
|
1125
|
+
return new TimeBase({
|
|
1126
|
+
denominator: denominator,
|
|
1106
1127
|
numerator: numerator
|
|
1107
1128
|
});
|
|
1108
1129
|
}
|
|
1109
1130
|
|
|
1110
|
-
if (
|
|
1111
|
-
return
|
|
1131
|
+
if (TIME_BASE_CONSTANTS.includes(timeBaseText)) {
|
|
1132
|
+
return new TimeBase(MAP_CONSTANT_TO_DEN_NUM[timeBaseText]);
|
|
1112
1133
|
}
|
|
1113
1134
|
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
if (Number.isNaN(denominator)) {
|
|
1117
|
-
throw new Error("timeBaseText must be a number or ".concat(Object.keys(CONSTANT_TIMEBASES).join(','), " - is ").concat(timeBaseText));
|
|
1135
|
+
if (!['string', 'number'].includes(_typeof(timeBaseText)) || Number.isNaN(Number(timeBaseText))) {
|
|
1136
|
+
throw new Error("timeBaseText must be a number or ".concat(TIME_BASE_CONSTANTS.join(','), " - is ").concat(JSON.stringify(timeBaseText)));
|
|
1118
1137
|
}
|
|
1119
1138
|
|
|
1120
|
-
return
|
|
1121
|
-
denominator:
|
|
1139
|
+
return new TimeBase({
|
|
1140
|
+
denominator: Number(timeBaseText)
|
|
1122
1141
|
});
|
|
1123
1142
|
};
|
|
1124
1143
|
|
|
1125
|
-
|
|
1144
|
+
/**
|
|
1145
|
+
* Create a TimeBase instance of an object
|
|
1146
|
+
*
|
|
1147
|
+
* @param {object} timeBase A TimeBase object ({ numerator, denominator })
|
|
1148
|
+
* @returns {TimeBase} A TimeBase instance
|
|
1149
|
+
*/
|
|
1150
|
+
|
|
1151
|
+
var formatTimeBaseType = function formatTimeBaseType(timeBase) {
|
|
1152
|
+
return new TimeBase(timeBase);
|
|
1153
|
+
};
|
|
1154
|
+
|
|
1155
|
+
/**
|
|
1156
|
+
* Create a TimeBase Instance from a string or object representation of a time base
|
|
1157
|
+
*
|
|
1158
|
+
* @param {string|object} timeBase Expressed as "denominator:numerator" or { numerator, denominator }
|
|
1159
|
+
* @returns {TimeBase} A TimeBase instance
|
|
1160
|
+
*/
|
|
1161
|
+
|
|
1162
|
+
var createTimeBase = function createTimeBase(timeBase) {
|
|
1126
1163
|
if (_typeof(timeBase) === 'object') {
|
|
1127
1164
|
return formatTimeBaseType(timeBase);
|
|
1128
1165
|
}
|
|
@@ -1130,47 +1167,86 @@ var formatTimeBase = function formatTimeBase(timeBase) {
|
|
|
1130
1167
|
return formatTimeBaseText(timeBase);
|
|
1131
1168
|
};
|
|
1132
1169
|
|
|
1133
|
-
|
|
1134
|
-
|
|
1170
|
+
/**
|
|
1171
|
+
* @private
|
|
1172
|
+
*
|
|
1173
|
+
* Drops 4 frames (0-3) for 59.97 and 2 frames (0-1) for 29.97/NTSC
|
|
1174
|
+
*
|
|
1175
|
+
* @param {TimeBase} timeBase to check
|
|
1176
|
+
* @returns {number} amount of frame drops for specified timeBase
|
|
1177
|
+
*/
|
|
1178
|
+
var getAmountOfFrameDrops = function getAmountOfFrameDrops(timeBase) {
|
|
1179
|
+
var timeBaseConstant = timeBase.toRate({
|
|
1180
|
+
constant: true
|
|
1181
|
+
});
|
|
1182
|
+
return timeBaseConstant === '59.94' && 4 || ['NTSC', '29.97'].includes(timeBaseConstant) && 2 || 0;
|
|
1135
1183
|
};
|
|
1136
1184
|
|
|
1137
|
-
|
|
1138
|
-
|
|
1185
|
+
/**
|
|
1186
|
+
* @private
|
|
1187
|
+
*
|
|
1188
|
+
* Check if TimeBase drops frames
|
|
1189
|
+
*
|
|
1190
|
+
* @param {object} timeBase TimeBase Instance to check
|
|
1191
|
+
* @returns {boolean} true if time base drops frames, false otherwise
|
|
1192
|
+
*/
|
|
1193
|
+
|
|
1194
|
+
var isDropFrameTimeBase = function isDropFrameTimeBase(timeBase) {
|
|
1195
|
+
return getAmountOfFrameDrops(timeBase) > 0;
|
|
1139
1196
|
};
|
|
1140
1197
|
|
|
1141
|
-
|
|
1142
|
-
var dropFrames = getDropFrames$1(roundedFrameRate);
|
|
1143
|
-
var oneMinuteUndroppedFrames = 60 * roundedFrameRate;
|
|
1144
|
-
var oneMinuteDroppedFrames = 60 * roundedFrameRate - dropFrames;
|
|
1145
|
-
var tenMinuteFrames = 10 * (oneMinuteUndroppedFrames - dropFrames) + dropFrames;
|
|
1146
|
-
var tenMinuteChunks = Math.floor(frames / tenMinuteFrames);
|
|
1147
|
-
var minuteRemainder = Math.max(0, frames % tenMinuteFrames - oneMinuteUndroppedFrames);
|
|
1148
|
-
var oneMinuteChunks = Math.floor(minuteRemainder / oneMinuteDroppedFrames);
|
|
1149
|
-
var frameRemainder = minuteRemainder % oneMinuteDroppedFrames;
|
|
1150
|
-
var frameChunks = frameRemainder > 0 ? dropFrames : 0;
|
|
1151
|
-
return tenMinuteChunks * 9 * dropFrames + oneMinuteChunks * dropFrames + frameChunks;
|
|
1152
|
-
}
|
|
1198
|
+
var _excluded$5 = ["hours"];
|
|
1153
1199
|
|
|
1154
|
-
var
|
|
1155
|
-
var
|
|
1156
|
-
|
|
1157
|
-
|
|
1200
|
+
var getDroppedFramesFromSamples = function getDroppedFramesFromSamples(_ref) {
|
|
1201
|
+
var samples = _ref.samples,
|
|
1202
|
+
timeBase = _ref.timeBase;
|
|
1203
|
+
var amountOfFrameDrops = getAmountOfFrameDrops(timeBase);
|
|
1204
|
+
if (amountOfFrameDrops === 0) return 0;
|
|
1205
|
+
var roundedFrameRate = timeBase.toRate({
|
|
1206
|
+
rounded: true
|
|
1207
|
+
});
|
|
1208
|
+
var oneMinuteNotDroppedFrames = 60 * roundedFrameRate;
|
|
1209
|
+
var amountOfFramesToDropPerMinute = 60 * roundedFrameRate - amountOfFrameDrops;
|
|
1210
|
+
var tenMinuteFrames = 10 * (oneMinuteNotDroppedFrames - amountOfFrameDrops) + amountOfFrameDrops;
|
|
1211
|
+
var amountOfTenMinuteChunks = Math.floor((samples + 1) / tenMinuteFrames);
|
|
1212
|
+
var minuteRemainder = Math.max(0, (samples + 1) % tenMinuteFrames - oneMinuteNotDroppedFrames);
|
|
1213
|
+
var amountOfOneMinuteReminderChunks = Math.floor(minuteRemainder / amountOfFramesToDropPerMinute);
|
|
1214
|
+
var frameRemainder = minuteRemainder % amountOfFramesToDropPerMinute;
|
|
1215
|
+
var amountOfFrameRemainderChunks = frameRemainder > 0 ? amountOfFrameDrops : 0;
|
|
1216
|
+
return amountOfTenMinuteChunks * 9 * amountOfFrameDrops + amountOfOneMinuteReminderChunks * amountOfFrameDrops + amountOfFrameRemainderChunks;
|
|
1158
1217
|
};
|
|
1218
|
+
/**
|
|
1219
|
+
* TimeCode class representing the TimeCodeType in VidiCore
|
|
1220
|
+
*
|
|
1221
|
+
* For more info, see the [Time Codes section of VidiCore API Docs](https://apidoc.vidispine.com/latest/time.html#time-codes)
|
|
1222
|
+
*/
|
|
1223
|
+
|
|
1159
1224
|
|
|
1160
1225
|
var TimeCode = /*#__PURE__*/function () {
|
|
1226
|
+
/**
|
|
1227
|
+
* Constructor for TimeCode
|
|
1228
|
+
*
|
|
1229
|
+
* @param {object} [timeCodeType={}] Object to create TimeCode of
|
|
1230
|
+
* @param {number} [timeCodeType.samples=0] Amount of samples for the time code
|
|
1231
|
+
* @param {object|string|number} [timeCodeType.timeBase={numerator: 1, denominator: 1}] The time base it should have
|
|
1232
|
+
* @param {object} [options={}] Options for the timeCode
|
|
1233
|
+
* @param {boolean} options.dropFrame If time code should be dropFrame or not (by default checks timeBase)
|
|
1234
|
+
* @param {string} options.frameSeparator Separator to use for frame smpte output (default ":" for non-drop-frame and ";" for dropFrame)
|
|
1235
|
+
*/
|
|
1161
1236
|
function TimeCode() {
|
|
1162
|
-
var
|
|
1163
|
-
_ref2$samples = _ref2.samples,
|
|
1164
|
-
samples = _ref2$samples === void 0 ? 0 : _ref2$samples,
|
|
1165
|
-
timeBase = _ref2.timeBase;
|
|
1237
|
+
var _options$dropFrame, _options$frameSeparat;
|
|
1166
1238
|
|
|
1167
|
-
var
|
|
1168
|
-
|
|
1169
|
-
_ref3$field = _ref3.field,
|
|
1170
|
-
field = _ref3$field === void 0 ? 2 : _ref3$field;
|
|
1239
|
+
var timeCodeType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1240
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1171
1241
|
|
|
1172
1242
|
_classCallCheck(this, TimeCode);
|
|
1173
1243
|
|
|
1244
|
+
var _ref2 = timeCodeType || {},
|
|
1245
|
+
_ref2$samples = _ref2.samples,
|
|
1246
|
+
samples = _ref2$samples === void 0 ? 0 : _ref2$samples,
|
|
1247
|
+
_ref2$timeBase = _ref2.timeBase,
|
|
1248
|
+
timeBase = _ref2$timeBase === void 0 ? new TimeBase() : _ref2$timeBase;
|
|
1249
|
+
|
|
1174
1250
|
if (typeof samples === 'number') {
|
|
1175
1251
|
this.samples = samples;
|
|
1176
1252
|
} else if (typeof samples === 'string') {
|
|
@@ -1185,21 +1261,39 @@ var TimeCode = /*#__PURE__*/function () {
|
|
|
1185
1261
|
throw new Error("samples is not number/string/-Inf/+Inf is: ".concat(samples));
|
|
1186
1262
|
}
|
|
1187
1263
|
|
|
1188
|
-
this.timeBase =
|
|
1189
|
-
this.dropFrame = dropFrame ===
|
|
1190
|
-
this.
|
|
1264
|
+
this.timeBase = createTimeBase(timeBase);
|
|
1265
|
+
this.dropFrame = (_options$dropFrame = options === null || options === void 0 ? void 0 : options.dropFrame) !== null && _options$dropFrame !== void 0 ? _options$dropFrame : isDropFrameTimeBase(this.timeBase);
|
|
1266
|
+
this.frameSeparator = (_options$frameSeparat = options === null || options === void 0 ? void 0 : options.frameSeparator) !== null && _options$frameSeparat !== void 0 ? _options$frameSeparat : this.dropFrame ? ';' : ':';
|
|
1191
1267
|
}
|
|
1268
|
+
/**
|
|
1269
|
+
* Return this TimeCode added with the supplied timeCodeType
|
|
1270
|
+
* If time bases differ, it will retain the time base of this TimeCode instance
|
|
1271
|
+
* If supplied time code has a more granular time base - it will round down exceeding samples (hasn't reached that sample yet)
|
|
1272
|
+
*
|
|
1273
|
+
* Note: This might make you "lose" frames depending on granularity of time bases, e.g.
|
|
1274
|
+
* "51@50".add("25@25") => "101@50"
|
|
1275
|
+
* while "25@25".add("51@50") => "50@25" (not "101@50")
|
|
1276
|
+
*
|
|
1277
|
+
* @param {TimeCode} timeCodeType A TimeCode instance you want to add with
|
|
1278
|
+
* @returns A new TimeCode instance with the addition applied
|
|
1279
|
+
*/
|
|
1280
|
+
|
|
1192
1281
|
|
|
1193
1282
|
_createClass(TimeCode, [{
|
|
1194
1283
|
key: "add",
|
|
1195
|
-
value: function add(
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1284
|
+
value: function add(timeCodeType) {
|
|
1285
|
+
if (!(timeCodeType !== null && timeCodeType !== void 0 && timeCodeType.timeBase) || (timeCodeType === null || timeCodeType === void 0 ? void 0 : timeCodeType.samples) === undefined) {
|
|
1286
|
+
throw Error('Invalid timeCodeType, cannot be added');
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
var _timeCodeType$timeBas = timeCodeType.timeBase;
|
|
1290
|
+
_timeCodeType$timeBas = _timeCodeType$timeBas === void 0 ? {} : _timeCodeType$timeBas;
|
|
1291
|
+
var numerator = _timeCodeType$timeBas.numerator,
|
|
1292
|
+
denominator = _timeCodeType$timeBas.denominator;
|
|
1293
|
+
var conformedTimeCode = timeCodeType;
|
|
1200
1294
|
|
|
1201
1295
|
if (numerator !== this.timeBase.numerator || denominator !== this.timeBase.denominator) {
|
|
1202
|
-
conformedTimeCode =
|
|
1296
|
+
conformedTimeCode = timeCodeType.conformTimeBase(this.timeBase);
|
|
1203
1297
|
}
|
|
1204
1298
|
|
|
1205
1299
|
var _conformedTimeCode = conformedTimeCode,
|
|
@@ -1209,16 +1303,34 @@ var TimeCode = /*#__PURE__*/function () {
|
|
|
1209
1303
|
timeBase: this.timeBase
|
|
1210
1304
|
});
|
|
1211
1305
|
}
|
|
1306
|
+
/**
|
|
1307
|
+
* Return this TimeCode subtracted with the supplied timeCodeType
|
|
1308
|
+
* If time bases differ, it will retain the time base of the instance time code
|
|
1309
|
+
* If supplied time code has a more granular time base - it will round down exceeding samples (hasn't reached that sample yet)
|
|
1310
|
+
*
|
|
1311
|
+
* Note: This might make you "lose" frames depending on granularity of time bases, e.g.
|
|
1312
|
+
* "101@50".subtract("25@25") => "51@50"
|
|
1313
|
+
* while "50@25".subtract("51@50") => "25@25" (not "49@50")
|
|
1314
|
+
*
|
|
1315
|
+
* @param {TimeCode} timeCodeType A TimeCode instance you want to subtract with
|
|
1316
|
+
* @returns A new TimeCode instance with the subtraction applied
|
|
1317
|
+
*/
|
|
1318
|
+
|
|
1212
1319
|
}, {
|
|
1213
1320
|
key: "subtract",
|
|
1214
|
-
value: function subtract(
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1321
|
+
value: function subtract(timeCodeType) {
|
|
1322
|
+
if (!(timeCodeType !== null && timeCodeType !== void 0 && timeCodeType.timeBase) || (timeCodeType === null || timeCodeType === void 0 ? void 0 : timeCodeType.samples) === undefined) {
|
|
1323
|
+
throw Error('Invalid timeCodeType, cannot be subtracted');
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
var _timeCodeType$timeBas2 = timeCodeType.timeBase;
|
|
1327
|
+
_timeCodeType$timeBas2 = _timeCodeType$timeBas2 === void 0 ? {} : _timeCodeType$timeBas2;
|
|
1328
|
+
var numerator = _timeCodeType$timeBas2.numerator,
|
|
1329
|
+
denominator = _timeCodeType$timeBas2.denominator;
|
|
1330
|
+
var conformedTimeCode = timeCodeType;
|
|
1219
1331
|
|
|
1220
1332
|
if (numerator !== this.timeBase.numerator || denominator !== this.timeBase.denominator) {
|
|
1221
|
-
conformedTimeCode =
|
|
1333
|
+
conformedTimeCode = timeCodeType.conformTimeBase(this.timeBase);
|
|
1222
1334
|
}
|
|
1223
1335
|
|
|
1224
1336
|
var _conformedTimeCode2 = conformedTimeCode,
|
|
@@ -1228,361 +1340,760 @@ var TimeCode = /*#__PURE__*/function () {
|
|
|
1228
1340
|
timeBase: this.timeBase
|
|
1229
1341
|
});
|
|
1230
1342
|
}
|
|
1343
|
+
/**
|
|
1344
|
+
* Creates a new TimeCode instance with specified timeBase and samples adjusted to that.
|
|
1345
|
+
*
|
|
1346
|
+
* If it conforms to a less granular time base - it will floor samples (hasn't reached that sample yet)
|
|
1347
|
+
* - e.g. "51@50".conformTo("PAL") => "25@PAL" (not "26@PAL")
|
|
1348
|
+
*
|
|
1349
|
+
* @param {string|object} conformTo The TimeBase it should conform the TimeCode to
|
|
1350
|
+
* @returns A new TimeCode instance with the conformTo timeBase applied
|
|
1351
|
+
*/
|
|
1352
|
+
|
|
1231
1353
|
}, {
|
|
1232
1354
|
key: "conformTimeBase",
|
|
1233
1355
|
value: function conformTimeBase(conformTo) {
|
|
1234
|
-
var
|
|
1356
|
+
var conformToTimeBase = conformTo;
|
|
1235
1357
|
|
|
1236
|
-
if (conformTo instanceof
|
|
1237
|
-
|
|
1358
|
+
if (!(conformTo instanceof TimeBase)) {
|
|
1359
|
+
conformToTimeBase = createTimeBase(conformTo);
|
|
1238
1360
|
}
|
|
1239
1361
|
|
|
1240
|
-
var samples = Math.
|
|
1362
|
+
var samples = Math.floor(this.samples / (this.timeBase.toRate({
|
|
1363
|
+
fixed: false
|
|
1364
|
+
}) / conformToTimeBase.toRate({
|
|
1365
|
+
fixed: false
|
|
1366
|
+
})));
|
|
1241
1367
|
var timeCode = {
|
|
1242
1368
|
samples: samples,
|
|
1243
|
-
timeBase:
|
|
1369
|
+
timeBase: conformToTimeBase
|
|
1244
1370
|
};
|
|
1245
1371
|
return new TimeCode(timeCode);
|
|
1246
1372
|
}
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1373
|
+
/**
|
|
1374
|
+
* Get TimeCode as a text representation
|
|
1375
|
+
*
|
|
1376
|
+
* Default format: samples@denominator(:numerator if > 1)
|
|
1377
|
+
* `constant` has precedence over `fraction` if both are true
|
|
1378
|
+
*
|
|
1379
|
+
* @param {object} [options={}] TimeBase toText options
|
|
1380
|
+
* @param {boolean} [options.includeTimeBaseForSeconds=false] include time base even if seconds
|
|
1381
|
+
* @param {boolean} [options.constant=false] show as constant (e.g. @PAL)
|
|
1382
|
+
* @param {boolean} [options.fraction=false] show as fraction (@25:1)
|
|
1383
|
+
* @returns Text representation of TimeCode
|
|
1384
|
+
*/
|
|
1385
|
+
|
|
1255
1386
|
}, {
|
|
1256
1387
|
key: "toText",
|
|
1257
1388
|
value: function toText() {
|
|
1258
|
-
var
|
|
1259
|
-
var
|
|
1389
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1390
|
+
var timeCodeText = "".concat(this.samples);
|
|
1391
|
+
var timeBaseText = this.timeBase.toText(options);
|
|
1260
1392
|
|
|
1261
|
-
if (
|
|
1393
|
+
if (options !== null && options !== void 0 && options.includeTimeBaseForSeconds || !['1', '1:1'].includes(timeBaseText)) {
|
|
1262
1394
|
timeCodeText = [this.samples, timeBaseText].join('@');
|
|
1263
1395
|
}
|
|
1264
1396
|
|
|
1265
1397
|
return timeCodeText;
|
|
1266
1398
|
}
|
|
1399
|
+
/**
|
|
1400
|
+
* Get TimeCode in a units object representation
|
|
1401
|
+
*
|
|
1402
|
+
* @returns {object} in the format { hours, minutes, seconds, frames }
|
|
1403
|
+
*/
|
|
1404
|
+
|
|
1267
1405
|
}, {
|
|
1268
|
-
key: "
|
|
1269
|
-
value: function
|
|
1270
|
-
var
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1406
|
+
key: "toUnits",
|
|
1407
|
+
value: function toUnits() {
|
|
1408
|
+
var totalSamples = this.samples + (this.dropFrame ? getDroppedFramesFromSamples(this) : 0);
|
|
1409
|
+
var roundedFrameRate = this.timeBase.toRate({
|
|
1410
|
+
rounded: true
|
|
1411
|
+
}); // Calculated without drop-frame but with 2 decimal places
|
|
1412
|
+
|
|
1413
|
+
if (['23.976', '23.98'].includes(this.timeBase.toConstant())) {
|
|
1414
|
+
roundedFrameRate = this.timeBase.toRate({
|
|
1415
|
+
fixed: true
|
|
1416
|
+
});
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
var hours = Math.floor(totalSamples / (3600 * roundedFrameRate));
|
|
1420
|
+
var minutes = Math.floor(totalSamples / (60 * roundedFrameRate)) % 60;
|
|
1421
|
+
var seconds = Math.floor(totalSamples / roundedFrameRate) % 60;
|
|
1422
|
+
var frames = Math.floor(totalSamples % roundedFrameRate);
|
|
1423
|
+
return {
|
|
1424
|
+
hours: hours,
|
|
1425
|
+
minutes: minutes,
|
|
1426
|
+
seconds: seconds,
|
|
1427
|
+
frames: frames
|
|
1428
|
+
};
|
|
1274
1429
|
}
|
|
1430
|
+
/**
|
|
1431
|
+
* Get TimeCode in a time object representation
|
|
1432
|
+
* "milliseconds" is rounded down, if you want another representation use "partialSeconds"
|
|
1433
|
+
*
|
|
1434
|
+
* @returns {object} in the format { hours, minutes, seconds, milliseconds, partialSeconds }
|
|
1435
|
+
*/
|
|
1436
|
+
|
|
1275
1437
|
}, {
|
|
1276
1438
|
key: "toTime",
|
|
1277
1439
|
value: function toTime() {
|
|
1278
|
-
var
|
|
1279
|
-
|
|
1280
|
-
var
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1440
|
+
var totalSamples = this.samples + getDroppedFramesFromSamples(this);
|
|
1441
|
+
|
|
1442
|
+
var _this$toUnits = this.toUnits(),
|
|
1443
|
+
hours = _this$toUnits.hours,
|
|
1444
|
+
minutes = _this$toUnits.minutes,
|
|
1445
|
+
seconds = _this$toUnits.seconds;
|
|
1446
|
+
|
|
1447
|
+
var roundedFrameRate = this.timeBase.toRate({
|
|
1448
|
+
rounded: true
|
|
1449
|
+
});
|
|
1450
|
+
var framesPrecise = totalSamples % roundedFrameRate;
|
|
1451
|
+
var milliseconds = Math.floor(1000 * framesPrecise / roundedFrameRate);
|
|
1452
|
+
var partialSeconds = framesPrecise / roundedFrameRate;
|
|
1285
1453
|
return {
|
|
1286
1454
|
hours: hours,
|
|
1287
1455
|
minutes: minutes,
|
|
1288
1456
|
seconds: seconds,
|
|
1289
|
-
|
|
1457
|
+
milliseconds: milliseconds,
|
|
1290
1458
|
partialSeconds: partialSeconds
|
|
1291
1459
|
};
|
|
1292
1460
|
}
|
|
1461
|
+
/**
|
|
1462
|
+
* Get TimeCode in a seconds representation
|
|
1463
|
+
*
|
|
1464
|
+
* @returns {number} the seconds
|
|
1465
|
+
*/
|
|
1466
|
+
|
|
1467
|
+
}, {
|
|
1468
|
+
key: "toSeconds",
|
|
1469
|
+
value: function toSeconds() {
|
|
1470
|
+
var _this$timeBase = this.timeBase,
|
|
1471
|
+
numerator = _this$timeBase.numerator,
|
|
1472
|
+
denominator = _this$timeBase.denominator;
|
|
1473
|
+
return Math.round(1000 * +(this.samples * numerator / denominator)) / 1000;
|
|
1474
|
+
}
|
|
1475
|
+
/**
|
|
1476
|
+
* Get TimeCode in a duration representation
|
|
1477
|
+
* The time unit char keys for the format string are:
|
|
1478
|
+
* - "h" for hour
|
|
1479
|
+
* - "m" for minute
|
|
1480
|
+
* - "s" for seconds
|
|
1481
|
+
* - "S" for milliseconds
|
|
1482
|
+
* Any other char will be kept in the duration output string.
|
|
1483
|
+
*
|
|
1484
|
+
* Add consecutive chars for zero padding.
|
|
1485
|
+
*
|
|
1486
|
+
* By default it:
|
|
1487
|
+
* - uses colon delimiter (e.g. for format "hhmmss")
|
|
1488
|
+
* - shows "m:ss" or "h:mm:ss" if format is undefined
|
|
1489
|
+
*
|
|
1490
|
+
* @param {object} [options={}]
|
|
1491
|
+
* @param {string} options.format specify format of duration string, e.g. hh:mm:ss.S for 01:23:04.5
|
|
1492
|
+
* @returns {string} Duration representation of the TimeCode
|
|
1493
|
+
*/
|
|
1494
|
+
|
|
1293
1495
|
}, {
|
|
1294
1496
|
key: "toDuration",
|
|
1295
1497
|
value: function toDuration() {
|
|
1296
|
-
var
|
|
1297
|
-
|
|
1498
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1499
|
+
var format = options.format;
|
|
1298
1500
|
|
|
1299
1501
|
var _this$toTime = this.toTime(),
|
|
1300
1502
|
hours = _this$toTime.hours,
|
|
1301
|
-
|
|
1302
|
-
seconds = _this$toTime.seconds;
|
|
1503
|
+
rest = _objectWithoutProperties(_this$toTime, _excluded$5);
|
|
1303
1504
|
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1505
|
+
var minutes = rest.minutes,
|
|
1506
|
+
seconds = rest.seconds,
|
|
1507
|
+
milliseconds = rest.milliseconds;
|
|
1508
|
+
|
|
1509
|
+
if (!!format && typeof format !== 'string') {
|
|
1510
|
+
throw Error('format has to be a string');
|
|
1308
1511
|
}
|
|
1309
1512
|
|
|
1310
|
-
|
|
1311
|
-
return
|
|
1513
|
+
var isBefore = function isBefore(unit, units) {
|
|
1514
|
+
return !format.includes(unit) || !units.some(function (u) {
|
|
1515
|
+
return format.includes(u) && format.lastIndexOf(unit) > format.indexOf(u);
|
|
1516
|
+
});
|
|
1517
|
+
};
|
|
1518
|
+
|
|
1519
|
+
if (!!format && !(isBefore('h', ['m', 's', 'S']) && isBefore('m', ['s', 'S']) && isBefore('s', ['S']))) {
|
|
1520
|
+
throw Error('format order is unsupported (has to be h, m, s then S)');
|
|
1312
1521
|
}
|
|
1313
1522
|
|
|
1314
|
-
if (
|
|
1315
|
-
return
|
|
1523
|
+
if (!format) {
|
|
1524
|
+
return "".concat(hours > 0 ? "".concat(hours, ":").concat("".concat(minutes).padStart(2, '0')) : minutes, ":").concat("".concat(seconds).padStart(2, '0'));
|
|
1316
1525
|
}
|
|
1317
1526
|
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
}, {
|
|
1321
|
-
key: "toSmpte",
|
|
1322
|
-
value: function toSmpte() {
|
|
1323
|
-
var _this = this;
|
|
1527
|
+
var countConsecutiveChars = function countConsecutiveChars(i, arr) {
|
|
1528
|
+
var j = i;
|
|
1324
1529
|
|
|
1325
|
-
|
|
1530
|
+
while (arr[j] === arr[j + 1]) {
|
|
1531
|
+
j += 1;
|
|
1532
|
+
}
|
|
1326
1533
|
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
minutes = _this$toTime2.minutes,
|
|
1330
|
-
seconds = _this$toTime2.seconds,
|
|
1331
|
-
frames = _this$toTime2.frames;
|
|
1534
|
+
return j - i + 1;
|
|
1535
|
+
};
|
|
1332
1536
|
|
|
1333
|
-
var
|
|
1537
|
+
var timeUnitKeys = ['h', 'm', 's', 'S'];
|
|
1538
|
+
var output = [];
|
|
1334
1539
|
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1540
|
+
_toConsumableArray(format).forEach(function (c, i, arr) {
|
|
1541
|
+
switch (c) {
|
|
1542
|
+
case 'h':
|
|
1543
|
+
{
|
|
1544
|
+
if (arr[i - 1] === 'h') {
|
|
1545
|
+
break;
|
|
1546
|
+
}
|
|
1340
1547
|
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
_Object$entries$find2 = _slicedToArray(_Object$entries$find, 1),
|
|
1344
|
-
_Object$entries$find3 = _Object$entries$find2[0],
|
|
1345
|
-
frameSeparator = _Object$entries$find3 === void 0 ? ':' : _Object$entries$find3;
|
|
1548
|
+
var amount = countConsecutiveChars(i, arr);
|
|
1549
|
+
output.push("".concat(hours).padStart(amount, '0'));
|
|
1346
1550
|
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
key: "toFraction",
|
|
1351
|
-
value: function toFraction() {
|
|
1352
|
-
return "".concat(this.samples, "@").concat(this.timeBase.denominator, ":").concat(this.timeBase.numerator);
|
|
1353
|
-
}
|
|
1354
|
-
}]);
|
|
1551
|
+
if (timeUnitKeys.includes(arr[i + amount])) {
|
|
1552
|
+
output.push(':');
|
|
1553
|
+
}
|
|
1355
1554
|
|
|
1356
|
-
|
|
1357
|
-
}
|
|
1555
|
+
break;
|
|
1556
|
+
}
|
|
1358
1557
|
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1558
|
+
case 'm':
|
|
1559
|
+
{
|
|
1560
|
+
if (arr[i - 1] === 'm') {
|
|
1561
|
+
break;
|
|
1562
|
+
}
|
|
1362
1563
|
|
|
1363
|
-
var
|
|
1364
|
-
if (timeCodeText === undefined) {
|
|
1365
|
-
var _timeCode = {
|
|
1366
|
-
samples: 0
|
|
1367
|
-
};
|
|
1368
|
-
return formatTimeCodeType(_timeCode, options);
|
|
1369
|
-
}
|
|
1564
|
+
var _amount = countConsecutiveChars(i, arr);
|
|
1370
1565
|
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
};
|
|
1375
|
-
return formatTimeCodeType(_timeCode2, options);
|
|
1376
|
-
}
|
|
1566
|
+
if (!format.includes('h')) {
|
|
1567
|
+
minutes *= hours * 60;
|
|
1568
|
+
}
|
|
1377
1569
|
|
|
1378
|
-
|
|
1379
|
-
var _timeCodeText$split = timeCodeText.split('@'),
|
|
1380
|
-
_timeCodeText$split2 = _slicedToArray(_timeCodeText$split, 2),
|
|
1381
|
-
samplesString = _timeCodeText$split2[0],
|
|
1382
|
-
timeBaseText = _timeCodeText$split2[1];
|
|
1570
|
+
output.push("".concat(minutes).padStart(_amount, '0'));
|
|
1383
1571
|
|
|
1384
|
-
|
|
1572
|
+
if (timeUnitKeys.includes(arr[i + _amount])) {
|
|
1573
|
+
output.push(':');
|
|
1574
|
+
}
|
|
1385
1575
|
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
samples: _samples,
|
|
1389
|
-
timeBase: timeBase
|
|
1390
|
-
};
|
|
1391
|
-
return formatTimeCodeType(_timeCode3, options);
|
|
1392
|
-
}
|
|
1576
|
+
break;
|
|
1577
|
+
}
|
|
1393
1578
|
|
|
1394
|
-
|
|
1395
|
-
|
|
1579
|
+
case 's':
|
|
1580
|
+
{
|
|
1581
|
+
if (arr[i - 1] === 's') {
|
|
1582
|
+
break;
|
|
1583
|
+
}
|
|
1396
1584
|
|
|
1397
|
-
|
|
1398
|
-
samples: _samples2
|
|
1399
|
-
};
|
|
1400
|
-
return formatTimeCodeType(_timeCode4, options);
|
|
1401
|
-
}
|
|
1585
|
+
var _amount2 = countConsecutiveChars(i, arr);
|
|
1402
1586
|
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1587
|
+
if (!format.includes('m')) {
|
|
1588
|
+
seconds *= minutes * 60;
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
output.push("".concat(seconds).padStart(_amount2, '0'));
|
|
1592
|
+
|
|
1593
|
+
if (timeUnitKeys.includes(arr[i + _amount2])) {
|
|
1594
|
+
output.push('.');
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
break;
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
case 'S':
|
|
1601
|
+
{
|
|
1602
|
+
if (arr[i - 1] === 'S') {
|
|
1603
|
+
break;
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
var _amount3 = countConsecutiveChars(i, arr);
|
|
1607
|
+
|
|
1608
|
+
if (!format.includes('s')) {
|
|
1609
|
+
milliseconds *= seconds * 1000;
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
output.push("".concat(Math.round(milliseconds / Math.pow(10, 3 - _amount3))).padStart(_amount3, '0'));
|
|
1613
|
+
break;
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
default:
|
|
1617
|
+
output.push(c);
|
|
1618
|
+
}
|
|
1619
|
+
});
|
|
1620
|
+
|
|
1621
|
+
return output.join('');
|
|
1622
|
+
}
|
|
1623
|
+
/**
|
|
1624
|
+
* Get TimeCode in a smpte representation
|
|
1625
|
+
*
|
|
1626
|
+
* @returns {string} Smpte representation of the TimeCode
|
|
1627
|
+
*/
|
|
1628
|
+
|
|
1629
|
+
}, {
|
|
1630
|
+
key: "toSmpte",
|
|
1631
|
+
value: function toSmpte() {
|
|
1632
|
+
if (this.samples === -Infinity) return '00:00:00:00';
|
|
1633
|
+
|
|
1634
|
+
var _this$toUnits2 = this.toUnits(),
|
|
1635
|
+
hours = _this$toUnits2.hours,
|
|
1636
|
+
minutes = _this$toUnits2.minutes,
|
|
1637
|
+
seconds = _this$toUnits2.seconds,
|
|
1638
|
+
frames = _this$toUnits2.frames;
|
|
1639
|
+
|
|
1640
|
+
var hhmmss = [hours.toFixed().padStart(2, '0'), minutes.toFixed().padStart(2, '0'), seconds.toFixed().padStart(2, '0')].join(':');
|
|
1641
|
+
return [hhmmss, "".concat(frames).padStart(2, '0')].join(this.frameSeparator);
|
|
1642
|
+
}
|
|
1643
|
+
/**
|
|
1644
|
+
* Get TimeCode as a VidiCore TimeCodeType object
|
|
1645
|
+
*
|
|
1646
|
+
* @returns {object} TimeCode as `{ samples, timeBase }`
|
|
1647
|
+
*/
|
|
1648
|
+
|
|
1649
|
+
}, {
|
|
1650
|
+
key: "toObject",
|
|
1651
|
+
value: function toObject() {
|
|
1652
|
+
return {
|
|
1653
|
+
samples: this.samples,
|
|
1654
|
+
timeBase: this.timeBase.toObject()
|
|
1655
|
+
};
|
|
1656
|
+
}
|
|
1657
|
+
/**
|
|
1658
|
+
* @deprecated Use {@link TimeCode#toObject|toObject} instead
|
|
1659
|
+
*
|
|
1660
|
+
* @returns {object} TimeCode as `{ samples, timeBase }`
|
|
1661
|
+
*/
|
|
1662
|
+
|
|
1663
|
+
}, {
|
|
1664
|
+
key: "toJson",
|
|
1665
|
+
value: function toJson() {
|
|
1666
|
+
// eslint-disable-next-line no-console
|
|
1667
|
+
console.warn('Deprecated - use toObject instead');
|
|
1668
|
+
return this.toObject();
|
|
1669
|
+
}
|
|
1670
|
+
}]);
|
|
1410
1671
|
|
|
1411
|
-
|
|
1672
|
+
return TimeCode;
|
|
1673
|
+
}();
|
|
1412
1674
|
|
|
1413
|
-
|
|
1414
|
-
|
|
1675
|
+
/* eslint-disable no-self-assign */
|
|
1676
|
+
|
|
1677
|
+
/**
|
|
1678
|
+
* @private
|
|
1679
|
+
*
|
|
1680
|
+
* Using Euclid's algorithm
|
|
1681
|
+
*
|
|
1682
|
+
* @param {number} num1 a number
|
|
1683
|
+
* @param {number} num2 another number
|
|
1684
|
+
* @returns {number} the greatest common divisor as a number
|
|
1685
|
+
*/
|
|
1686
|
+
var getGreatestCommonDivisor = function getGreatestCommonDivisor(num1, num2) {
|
|
1687
|
+
var a = Math.abs(num1);
|
|
1688
|
+
var b = Math.abs(num2);
|
|
1689
|
+
|
|
1690
|
+
while (a && b && a !== b) {
|
|
1691
|
+
if (a > b) {
|
|
1692
|
+
var _ref = [a - b, b];
|
|
1693
|
+
a = _ref[0];
|
|
1694
|
+
b = _ref[1];
|
|
1695
|
+
} else {
|
|
1696
|
+
var _ref2 = [a, b - a];
|
|
1697
|
+
a = _ref2[0];
|
|
1698
|
+
b = _ref2[1];
|
|
1699
|
+
}
|
|
1415
1700
|
}
|
|
1416
1701
|
|
|
1417
|
-
|
|
1418
|
-
samples: samples
|
|
1419
|
-
};
|
|
1420
|
-
return formatTimeCodeType(timeCode, options);
|
|
1702
|
+
return a || b;
|
|
1421
1703
|
};
|
|
1422
1704
|
|
|
1423
|
-
var
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1705
|
+
var _excluded$4 = ["timeBase", "useGCD"];
|
|
1706
|
+
/**
|
|
1707
|
+
* Format seconds to TimeCode object
|
|
1708
|
+
* Input time base is always 1:1 since it expects seconds as input
|
|
1709
|
+
*
|
|
1710
|
+
* Note: Max 15 digits accuracy (double precision float64), e.g.
|
|
1711
|
+
* - 10^6 seconds can have 10^9 decimals (nanosecond) precision
|
|
1712
|
+
* - 10^9 seconds can have 10^6 decimals (microsecond) precision
|
|
1713
|
+
* - 10^12 seconds can have 10^3 decimals (millisecond) precision
|
|
1714
|
+
*
|
|
1715
|
+
* @param {string|number} seconds With or without decimals ("." and "," are both interpreted as decimal)
|
|
1716
|
+
* @param {object} [options={}] Options for how to format the seconds to a TimeCode
|
|
1717
|
+
* @param {object|string} options.timeBase What TimeBase the resulting TimeCode should have (if unset and useGCD=false, denominator will be 10^<amount-of-decimals>)
|
|
1718
|
+
* @param {boolean} [options.useGCD=false] Samples and denominator are divided with GCD (ignored if timeBase is set) (e.g. 1.04 => 104@100 => 26@25)
|
|
1719
|
+
* @returns {TimeCode} A TimeCode instance
|
|
1720
|
+
*/
|
|
1427
1721
|
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
denominator = _ref$denominator === void 0 ? 1 : _ref$denominator,
|
|
1431
|
-
_ref$numerator = _ref.numerator,
|
|
1432
|
-
numerator = _ref$numerator === void 0 ? 1 : _ref$numerator;
|
|
1722
|
+
var formatTimeCodeSeconds = function formatTimeCodeSeconds(seconds) {
|
|
1723
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1433
1724
|
|
|
1434
|
-
var
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
};
|
|
1439
|
-
return new TimeCode(timeCode, options);
|
|
1440
|
-
};
|
|
1725
|
+
var timeBase = options.timeBase,
|
|
1726
|
+
_options$useGCD = options.useGCD,
|
|
1727
|
+
useGCD = _options$useGCD === void 0 ? false : _options$useGCD,
|
|
1728
|
+
timeCodeOptions = _objectWithoutProperties(options, _excluded$4);
|
|
1441
1729
|
|
|
1442
|
-
var
|
|
1443
|
-
|
|
1730
|
+
var secondsWithDot = "".concat(seconds).replace(/,/g, '.');
|
|
1731
|
+
|
|
1732
|
+
if (Number.isNaN(+secondsWithDot)) {
|
|
1444
1733
|
throw new Error("seconds must be digits, is ".concat(seconds));
|
|
1445
1734
|
}
|
|
1446
1735
|
|
|
1447
|
-
var
|
|
1448
|
-
|
|
1449
|
-
numerator = _ref$numerator === void 0 ? 1 : _ref$numerator;
|
|
1736
|
+
var denominator = 1;
|
|
1737
|
+
var samples;
|
|
1450
1738
|
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1739
|
+
if (Number.isInteger(+secondsWithDot)) {
|
|
1740
|
+
samples = +secondsWithDot * denominator;
|
|
1741
|
+
} else {
|
|
1742
|
+
var _ms$length;
|
|
1454
1743
|
|
|
1455
|
-
|
|
1456
|
-
|
|
1744
|
+
var _secondsWithDot$split = secondsWithDot.split('.'),
|
|
1745
|
+
_secondsWithDot$split2 = _slicedToArray(_secondsWithDot$split, 2),
|
|
1746
|
+
ms = _secondsWithDot$split2[1];
|
|
1747
|
+
|
|
1748
|
+
var decimalPlaces = Math.min((_ms$length = ms === null || ms === void 0 ? void 0 : ms.length) !== null && _ms$length !== void 0 ? _ms$length : 0, 16);
|
|
1457
1749
|
denominator *= Math.pow(10, decimalPlaces);
|
|
1750
|
+
samples = Math.round(secondsWithDot * denominator);
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
if (!timeBase && useGCD) {
|
|
1754
|
+
var gcd = getGreatestCommonDivisor(denominator, samples);
|
|
1755
|
+
samples /= gcd;
|
|
1756
|
+
denominator /= gcd;
|
|
1458
1757
|
}
|
|
1459
1758
|
|
|
1460
|
-
var
|
|
1461
|
-
var timeCode = {
|
|
1759
|
+
var timeCode = new TimeCode({
|
|
1462
1760
|
samples: samples,
|
|
1463
1761
|
timeBase: {
|
|
1464
1762
|
denominator: denominator,
|
|
1465
|
-
numerator:
|
|
1763
|
+
numerator: 1
|
|
1466
1764
|
}
|
|
1467
|
-
};
|
|
1468
|
-
return
|
|
1765
|
+
}, timeCodeOptions);
|
|
1766
|
+
return timeBase ? timeCode.conformTimeBase(createTimeBase(timeBase === true ? 1 : timeBase)) : timeCode;
|
|
1469
1767
|
};
|
|
1470
1768
|
|
|
1471
|
-
|
|
1769
|
+
var _excluded$3 = ["exceedingMode", "timeBase"];
|
|
1472
1770
|
|
|
1473
|
-
function
|
|
1771
|
+
function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1474
1772
|
|
|
1475
|
-
var
|
|
1476
|
-
|
|
1773
|
+
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$7(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1774
|
+
var MAP_SEPARATOR_TO_OPTIONS = {
|
|
1775
|
+
':': {
|
|
1776
|
+
dropFrame: false,
|
|
1777
|
+
frameSeparator: ':'
|
|
1778
|
+
},
|
|
1779
|
+
'.': {
|
|
1780
|
+
dropFrame: false,
|
|
1781
|
+
frameSeparator: '.'
|
|
1782
|
+
},
|
|
1783
|
+
';': {
|
|
1784
|
+
dropFrame: true,
|
|
1785
|
+
frameSeparator: ';'
|
|
1786
|
+
},
|
|
1787
|
+
',': {
|
|
1788
|
+
dropFrame: true,
|
|
1789
|
+
frameSeparator: ','
|
|
1790
|
+
}
|
|
1477
1791
|
};
|
|
1792
|
+
var getDroppedFramesFromSmpte = function getDroppedFramesFromSmpte(_ref, samples, timeBase) {
|
|
1793
|
+
var _ref2 = _slicedToArray(_ref, 4),
|
|
1794
|
+
hh = _ref2[0],
|
|
1795
|
+
mm = _ref2[1],
|
|
1796
|
+
ss = _ref2[2],
|
|
1797
|
+
ff = _ref2[3];
|
|
1798
|
+
|
|
1799
|
+
var roundedFrameRate = timeBase.toRate({
|
|
1800
|
+
rounded: true
|
|
1801
|
+
});
|
|
1802
|
+
var dropFrames = getAmountOfFrameDrops(timeBase);
|
|
1803
|
+
|
|
1804
|
+
if (samples === 0 || dropFrames === 0) {
|
|
1805
|
+
return 0;
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
var shouldDropMinute = mm % 10 !== 0;
|
|
1809
|
+
var shouldDropSecond = shouldDropMinute && ss === 0;
|
|
1810
|
+
var hourFrames = hh * (3600 * roundedFrameRate - 54 * dropFrames);
|
|
1811
|
+
var minuteFrames = mm * 60 * roundedFrameRate - (mm - Math.ceil(mm / 10)) * dropFrames;
|
|
1812
|
+
var secondFrames = ss * roundedFrameRate - (shouldDropMinute && ss > 1 ? dropFrames : 0);
|
|
1813
|
+
|
|
1814
|
+
if (shouldDropSecond && ff < dropFrames) {
|
|
1815
|
+
throw new Error("Frame does not exist for ".concat(timeBase.toRate({
|
|
1816
|
+
constant: true
|
|
1817
|
+
}), " drop-frame"));
|
|
1818
|
+
}
|
|
1478
1819
|
|
|
1479
|
-
var
|
|
1480
|
-
|
|
1820
|
+
var frameFrames = shouldDropSecond ? ff - dropFrames : ff;
|
|
1821
|
+
var samplesWithoutDroppedFrames = hourFrames + minuteFrames + secondFrames + frameFrames;
|
|
1822
|
+
return samples - samplesWithoutDroppedFrames;
|
|
1481
1823
|
};
|
|
1482
1824
|
|
|
1483
|
-
var splitSmpte = function splitSmpte(
|
|
1484
|
-
var
|
|
1485
|
-
|
|
1486
|
-
|
|
1825
|
+
var splitSmpte = function splitSmpte(smpte) {
|
|
1826
|
+
var _ref3 = (smpte === null || smpte === void 0 ? void 0 : smpte.match(/[^0-9:\-_]/)) || [],
|
|
1827
|
+
_ref4 = _slicedToArray(_ref3, 1),
|
|
1828
|
+
nonColonFrameSeparator = _ref4[0];
|
|
1487
1829
|
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1830
|
+
var smpteValues = [];
|
|
1831
|
+
var options = {
|
|
1832
|
+
frameSeparator: ':',
|
|
1833
|
+
dropFrame: false
|
|
1834
|
+
};
|
|
1491
1835
|
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1836
|
+
if (nonColonFrameSeparator) {
|
|
1837
|
+
var _smpte$split = smpte.split(nonColonFrameSeparator),
|
|
1838
|
+
_smpte$split2 = _slicedToArray(_smpte$split, 2),
|
|
1839
|
+
hhmmss = _smpte$split2[0],
|
|
1840
|
+
ff = _smpte$split2[1];
|
|
1496
1841
|
|
|
1497
|
-
|
|
1498
|
-
|
|
1842
|
+
smpteValues = [].concat(_toConsumableArray(hhmmss.split(':')), [ff]);
|
|
1843
|
+
options = MAP_SEPARATOR_TO_OPTIONS[nonColonFrameSeparator] || {};
|
|
1499
1844
|
} else {
|
|
1500
|
-
|
|
1845
|
+
smpteValues = smpte.split(':');
|
|
1501
1846
|
}
|
|
1502
1847
|
|
|
1503
|
-
|
|
1848
|
+
smpteValues = smpteValues.map(Number);
|
|
1849
|
+
|
|
1850
|
+
if (smpteValues.length !== 4) {
|
|
1851
|
+
throw new Error('Invalid format, must be "##:##:##:##');
|
|
1852
|
+
}
|
|
1504
1853
|
|
|
1505
|
-
if (
|
|
1854
|
+
if (smpteValues.some(function (n) {
|
|
1506
1855
|
return Number.isNaN(n);
|
|
1507
1856
|
})) {
|
|
1508
|
-
throw new Error('Invalid
|
|
1857
|
+
throw new Error('Invalid format, values must be numbers');
|
|
1509
1858
|
}
|
|
1510
1859
|
|
|
1511
|
-
return [
|
|
1860
|
+
return [smpteValues, options];
|
|
1512
1861
|
};
|
|
1513
1862
|
|
|
1514
|
-
var
|
|
1515
|
-
var
|
|
1516
|
-
|
|
1863
|
+
var getSamplesFromSmpte = function getSamplesFromSmpte(smpteValues, timeBase, dropFrame) {
|
|
1864
|
+
var _smpteValues = _slicedToArray(smpteValues, 4),
|
|
1865
|
+
hh = _smpteValues[0],
|
|
1866
|
+
mm = _smpteValues[1],
|
|
1867
|
+
ss = _smpteValues[2],
|
|
1868
|
+
ff = _smpteValues[3];
|
|
1869
|
+
|
|
1870
|
+
var roundedFrameRate = timeBase.toRate({
|
|
1871
|
+
rounded: true
|
|
1872
|
+
});
|
|
1873
|
+
var samples = hh * 3600 * roundedFrameRate + mm * 60 * roundedFrameRate + ss * roundedFrameRate + ff;
|
|
1874
|
+
return samples - (dropFrame ? getDroppedFramesFromSmpte(smpteValues, samples, timeBase) : 0);
|
|
1875
|
+
}; // Better naming than "useValueExcess" and "useValueTruncate" must exist
|
|
1876
|
+
|
|
1517
1877
|
|
|
1518
|
-
|
|
1519
|
-
|
|
1878
|
+
var EXCEEDING_OPTIONS = ['error', 'add', 'ignore'];
|
|
1879
|
+
/**
|
|
1880
|
+
* Format smpte text to a TimeCode Instance
|
|
1881
|
+
*
|
|
1882
|
+
* exceedingMode:
|
|
1883
|
+
* - "overflow" exceeding values will be kept (e.g. PAL and 00:00:00:25 => 00:00:01:00)
|
|
1884
|
+
* - "truncate" exceeding values will be truncated (e.g. PAL and 00:00:00:25 => 00:00:00:24)
|
|
1885
|
+
* - "error" exceeding values will throw error (e.g. PAL and 00:00:00:25 => Error)
|
|
1886
|
+
*
|
|
1887
|
+
* @param {string} smpte String representation of smpte
|
|
1888
|
+
* @param {object} [options={}] What options to use for creating the time code from smpte (all not specified below are passed to the TimeCode constructor)
|
|
1889
|
+
* @param {object|string|number} options.timeBase TimeBase of smpte (and consequently TimeBase of output TimeCode)
|
|
1890
|
+
* @param {string} [options.exceedingMode=error] How to handle exceeding values (`overflow|truncate|error`)
|
|
1891
|
+
* @param {boolean} options.dropFrame If it should parse and create time code using dropFrame
|
|
1892
|
+
* @param {string} options.frameSeparator What frame separator the TimeCode should store (defaults to what the smpte has)
|
|
1893
|
+
* @returns {TimeCode} A TimeCode instance
|
|
1894
|
+
*/
|
|
1895
|
+
|
|
1896
|
+
var formatTimeCodeSmpte = function formatTimeCodeSmpte(smpte) {
|
|
1897
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1898
|
+
|
|
1899
|
+
var _options$exceedingMod = options.exceedingMode,
|
|
1900
|
+
exceedingMode = _options$exceedingMod === void 0 ? 'error' : _options$exceedingMod,
|
|
1901
|
+
timeBase = options.timeBase,
|
|
1902
|
+
timeCodeOptions = _objectWithoutProperties(options, _excluded$3);
|
|
1903
|
+
|
|
1904
|
+
if ([null, undefined].includes(smpte)) {
|
|
1905
|
+
throw new Error("smpte cannot be undefined or null");
|
|
1520
1906
|
}
|
|
1521
1907
|
|
|
1522
|
-
if (
|
|
1523
|
-
throw new Error(
|
|
1908
|
+
if (typeof smpte !== 'string') {
|
|
1909
|
+
throw new Error("smpte must be a string, is ".concat(JSON.stringify(smpte)));
|
|
1524
1910
|
}
|
|
1525
1911
|
|
|
1526
|
-
var
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
var minuteFrames = mm * 60 * roundedFrameRate - (mm - Math.ceil(mm / 10)) * dropFrames;
|
|
1531
|
-
var secondFrames = ss * roundedFrameRate - (shouldDropMinute && ss > 1 ? dropFrames : 0);
|
|
1912
|
+
var _splitSmpte = splitSmpte(smpte),
|
|
1913
|
+
_splitSmpte2 = _slicedToArray(_splitSmpte, 2),
|
|
1914
|
+
smpteValues = _splitSmpte2[0],
|
|
1915
|
+
timeCodeOptionsFromSmpte = _splitSmpte2[1];
|
|
1532
1916
|
|
|
1533
|
-
|
|
1534
|
-
|
|
1917
|
+
var timeBaseInstance = createTimeBase(timeBase);
|
|
1918
|
+
|
|
1919
|
+
var mergedOptions = _objectSpread$7(_objectSpread$7({}, timeCodeOptionsFromSmpte), {}, {
|
|
1920
|
+
dropFrame: isDropFrameTimeBase(timeBaseInstance)
|
|
1921
|
+
}, timeCodeOptions);
|
|
1922
|
+
|
|
1923
|
+
var roundedFrameRate = timeBaseInstance.toRate({
|
|
1924
|
+
rounded: true
|
|
1925
|
+
});
|
|
1926
|
+
var maxFrame = Math.max(0, roundedFrameRate - 1);
|
|
1927
|
+
|
|
1928
|
+
if (smpteValues.some(function (v) {
|
|
1929
|
+
return v < 0;
|
|
1930
|
+
})) {
|
|
1931
|
+
throw new Error('Negative values are not supported');
|
|
1535
1932
|
}
|
|
1536
1933
|
|
|
1537
|
-
var
|
|
1538
|
-
|
|
1934
|
+
var samples;
|
|
1935
|
+
|
|
1936
|
+
switch (exceedingMode) {
|
|
1937
|
+
case 'error':
|
|
1938
|
+
{
|
|
1939
|
+
var _smpteValues2 = _slicedToArray(smpteValues, 4),
|
|
1940
|
+
hours = _smpteValues2[0],
|
|
1941
|
+
minutes = _smpteValues2[1],
|
|
1942
|
+
seconds = _smpteValues2[2],
|
|
1943
|
+
frames = _smpteValues2[3];
|
|
1944
|
+
|
|
1945
|
+
if (hours >= 100) {
|
|
1946
|
+
throw Error('Minutes has to be less than 60');
|
|
1947
|
+
}
|
|
1948
|
+
|
|
1949
|
+
if (minutes >= 60) {
|
|
1950
|
+
throw Error('Minutes has to be less than 60');
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
if (seconds >= 60) {
|
|
1954
|
+
throw Error('Seconds has to be less than 60');
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
if (frames > maxFrame) {
|
|
1958
|
+
throw Error("Frames has to be less or equal to ".concat(maxFrame));
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
samples = getSamplesFromSmpte(smpteValues, timeBaseInstance, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.dropFrame);
|
|
1962
|
+
break;
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
case 'ignore':
|
|
1966
|
+
{
|
|
1967
|
+
var _smpteValues3 = _slicedToArray(smpteValues, 4),
|
|
1968
|
+
_hours = _smpteValues3[0],
|
|
1969
|
+
_minutes = _smpteValues3[1],
|
|
1970
|
+
_seconds = _smpteValues3[2],
|
|
1971
|
+
_frames = _smpteValues3[3];
|
|
1972
|
+
|
|
1973
|
+
var truncatedSmpteValues = [Math.min(100, _hours), Math.min(59, _minutes), Math.min(59, _seconds), Math.min(maxFrame, _frames)];
|
|
1974
|
+
samples = getSamplesFromSmpte(truncatedSmpteValues, timeBaseInstance, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.dropFrame);
|
|
1975
|
+
break;
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
case 'add':
|
|
1979
|
+
{
|
|
1980
|
+
samples = getSamplesFromSmpte(smpteValues, timeBaseInstance, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.dropFrame);
|
|
1981
|
+
break;
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
default:
|
|
1985
|
+
{
|
|
1986
|
+
throw new Error("Invalid exceedingMode, options are ".concat(JSON.stringify(EXCEEDING_OPTIONS)));
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
return new TimeCode({
|
|
1991
|
+
samples: samples,
|
|
1992
|
+
timeBase: timeBaseInstance
|
|
1993
|
+
}, mergedOptions);
|
|
1539
1994
|
};
|
|
1540
1995
|
|
|
1541
|
-
var
|
|
1542
|
-
|
|
1996
|
+
var _excluded$2 = ["timeBase"];
|
|
1997
|
+
/**
|
|
1998
|
+
* Format text to a TimeCode instance
|
|
1999
|
+
*
|
|
2000
|
+
* @param {string} timeCodeText A time code text (e.g. "25@PAL")
|
|
2001
|
+
* @param {object} [options={}] Options for how to format
|
|
2002
|
+
* @param {object|string} options.timeBase The time base the returned TimeCode should have
|
|
2003
|
+
* @returns {TimeCode} A TimeCode instance
|
|
2004
|
+
*/
|
|
2005
|
+
|
|
2006
|
+
var formatTimeCodeText = function formatTimeCodeText(timeCodeText, options) {
|
|
2007
|
+
var _timeCodeObject;
|
|
2008
|
+
|
|
2009
|
+
var _ref = options || {},
|
|
2010
|
+
timeBase = _ref.timeBase,
|
|
2011
|
+
timeCodeOptions = _objectWithoutProperties(_ref, _excluded$2);
|
|
1543
2012
|
|
|
1544
|
-
|
|
1545
|
-
var _timeBase = formatTimeBase(timeBaseText);
|
|
2013
|
+
var timeCodeObject;
|
|
1546
2014
|
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
2015
|
+
if (timeCodeText === undefined) {
|
|
2016
|
+
timeCodeObject = {
|
|
2017
|
+
samples: 0
|
|
2018
|
+
};
|
|
2019
|
+
} else if (typeof timeCodeText === 'number') {
|
|
2020
|
+
timeCodeObject = {
|
|
2021
|
+
samples: timeCodeText
|
|
2022
|
+
};
|
|
2023
|
+
} else if (timeCodeText.includes('@')) {
|
|
2024
|
+
var _timeCodeText$split = timeCodeText.split('@'),
|
|
2025
|
+
_timeCodeText$split2 = _slicedToArray(_timeCodeText$split, 2),
|
|
2026
|
+
samplesString = _timeCodeText$split2[0],
|
|
2027
|
+
timeBaseText = _timeCodeText$split2[1];
|
|
2028
|
+
|
|
2029
|
+
var samples = Number(samplesString);
|
|
2030
|
+
timeCodeObject = {
|
|
2031
|
+
samples: samples,
|
|
2032
|
+
timeBase: formatTimeBaseText(timeBaseText)
|
|
2033
|
+
};
|
|
2034
|
+
} else if (timeCodeText === '-INF') {
|
|
2035
|
+
timeCodeObject = {
|
|
2036
|
+
samples: -Infinity
|
|
2037
|
+
};
|
|
2038
|
+
} else if (timeCodeText === '+INF') {
|
|
2039
|
+
timeCodeObject = {
|
|
2040
|
+
samples: Infinity
|
|
2041
|
+
};
|
|
2042
|
+
} else {
|
|
2043
|
+
timeCodeObject = {
|
|
2044
|
+
samples: Number(timeCodeText)
|
|
1550
2045
|
};
|
|
1551
|
-
return formatTimeCodeType(_timeCode);
|
|
1552
2046
|
}
|
|
1553
2047
|
|
|
1554
|
-
if (
|
|
1555
|
-
throw new Error("
|
|
2048
|
+
if (Number.isNaN((_timeCodeObject = timeCodeObject) === null || _timeCodeObject === void 0 ? void 0 : _timeCodeObject.samples) || timeCodeObject.timeBase && !(timeCodeObject.timeBase instanceof TimeBase)) {
|
|
2049
|
+
throw new Error("timeCodeText must be a number or sample@timeBase - is ".concat(timeCodeText));
|
|
1556
2050
|
}
|
|
1557
2051
|
|
|
1558
|
-
var
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
2052
|
+
var timeCode = new TimeCode(timeCodeObject, timeCodeOptions);
|
|
2053
|
+
return timeBase ? timeCode.conformTimeBase(createTimeBase(timeBase)) : timeCode;
|
|
2054
|
+
};
|
|
2055
|
+
|
|
2056
|
+
/**
|
|
2057
|
+
* Format an object to a TimeCode instance
|
|
2058
|
+
*
|
|
2059
|
+
* @param {object} timeCode To create TimeCode instance of
|
|
2060
|
+
* @param {object} options For the TimeCode constructor
|
|
2061
|
+
* @returns {TimeCode} A TimeCode instance
|
|
2062
|
+
*/
|
|
2063
|
+
|
|
2064
|
+
var formatTimeCodeType = function formatTimeCodeType(timeCode, options) {
|
|
2065
|
+
return new TimeCode(timeCode, options);
|
|
2066
|
+
};
|
|
2067
|
+
|
|
2068
|
+
var isObject = function isObject(o) {
|
|
2069
|
+
return Object.prototype.toString.call(o) === '[object Object]';
|
|
2070
|
+
};
|
|
2071
|
+
|
|
2072
|
+
var isString = function isString(s) {
|
|
2073
|
+
return typeof s === 'string';
|
|
2074
|
+
};
|
|
2075
|
+
|
|
2076
|
+
var hasSmpteFormat = function hasSmpteFormat(s) {
|
|
2077
|
+
return isString(s) && !!s.match(/^(\d\d+):(\d\d+):(\d\d+)(:|;|\.|,)(\d\d+)$/);
|
|
2078
|
+
};
|
|
2079
|
+
|
|
2080
|
+
var isNumber = function isNumber(s) {
|
|
2081
|
+
return !Number.isNaN(Number(s));
|
|
2082
|
+
};
|
|
2083
|
+
/**
|
|
2084
|
+
* Create a TimeCode instance from smpte, seconds/samples, timeCode object or string
|
|
2085
|
+
*
|
|
2086
|
+
* @param {object|string|number} timeCode Smpte, seconds/samples, timeCode object or string
|
|
2087
|
+
* @param {object} [options={}] For the format functions
|
|
2088
|
+
* @returns {TimeCode} A TimeCode instance
|
|
2089
|
+
*/
|
|
2090
|
+
|
|
2091
|
+
|
|
2092
|
+
var createTimeCode = function createTimeCode(timeCode, options) {
|
|
2093
|
+
if (isObject(timeCode)) return formatTimeCodeType(timeCode, options);
|
|
2094
|
+
if (hasSmpteFormat(timeCode)) return formatTimeCodeSmpte(timeCode, options);
|
|
2095
|
+
if (isNumber(timeCode)) return formatTimeCodeSeconds(timeCode, options);
|
|
2096
|
+
return formatTimeCodeText(timeCode, options);
|
|
1586
2097
|
};
|
|
1587
2098
|
|
|
1588
2099
|
function timeToCueTime(_ref) {
|
|
@@ -1602,10 +2113,10 @@ function timeToCueTime(_ref) {
|
|
|
1602
2113
|
}
|
|
1603
2114
|
/**
|
|
1604
2115
|
* Convert subtitle groups to WebVtt subtitle format
|
|
1605
|
-
* @param {Object} input={}
|
|
2116
|
+
* @param {Object} [input={}]
|
|
1606
2117
|
* @param {Object} input.metadataType - MetadataType response from API.
|
|
1607
|
-
* @param {string} input.subtitleGroup=stl_subtitle - Name of group containing subtitle field/text.
|
|
1608
|
-
* @param {string} input.subtitleField=stl_text - Name of field (text) to use for the subtitles.
|
|
2118
|
+
* @param {string} [input.subtitleGroup=stl_subtitle] - Name of group containing subtitle field/text.
|
|
2119
|
+
* @param {string} [input.subtitleField=stl_text] - Name of field (text) to use for the subtitles.
|
|
1609
2120
|
* @returns {string} WebVtt subtitles
|
|
1610
2121
|
*/
|
|
1611
2122
|
|
|
@@ -1664,9 +2175,9 @@ var createFacetType = function createFacetType() {
|
|
|
1664
2175
|
});
|
|
1665
2176
|
};
|
|
1666
2177
|
|
|
1667
|
-
function ownKeys$
|
|
2178
|
+
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1668
2179
|
|
|
1669
|
-
function _objectSpread$
|
|
2180
|
+
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1670
2181
|
|
|
1671
2182
|
var parseFacetType = function parseFacetType() {
|
|
1672
2183
|
var facetType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
@@ -1675,7 +2186,7 @@ var parseFacetType = function parseFacetType() {
|
|
|
1675
2186
|
var facetFieldReducer = function facetFieldReducer(a, _ref) {
|
|
1676
2187
|
var fieldValue = _ref.fieldValue,
|
|
1677
2188
|
value = _ref.value;
|
|
1678
|
-
return _objectSpread$
|
|
2189
|
+
return _objectSpread$6(_objectSpread$6({}, a), {}, _defineProperty({}, fieldValue, value));
|
|
1679
2190
|
};
|
|
1680
2191
|
|
|
1681
2192
|
facetType.forEach(function (_ref2) {
|
|
@@ -1687,41 +2198,95 @@ var parseFacetType = function parseFacetType() {
|
|
|
1687
2198
|
return output;
|
|
1688
2199
|
};
|
|
1689
2200
|
|
|
1690
|
-
|
|
2201
|
+
function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1691
2202
|
|
|
1692
|
-
function
|
|
2203
|
+
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1693
2204
|
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
}
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
}
|
|
2205
|
+
/**
|
|
2206
|
+
* Parses highlight timespan in VidiCore into key/value object.
|
|
2207
|
+
* The attributes can be targeted for each sub-type.
|
|
2208
|
+
* @param {Object[]} highlightTimespan - A VidiCore timespan object.
|
|
2209
|
+
* @param {Object} options - Options which change how the timespans are parsed.
|
|
2210
|
+
* @param {boolean} [options.arrayOnSingle=true] - Return an array if there is a single value.
|
|
2211
|
+
* @param {boolean} [options.timespanAsList=false] - Return timespans as list.
|
|
2212
|
+
* @param {string} options.joinValue - String to join the values, eg ','.
|
|
2213
|
+
*/
|
|
2214
|
+
var parseHighlightTimespan = function parseHighlightTimespan() {
|
|
2215
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
2216
|
+
_ref$field = _ref.field,
|
|
2217
|
+
field = _ref$field === void 0 ? [] : _ref$field,
|
|
2218
|
+
start = _ref.start,
|
|
2219
|
+
end = _ref.end;
|
|
1705
2220
|
|
|
1706
|
-
var
|
|
1707
|
-
|
|
2221
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2222
|
+
var _options$arrayOnSingl = options.arrayOnSingle,
|
|
2223
|
+
arrayOnSingle = _options$arrayOnSingl === void 0 ? true : _options$arrayOnSingl,
|
|
2224
|
+
_options$joinValue = options.joinValue,
|
|
2225
|
+
joinValue = _options$joinValue === void 0 ? undefined : _options$joinValue,
|
|
2226
|
+
_options$timespanAsLi = options.timespanAsList,
|
|
2227
|
+
timespanAsList = _options$timespanAsLi === void 0 ? undefined : _options$timespanAsLi;
|
|
2228
|
+
var initialValue = timespanAsList ? {
|
|
2229
|
+
start: start,
|
|
2230
|
+
end: end
|
|
2231
|
+
} : {};
|
|
2232
|
+
var fieldList = field.reduce(function (a, _ref2) {
|
|
2233
|
+
var name = _ref2.name,
|
|
2234
|
+
_ref2$value = _ref2.value,
|
|
2235
|
+
valueList = _ref2$value === void 0 ? [] : _ref2$value;
|
|
2236
|
+
if (valueList.length === 0) return a;
|
|
2237
|
+
var fieldValue;
|
|
2238
|
+
|
|
2239
|
+
if (arrayOnSingle === false && valueList.length === 1) {
|
|
2240
|
+
var _valueList = _slicedToArray(valueList, 1);
|
|
2241
|
+
|
|
2242
|
+
fieldValue = _valueList[0];
|
|
2243
|
+
} else if (joinValue) fieldValue = valueList.join(joinValue);else fieldValue = valueList;
|
|
2244
|
+
|
|
2245
|
+
return _objectSpread$5(_objectSpread$5({}, a), {}, _defineProperty({}, name, fieldValue));
|
|
2246
|
+
}, initialValue);
|
|
2247
|
+
return fieldList;
|
|
1708
2248
|
};
|
|
1709
2249
|
|
|
1710
|
-
var
|
|
1711
|
-
var width = _ref.width,
|
|
1712
|
-
height = _ref.height;
|
|
1713
|
-
var denominator = gcd(width, height);
|
|
1714
|
-
var widthRatio = width / denominator;
|
|
1715
|
-
var heightRatio = height / denominator;
|
|
2250
|
+
function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1716
2251
|
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
2252
|
+
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2253
|
+
/**
|
|
2254
|
+
* Parses highlight timespans from VidiCore into key/value object.
|
|
2255
|
+
* The attributes can be targeted for each sub-type.
|
|
2256
|
+
* @param {Object} highlightTimespanList - A list of timespans from VidiCore.
|
|
2257
|
+
* @param {Object} options - Options which change how the timespans are parsed.
|
|
2258
|
+
* @param {boolean} [options.arrayOnSingle=true] - Return an array if there is a single value.
|
|
2259
|
+
* @param {string} options.joinValue - String to join the values, eg ','.
|
|
2260
|
+
* @param {boolean} [options.timespanAsList=false] - Return timespans as list.
|
|
2261
|
+
* @param {boolean} [options.flat=false] - Flatten to field-name/field-value (Note: field-values may be overwritten).
|
|
2262
|
+
* @param {boolean} [options.flatTimespan=false] - Flatten timespan to object with start/end as key.
|
|
2263
|
+
* @param {string} [options.joinTimespan=_] - Character to join the start/end timecodes.
|
|
2264
|
+
*/
|
|
1721
2265
|
|
|
1722
|
-
|
|
2266
|
+
var parseHighlightTimespanList = function parseHighlightTimespanList() {
|
|
2267
|
+
var highlightTimespanList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
2268
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2269
|
+
var flat = options.flat,
|
|
2270
|
+
timespanAsList = options.timespanAsList,
|
|
2271
|
+
_options$joinTimespan = options.joinTimespan,
|
|
2272
|
+
joinTimespan = _options$joinTimespan === void 0 ? '_' : _options$joinTimespan,
|
|
2273
|
+
flatTimespan = options.flatTimespan;
|
|
2274
|
+
if (timespanAsList === true) return highlightTimespanList.map(function (timespan) {
|
|
2275
|
+
return parseHighlightTimespan(timespan, options);
|
|
2276
|
+
});
|
|
2277
|
+
if (flat === true || flatTimespan === true) return highlightTimespanList.reduce(function (a, timespan) {
|
|
2278
|
+
return _objectSpread$4(_objectSpread$4({}, a), parseHighlightTimespan(timespan, options));
|
|
2279
|
+
}, {});
|
|
2280
|
+
return highlightTimespanList.reduce(function (a, timespan) {
|
|
2281
|
+
return _objectSpread$4(_objectSpread$4({}, a), {}, _defineProperty({}, [timespan.start, timespan.end].join(joinTimespan), parseHighlightTimespan(timespan, options)));
|
|
2282
|
+
}, {});
|
|
1723
2283
|
};
|
|
1724
2284
|
|
|
2285
|
+
var _excluded$1 = ["property"];
|
|
2286
|
+
|
|
2287
|
+
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2288
|
+
|
|
2289
|
+
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1725
2290
|
var parseBaseMediaInfoType = function parseBaseMediaInfoType() {
|
|
1726
2291
|
var baseMediaInfoType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1727
2292
|
|
|
@@ -1729,7 +2294,64 @@ var parseBaseMediaInfoType = function parseBaseMediaInfoType() {
|
|
|
1729
2294
|
props = _objectWithoutProperties(baseMediaInfoType, _excluded$1);
|
|
1730
2295
|
|
|
1731
2296
|
var parsedKeyValuePairType = parseKeyValuePairType(keyValuePairType);
|
|
1732
|
-
return _objectSpread(_objectSpread({}, parsedKeyValuePairType), props);
|
|
2297
|
+
return _objectSpread$3(_objectSpread$3({}, parsedKeyValuePairType), props);
|
|
2298
|
+
};
|
|
2299
|
+
|
|
2300
|
+
var sampleRateSymbols = {
|
|
2301
|
+
kB: 'kHz',
|
|
2302
|
+
B: 'Hz',
|
|
2303
|
+
mB: 'mHz'
|
|
2304
|
+
};
|
|
2305
|
+
var bitRateSymbols = {
|
|
2306
|
+
kB: 'kbps',
|
|
2307
|
+
B: 'bps',
|
|
2308
|
+
MB: 'mbps'
|
|
2309
|
+
};
|
|
2310
|
+
/**
|
|
2311
|
+
* Parses the technical information of a AudioComponentType.
|
|
2312
|
+
* @param {Object} audioComponentType - A AudioComponentType from VidiCore.
|
|
2313
|
+
* @returns {Object} Parsed component object.
|
|
2314
|
+
*/
|
|
2315
|
+
|
|
2316
|
+
var parseAudioComponentType = function parseAudioComponentType() {
|
|
2317
|
+
var audioComponentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2318
|
+
var _audioComponentType$t = audioComponentType.timeBase,
|
|
2319
|
+
timeBase = _audioComponentType$t === void 0 ? {} : _audioComponentType$t,
|
|
2320
|
+
audioChannels = audioComponentType.channelCount,
|
|
2321
|
+
audioCodec = audioComponentType.codec,
|
|
2322
|
+
_audioComponentType$m = audioComponentType.mediaInfo,
|
|
2323
|
+
mediaInfo = _audioComponentType$m === void 0 ? {} : _audioComponentType$m,
|
|
2324
|
+
bitrate = audioComponentType.bitrate,
|
|
2325
|
+
_audioComponentType$m2 = audioComponentType.metadata,
|
|
2326
|
+
metadata = _audioComponentType$m2 === void 0 ? [] : _audioComponentType$m2;
|
|
2327
|
+
var audioMediaInfo = parseBaseMediaInfoType(mediaInfo);
|
|
2328
|
+
var audioMetadata = parseKeyValuePairType(metadata);
|
|
2329
|
+
var audioFormat = audioMediaInfo.Format,
|
|
2330
|
+
audioBitDepth = audioMediaInfo.Resolution,
|
|
2331
|
+
audioBitRateMode = audioMediaInfo.Bit_rate_mode;
|
|
2332
|
+
var audioSamplerateSamples = timeBase.denominator ? timeBase.denominator / timeBase.numerator : undefined;
|
|
2333
|
+
var audioSamplerate = audioSamplerateSamples ? parseFileSize(audioSamplerateSamples, {
|
|
2334
|
+
base: 10,
|
|
2335
|
+
round: 1,
|
|
2336
|
+
symbols: sampleRateSymbols
|
|
2337
|
+
}) : undefined;
|
|
2338
|
+
var audioBitrate = bitrate ? parseFileSize(bitrate, {
|
|
2339
|
+
base: 10,
|
|
2340
|
+
round: 2,
|
|
2341
|
+
symbols: bitRateSymbols
|
|
2342
|
+
}) : undefined;
|
|
2343
|
+
return {
|
|
2344
|
+
audioFormat: audioFormat,
|
|
2345
|
+
audioCodec: audioCodec,
|
|
2346
|
+
audioSamplerate: audioSamplerate,
|
|
2347
|
+
audioSamplerateSamples: audioSamplerateSamples,
|
|
2348
|
+
audioBitDepth: audioBitDepth,
|
|
2349
|
+
audioBitrate: audioBitrate,
|
|
2350
|
+
audioBitRateMode: audioBitRateMode,
|
|
2351
|
+
audioChannels: audioChannels,
|
|
2352
|
+
audioMediaInfo: audioMediaInfo,
|
|
2353
|
+
audioMetadata: audioMetadata
|
|
2354
|
+
};
|
|
1733
2355
|
};
|
|
1734
2356
|
|
|
1735
2357
|
var parseFileType = function parseFileType(fileType) {
|
|
@@ -1756,16 +2378,60 @@ var parseFileType = function parseFileType(fileType) {
|
|
|
1756
2378
|
};
|
|
1757
2379
|
};
|
|
1758
2380
|
|
|
1759
|
-
var
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
2381
|
+
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2382
|
+
|
|
2383
|
+
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2384
|
+
/**
|
|
2385
|
+
* Parses the technical information of a BinaryComponentType.
|
|
2386
|
+
* @param {Object} binaryComponentType - A BinaryComponentType from VidiCore.
|
|
2387
|
+
* @returns {Object} Parsed component object.
|
|
2388
|
+
*/
|
|
2389
|
+
|
|
2390
|
+
var parseBinaryComponentType = function parseBinaryComponentType() {
|
|
2391
|
+
var binaryComponentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2392
|
+
var fileList = binaryComponentType.file,
|
|
2393
|
+
_binaryComponentType$ = binaryComponentType.mediaInfo,
|
|
2394
|
+
mediaInfo = _binaryComponentType$ === void 0 ? {} : _binaryComponentType$,
|
|
2395
|
+
_binaryComponentType$2 = binaryComponentType.metadata,
|
|
2396
|
+
metadata = _binaryComponentType$2 === void 0 ? [] : _binaryComponentType$2;
|
|
2397
|
+
var binaryMetadata = parseKeyValuePairType(metadata);
|
|
2398
|
+
var binaryMediaInfo = parseBaseMediaInfoType(mediaInfo);
|
|
2399
|
+
var parsedBinaryComponent = {
|
|
2400
|
+
binaryMetadata: binaryMetadata,
|
|
2401
|
+
binaryMediaInfo: binaryMediaInfo
|
|
2402
|
+
};
|
|
2403
|
+
|
|
2404
|
+
if (fileList) {
|
|
2405
|
+
var _fileList = _slicedToArray(fileList, 1),
|
|
2406
|
+
fileType = _fileList[0];
|
|
2407
|
+
|
|
2408
|
+
var parsedFileType = parseFileType(fileType);
|
|
2409
|
+
parsedBinaryComponent = _objectSpread$2(_objectSpread$2({}, parsedBinaryComponent), parsedFileType);
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2412
|
+
return parsedBinaryComponent;
|
|
2413
|
+
};
|
|
2414
|
+
|
|
2415
|
+
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2416
|
+
|
|
2417
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2418
|
+
/**
|
|
2419
|
+
* Parses the technical information of a ContainerComponentType.
|
|
2420
|
+
* @param {Object} containerComponentType - A ContainerComponentType from VidiCore.
|
|
2421
|
+
* @returns {Object} Parsed component object.
|
|
2422
|
+
*/
|
|
2423
|
+
|
|
2424
|
+
var parseContainerComponentType = function parseContainerComponentType() {
|
|
2425
|
+
var containerComponentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2426
|
+
var _containerComponentTy = containerComponentType.mediaInfo,
|
|
2427
|
+
mediaInfo = _containerComponentTy === void 0 ? {} : _containerComponentTy,
|
|
2428
|
+
_containerComponentTy2 = containerComponentType.metadata,
|
|
2429
|
+
metadata = _containerComponentTy2 === void 0 ? [] : _containerComponentTy2,
|
|
2430
|
+
fileList = containerComponentType.file,
|
|
2431
|
+
durationTimeCode = containerComponentType.duration,
|
|
2432
|
+
startTimestamp = containerComponentType.startTimestamp,
|
|
2433
|
+
startTimecode = containerComponentType.startTimecode,
|
|
2434
|
+
timeCodeTimeBase = containerComponentType.timeCodeTimeBase;
|
|
1769
2435
|
var containerMetadata = parseKeyValuePairType(metadata);
|
|
1770
2436
|
var containerMediaInfo = parseBaseMediaInfoType(mediaInfo);
|
|
1771
2437
|
var containerFormat = containerMediaInfo.Format;
|
|
@@ -1774,7 +2440,7 @@ var parseContainerComponent = function parseContainerComponent(containerComponen
|
|
|
1774
2440
|
textFormat = containerMediaInfo.Text_Format_List;
|
|
1775
2441
|
|
|
1776
2442
|
if (containerFormat === undefined) {
|
|
1777
|
-
var format =
|
|
2443
|
+
var format = containerComponentType.format;
|
|
1778
2444
|
containerFormat = format;
|
|
1779
2445
|
|
|
1780
2446
|
if (format && format.includes(',')) {
|
|
@@ -1786,7 +2452,7 @@ var parseContainerComponent = function parseContainerComponent(containerComponen
|
|
|
1786
2452
|
}
|
|
1787
2453
|
}
|
|
1788
2454
|
|
|
1789
|
-
var
|
|
2455
|
+
var parsedContainerComponentType = {
|
|
1790
2456
|
containerFormat: containerFormat,
|
|
1791
2457
|
videoFormat: videoFormat,
|
|
1792
2458
|
audioFormat: audioFormat,
|
|
@@ -1796,20 +2462,21 @@ var parseContainerComponent = function parseContainerComponent(containerComponen
|
|
|
1796
2462
|
};
|
|
1797
2463
|
|
|
1798
2464
|
if (containerMetadata.componentOriginalFilename) {
|
|
1799
|
-
|
|
2465
|
+
parsedContainerComponentType.originalFilename = containerMetadata.componentOriginalFilename;
|
|
1800
2466
|
}
|
|
1801
2467
|
|
|
1802
2468
|
if (durationTimeCode !== undefined && durationTimeCode.samples !== 0) {
|
|
1803
|
-
|
|
1804
|
-
|
|
2469
|
+
var timeCode = formatTimeCodeType(durationTimeCode);
|
|
2470
|
+
parsedContainerComponentType.durationTimeCode = timeCode.toObject();
|
|
2471
|
+
parsedContainerComponentType.duration = timeCode.toDuration();
|
|
1805
2472
|
}
|
|
1806
2473
|
|
|
1807
2474
|
if (startTimestamp) {
|
|
1808
|
-
|
|
2475
|
+
parsedContainerComponentType.startTimestamp = formatTimeCodeType(startTimestamp).toObject();
|
|
1809
2476
|
}
|
|
1810
2477
|
|
|
1811
2478
|
if (startTimecode !== undefined && timeCodeTimeBase) {
|
|
1812
|
-
|
|
2479
|
+
parsedContainerComponentType.startTimecode = formatTimeCodeType({
|
|
1813
2480
|
samples: startTimecode,
|
|
1814
2481
|
timeBase: timeCodeTimeBase
|
|
1815
2482
|
});
|
|
@@ -1820,22 +2487,29 @@ var parseContainerComponent = function parseContainerComponent(containerComponen
|
|
|
1820
2487
|
fileType = _fileList[0];
|
|
1821
2488
|
|
|
1822
2489
|
var parsedFileType = parseFileType(fileType);
|
|
1823
|
-
|
|
2490
|
+
parsedContainerComponentType = _objectSpread$1(_objectSpread$1({}, parsedContainerComponentType), parsedFileType);
|
|
1824
2491
|
}
|
|
1825
2492
|
|
|
1826
|
-
return
|
|
2493
|
+
return parsedContainerComponentType;
|
|
1827
2494
|
};
|
|
1828
2495
|
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
2496
|
+
/**
|
|
2497
|
+
* Parses the technical information of a VideoComponentType.
|
|
2498
|
+
* @param {Object} videoComponentType - A VideoComponentType from VidiCore.
|
|
2499
|
+
* @returns {Object} Parsed component object.
|
|
2500
|
+
*/
|
|
2501
|
+
|
|
2502
|
+
var parseVideoComponentType = function parseVideoComponentType() {
|
|
2503
|
+
var videoComponentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2504
|
+
var videoCodec = videoComponentType.codec,
|
|
2505
|
+
bitrate = videoComponentType.bitrate,
|
|
2506
|
+
fieldOrder = videoComponentType.fieldOrder,
|
|
2507
|
+
_videoComponentType$r = videoComponentType.resolution,
|
|
2508
|
+
resolution = _videoComponentType$r === void 0 ? {} : _videoComponentType$r,
|
|
2509
|
+
_videoComponentType$m = videoComponentType.mediaInfo,
|
|
2510
|
+
mediaInfo = _videoComponentType$m === void 0 ? {} : _videoComponentType$m,
|
|
2511
|
+
_videoComponentType$m2 = videoComponentType.metadata,
|
|
2512
|
+
metadata = _videoComponentType$m2 === void 0 ? [] : _videoComponentType$m2;
|
|
1839
2513
|
var videoMediaInfo = parseBaseMediaInfoType(mediaInfo);
|
|
1840
2514
|
var videoMetadata = parseKeyValuePairType(metadata);
|
|
1841
2515
|
var videoFormat = videoMediaInfo.Format,
|
|
@@ -1844,8 +2518,8 @@ var parseVideoComponent = function parseVideoComponent(videoComponent) {
|
|
|
1844
2518
|
colorPrimaries = videoMediaInfo['Color primaries'],
|
|
1845
2519
|
chromaSubsampling = videoMediaInfo.Colorimetry;
|
|
1846
2520
|
var timeBase;
|
|
1847
|
-
var averageFrameRate =
|
|
1848
|
-
realBaseFrameRate =
|
|
2521
|
+
var averageFrameRate = videoComponentType.averageFrameRate,
|
|
2522
|
+
realBaseFrameRate = videoComponentType.realBaseFrameRate;
|
|
1849
2523
|
|
|
1850
2524
|
if (realBaseFrameRate !== undefined) {
|
|
1851
2525
|
timeBase = {
|
|
@@ -1864,7 +2538,7 @@ var parseVideoComponent = function parseVideoComponent(videoComponent) {
|
|
|
1864
2538
|
var samples = videoMediaInfo['Frame count'];
|
|
1865
2539
|
|
|
1866
2540
|
if (samples === undefined) {
|
|
1867
|
-
var numberOfPackets =
|
|
2541
|
+
var numberOfPackets = videoComponentType.numberOfPackets;
|
|
1868
2542
|
if (numberOfPackets !== undefined) samples = numberOfPackets;
|
|
1869
2543
|
}
|
|
1870
2544
|
|
|
@@ -1877,8 +2551,10 @@ var parseVideoComponent = function parseVideoComponent(videoComponent) {
|
|
|
1877
2551
|
samples: samples,
|
|
1878
2552
|
timeBase: timeBase
|
|
1879
2553
|
});
|
|
1880
|
-
frameRate = timeCode.timeBase.toRate(
|
|
1881
|
-
|
|
2554
|
+
frameRate = timeCode.timeBase.toRate({
|
|
2555
|
+
constant: true
|
|
2556
|
+
});
|
|
2557
|
+
smpte = timeCode.toSmpte();
|
|
1882
2558
|
}
|
|
1883
2559
|
|
|
1884
2560
|
var height = resolution.height,
|
|
@@ -1909,69 +2585,21 @@ var parseVideoComponent = function parseVideoComponent(videoComponent) {
|
|
|
1909
2585
|
};
|
|
1910
2586
|
};
|
|
1911
2587
|
|
|
1912
|
-
var
|
|
1913
|
-
var _audioComponent$timeB = audioComponent.timeBase,
|
|
1914
|
-
timeBase = _audioComponent$timeB === void 0 ? {} : _audioComponent$timeB,
|
|
1915
|
-
audioChannels = audioComponent.channelCount,
|
|
1916
|
-
audioCodec = audioComponent.codec,
|
|
1917
|
-
_audioComponent$media = audioComponent.mediaInfo,
|
|
1918
|
-
mediaInfo = _audioComponent$media === void 0 ? {} : _audioComponent$media,
|
|
1919
|
-
bitrate = audioComponent.bitrate,
|
|
1920
|
-
_audioComponent$metad = audioComponent.metadata,
|
|
1921
|
-
metadata = _audioComponent$metad === void 0 ? [] : _audioComponent$metad;
|
|
1922
|
-
var audioMediaInfo = parseBaseMediaInfoType(mediaInfo);
|
|
1923
|
-
var audioMetadata = parseKeyValuePairType(metadata);
|
|
1924
|
-
var audioFormat = audioMediaInfo.Format,
|
|
1925
|
-
audioBitDepth = audioMediaInfo.Resolution,
|
|
1926
|
-
audioBitRateMode = audioMediaInfo.Bit_rate_mode;
|
|
1927
|
-
var audioSamplerateSamples = timeBase.denominator ? timeBase.denominator / timeBase.numerator : undefined;
|
|
1928
|
-
var audioSamplerate = audioSamplerateSamples ? parseFileSize(audioSamplerateSamples, {
|
|
1929
|
-
base: 10,
|
|
1930
|
-
round: 1,
|
|
1931
|
-
symbols: sampleRateSymbols
|
|
1932
|
-
}) : undefined;
|
|
1933
|
-
var audioBitrate = bitrate ? parseFileSize(bitrate, {
|
|
1934
|
-
base: 10,
|
|
1935
|
-
round: 2,
|
|
1936
|
-
symbols: bitRateSymbols
|
|
1937
|
-
}) : undefined;
|
|
1938
|
-
return {
|
|
1939
|
-
audioFormat: audioFormat,
|
|
1940
|
-
audioCodec: audioCodec,
|
|
1941
|
-
audioSamplerate: audioSamplerate,
|
|
1942
|
-
audioSamplerateSamples: audioSamplerateSamples,
|
|
1943
|
-
audioBitDepth: audioBitDepth,
|
|
1944
|
-
audioBitrate: audioBitrate,
|
|
1945
|
-
audioBitRateMode: audioBitRateMode,
|
|
1946
|
-
audioChannels: audioChannels,
|
|
1947
|
-
audioMediaInfo: audioMediaInfo,
|
|
1948
|
-
audioMetadata: audioMetadata
|
|
1949
|
-
};
|
|
1950
|
-
};
|
|
1951
|
-
|
|
1952
|
-
var parseBinaryComponent = function parseBinaryComponent(binaryComponent) {
|
|
1953
|
-
var fileList = binaryComponent.file,
|
|
1954
|
-
_binaryComponent$medi = binaryComponent.mediaInfo,
|
|
1955
|
-
mediaInfo = _binaryComponent$medi === void 0 ? {} : _binaryComponent$medi,
|
|
1956
|
-
_binaryComponent$meta = binaryComponent.metadata,
|
|
1957
|
-
metadata = _binaryComponent$meta === void 0 ? [] : _binaryComponent$meta;
|
|
1958
|
-
var binaryMetadata = parseKeyValuePairType(metadata);
|
|
1959
|
-
var binaryMediaInfo = parseBaseMediaInfoType(mediaInfo);
|
|
1960
|
-
var parsedBinaryComponent = {
|
|
1961
|
-
binaryMetadata: binaryMetadata,
|
|
1962
|
-
binaryMediaInfo: binaryMediaInfo
|
|
1963
|
-
};
|
|
1964
|
-
|
|
1965
|
-
if (fileList) {
|
|
1966
|
-
var _fileList2 = _slicedToArray(fileList, 1),
|
|
1967
|
-
fileType = _fileList2[0];
|
|
1968
|
-
|
|
1969
|
-
var parsedFileType = parseFileType(fileType);
|
|
1970
|
-
parsedBinaryComponent = _objectSpread(_objectSpread({}, parsedBinaryComponent), parsedFileType);
|
|
1971
|
-
}
|
|
2588
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1972
2589
|
|
|
1973
|
-
|
|
1974
|
-
|
|
2590
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2591
|
+
/**
|
|
2592
|
+
* Parses the technical information of a ShapeType and its various components.
|
|
2593
|
+
*
|
|
2594
|
+
* Will only parse the first videoComponent, audioComponent, binaryComponent in the corresponding array.
|
|
2595
|
+
* To parse a selected component see:
|
|
2596
|
+
* - {@link parseContainerComponentType}
|
|
2597
|
+
* - {@link parseVideoComponentType}
|
|
2598
|
+
* - {@link parseAudioComponentType}
|
|
2599
|
+
* - {@link parseBinaryComponentType}
|
|
2600
|
+
* @param {Object} shapeType - A ShapeType from VidiCore.
|
|
2601
|
+
* @returns {Object} Parsed shape object.
|
|
2602
|
+
*/
|
|
1975
2603
|
|
|
1976
2604
|
var parseShapeType = function parseShapeType() {
|
|
1977
2605
|
var shapeType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -1994,7 +2622,7 @@ var parseShapeType = function parseShapeType() {
|
|
|
1994
2622
|
parsedShape.mimeType = _mimeTypeList[0];
|
|
1995
2623
|
|
|
1996
2624
|
if (containerComponent) {
|
|
1997
|
-
var parsedContainerComponent =
|
|
2625
|
+
var parsedContainerComponent = parseContainerComponentType(containerComponent, shapeType);
|
|
1998
2626
|
parsedShape = _objectSpread(_objectSpread({}, parsedShape), parsedContainerComponent);
|
|
1999
2627
|
}
|
|
2000
2628
|
|
|
@@ -2002,7 +2630,7 @@ var parseShapeType = function parseShapeType() {
|
|
|
2002
2630
|
var _videoComponentList = _slicedToArray(videoComponentList, 1),
|
|
2003
2631
|
videoComponent = _videoComponentList[0];
|
|
2004
2632
|
|
|
2005
|
-
var parsedVideoComponent =
|
|
2633
|
+
var parsedVideoComponent = parseVideoComponentType(videoComponent, shapeType);
|
|
2006
2634
|
parsedShape = _objectSpread(_objectSpread({}, parsedShape), parsedVideoComponent);
|
|
2007
2635
|
}
|
|
2008
2636
|
|
|
@@ -2010,7 +2638,7 @@ var parseShapeType = function parseShapeType() {
|
|
|
2010
2638
|
var _audioComponentList = _slicedToArray(audioComponentList, 1),
|
|
2011
2639
|
audioComponent = _audioComponentList[0];
|
|
2012
2640
|
|
|
2013
|
-
var parsedAudioComponent =
|
|
2641
|
+
var parsedAudioComponent = parseAudioComponentType(audioComponent, shapeType);
|
|
2014
2642
|
parsedShape = _objectSpread(_objectSpread({}, parsedShape), parsedAudioComponent);
|
|
2015
2643
|
}
|
|
2016
2644
|
|
|
@@ -2018,13 +2646,47 @@ var parseShapeType = function parseShapeType() {
|
|
|
2018
2646
|
var _binaryComponentList = _slicedToArray(binaryComponentList, 1),
|
|
2019
2647
|
binaryComponent = _binaryComponentList[0];
|
|
2020
2648
|
|
|
2021
|
-
var parsedBinaryComponent =
|
|
2649
|
+
var parsedBinaryComponent = parseBinaryComponentType(binaryComponent, shapeType);
|
|
2022
2650
|
parsedShape = _objectSpread(_objectSpread({}, parsedShape), parsedBinaryComponent);
|
|
2023
2651
|
}
|
|
2024
2652
|
|
|
2025
2653
|
return parsedShape;
|
|
2026
2654
|
};
|
|
2027
2655
|
|
|
2656
|
+
/* eslint-disable no-console */
|
|
2657
|
+
/**
|
|
2658
|
+
* @deprecated please use {@link parseAudioComponentType}
|
|
2659
|
+
*/
|
|
2660
|
+
|
|
2661
|
+
var parseAudioComponent = function parseAudioComponent(audioComponent) {
|
|
2662
|
+
console.warn('parseAudioComponent is deprecated, please use parseAudioComponentType');
|
|
2663
|
+
return parseAudioComponentType(audioComponent);
|
|
2664
|
+
};
|
|
2665
|
+
/**
|
|
2666
|
+
* @deprecated please use {@link parseBinaryComponentType}
|
|
2667
|
+
*/
|
|
2668
|
+
|
|
2669
|
+
var parseBinaryComponent = function parseBinaryComponent(binaryComponent) {
|
|
2670
|
+
console.warn('parseBinaryComponent is deprecated, please use parseBinaryComponentType');
|
|
2671
|
+
return parseBinaryComponentType(binaryComponent);
|
|
2672
|
+
};
|
|
2673
|
+
/**
|
|
2674
|
+
* @deprecated please use {@link parseContainerComponentType}
|
|
2675
|
+
*/
|
|
2676
|
+
|
|
2677
|
+
var parseContainerComponent = function parseContainerComponent(containerComponent) {
|
|
2678
|
+
console.warn('parseContainerComponent is deprecated, please use parseContainerComponentType');
|
|
2679
|
+
return parseContainerComponentType(containerComponent);
|
|
2680
|
+
};
|
|
2681
|
+
/**
|
|
2682
|
+
* @deprecated please use {@link parseVideoComponentType}
|
|
2683
|
+
*/
|
|
2684
|
+
|
|
2685
|
+
var parseVideoComponent = function parseVideoComponent(videoComponent) {
|
|
2686
|
+
console.warn('parseVideoComponent is deprecated, please use parseVideoComponentType');
|
|
2687
|
+
return parseVideoComponentType(videoComponent);
|
|
2688
|
+
};
|
|
2689
|
+
|
|
2028
2690
|
var IMAGE_MIME_TYPES = ['image/apng', 'image/bmp', 'image/gif', 'image/jpeg', 'image/x-icon', 'image/png', 'image/svg+xml'];
|
|
2029
2691
|
var VIDEO_MIME_TYPES = ['video/mp4'];
|
|
2030
2692
|
var AUDIO_MIME_TYPES = ['audio/mp4', 'audio/mpeg', 'audio/x-aac', 'audio/aac', 'audio/x-wav', 'audio/wav', 'audio/accp', 'audio/ogg', 'audio/webm', 'audio/x-flac'];
|
|
@@ -2259,7 +2921,9 @@ var parseMediaConvertPreset = function parseMediaConvertPreset(transcodePresetTy
|
|
|
2259
2921
|
numerator: numerator
|
|
2260
2922
|
});
|
|
2261
2923
|
output.timeBase = timeBase;
|
|
2262
|
-
output.frameRate = timeBase.toRate(
|
|
2924
|
+
output.frameRate = timeBase.toRate({
|
|
2925
|
+
constant: true
|
|
2926
|
+
});
|
|
2263
2927
|
}
|
|
2264
2928
|
}
|
|
2265
2929
|
|
|
@@ -2304,7 +2968,9 @@ var parseTranscodePreset = function parseTranscodePreset(transcodePresetType) {
|
|
|
2304
2968
|
if (video.framerate) {
|
|
2305
2969
|
var timeBase = formatTimeBaseType(video.framerate);
|
|
2306
2970
|
output.timeBase = timeBase;
|
|
2307
|
-
output.frameRate = timeBase.toRate(
|
|
2971
|
+
output.frameRate = timeBase.toRate({
|
|
2972
|
+
constant: true
|
|
2973
|
+
});
|
|
2308
2974
|
}
|
|
2309
2975
|
|
|
2310
2976
|
if (video.scaling) {
|
|
@@ -2351,5 +3017,5 @@ var getDocumentType = function getDocumentType() {
|
|
|
2351
3017
|
return undefined;
|
|
2352
3018
|
};
|
|
2353
3019
|
|
|
2354
|
-
export { SYSTEM_FIELDGROUPS, SYSTEM_FIELDS, TimeBase, TimeCode, createFacetType, createMetadataType,
|
|
3020
|
+
export { SYSTEM_FIELDGROUPS, SYSTEM_FIELDS, TimeBase, TimeCode, createFacetType, createMetadataType, createTimeBase, createTimeCode, filterShapeSource, findNearestThumbnail, formatTimeBaseText, formatTimeBaseType, formatTimeCodeSeconds, formatTimeCodeSmpte, formatTimeCodeText, formatTimeCodeType, getDocumentType, getShapeMediaType, metadataTypeToWebVtt, parseAudioComponent, parseAudioComponentType, parseBinaryComponent, parseBinaryComponentType, parseContainerComponent, parseContainerComponentType, parseFacetType, parseFileType, parseHighlightTimespan, parseHighlightTimespanList, parseKeyValuePairType, parseMediaConvertPreset, parseMetadataType, parseNowDate, parseShapeType, parseSimpleMetadataType, parseTimespan, parseTimespanList, parseTranscodePreset, parseVideoComponent, parseVideoComponentType, roles };
|
|
2355
3021
|
//# sourceMappingURL=index.es.js.map
|