Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

Commit 83ce830

Browse files
authored
feat: DEV-4028: Use $fps from task for frameRate (#1141)
* feat: DEV-4028: Use $fps from task for frameRate * Get back to always string frameRate * Fix default value * Another small fix, Label Stream was broken
1 parent 48c2943 commit 83ce830

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

Diff for: src/tags/object/Video/Video.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { getRoot, types } from 'mobx-state-tree';
22
import React from 'react';
33

4+
import { isTimeRelativelySimilar } from '../../../lib/AudioUltra';
45
import { AnnotationMixin } from '../../../mixins/AnnotationMixin';
6+
import IsReadyMixin from '../../../mixins/IsReadyMixin';
57
import ProcessAttrsMixin from '../../../mixins/ProcessAttrs';
6-
import ObjectBase from '../Base';
78
import { SyncMixin } from '../../../mixins/SyncMixin';
8-
import IsReadyMixin from '../../../mixins/IsReadyMixin';
9-
import { isTimeRelativelySimilar } from '../../../lib/AudioUltra';
9+
import { parseValue } from '../../../utils/data';
1010
import { FF_DEV_2715, isFF } from '../../../utils/feature-flags';
11+
import ObjectBase from '../Base';
1112

1213
const isFFDev2715 = isFF(FF_DEV_2715);
1314

@@ -40,7 +41,7 @@ const isFFDev2715 = isFF(FF_DEV_2715);
4041
* @meta_description Customize Label Studio with the Video tag for basic video annotation tasks for machine learning and data science projects.
4142
* @param {string} name Name of the element
4243
* @param {string} value URL of the video
43-
* @param {number} [frameRate=24] videp frame rate per second; default is 24
44+
* @param {number} [frameRate=24] video frame rate per second; default is 24; can use task data like `$fps`
4445
* @param {string} [sync] object name to sync with
4546
* @param {boolean} [muted=false] muted video
4647
* @param {number} [height=600] height of the video
@@ -114,10 +115,11 @@ const Model = types
114115

115116
return {
116117
afterCreate() {
117-
const { framerate } = self;
118+
const framerate = Number(parseValue(self.framerate, self.store.task?.dataObj));
118119

119-
if (!framerate) self.framerate = 24;
120-
else if (framerate < 1) self.framerate = 1 / framerate;
120+
if (!framerate || isNaN(framerate)) self.framerate = '24';
121+
else if (framerate < 1) self.framerate = String(1 / framerate);
122+
else self.framerate = String(framerate);
121123
},
122124

123125
triggerSyncPlay() {

0 commit comments

Comments
 (0)