remotion 4.0.15 → 4.0.17

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.
@@ -17,11 +17,15 @@ const resolveVideoConfig = ({ composition, editorProps: editorPropsOrUndefined,
17
17
  abortSignal: signal,
18
18
  })
19
19
  : null;
20
+ const fallbackProps = {
21
+ ...((_c = composition.defaultProps) !== null && _c !== void 0 ? _c : {}),
22
+ ...(inputProps !== null && inputProps !== void 0 ? inputProps : {}),
23
+ };
20
24
  if (calculatedProm !== null &&
21
25
  typeof calculatedProm === 'object' &&
22
26
  'then' in calculatedProm) {
23
27
  return calculatedProm.then((c) => {
24
- var _a, _b, _c;
28
+ var _a, _b;
25
29
  const { height, width, durationInFrames, fps } = validateCalculated({
26
30
  calculated: c,
27
31
  composition,
@@ -33,7 +37,7 @@ const resolveVideoConfig = ({ composition, editorProps: editorPropsOrUndefined,
33
37
  durationInFrames,
34
38
  id: composition.id,
35
39
  defaultProps: (_a = composition.defaultProps) !== null && _a !== void 0 ? _a : {},
36
- props: (_c = (_b = c.props) !== null && _b !== void 0 ? _b : composition.defaultProps) !== null && _c !== void 0 ? _c : {},
40
+ props: (_b = c.props) !== null && _b !== void 0 ? _b : fallbackProps,
37
41
  };
38
42
  });
39
43
  }
@@ -45,11 +49,8 @@ const resolveVideoConfig = ({ composition, editorProps: editorPropsOrUndefined,
45
49
  return {
46
50
  ...data,
47
51
  id: composition.id,
48
- defaultProps: (_c = composition.defaultProps) !== null && _c !== void 0 ? _c : {},
49
- props: {
50
- ...((_d = composition.defaultProps) !== null && _d !== void 0 ? _d : {}),
51
- ...(inputProps !== null && inputProps !== void 0 ? inputProps : {}),
52
- },
52
+ defaultProps: (_d = composition.defaultProps) !== null && _d !== void 0 ? _d : {},
53
+ props: fallbackProps,
53
54
  };
54
55
  }
55
56
  return {
@@ -32,8 +32,18 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
32
32
  if (!src) {
33
33
  throw new Error(`No 'src' attribute was passed to the ${tagName} element.`);
34
34
  }
35
- mediaRef.current.playbackRate = Math.max(0, playbackRate);
36
- const shouldBeTime = (0, get_current_time_js_1.getMediaTime)({
35
+ const playbackRateToSet = Math.max(0, playbackRate);
36
+ if (mediaRef.current.playbackRate !== playbackRateToSet) {
37
+ mediaRef.current.playbackRate = playbackRateToSet;
38
+ }
39
+ // Let's throttle the seeking to only every 10 frames when a video is playing to avoid bottlenecking
40
+ // the video tag.
41
+ if (playing) {
42
+ if (absoluteFrame % 10 !== 0) {
43
+ return;
44
+ }
45
+ }
46
+ const desiredUnclampedTime = (0, get_current_time_js_1.getMediaTime)({
37
47
  fps,
38
48
  frame,
39
49
  src,
@@ -41,15 +51,20 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
41
51
  startFrom: -mediaStartsAt,
42
52
  mediaType,
43
53
  });
54
+ const { duration } = mediaRef.current;
55
+ const shouldBeTime = !Number.isNaN(duration) && Number.isFinite(duration)
56
+ ? Math.min(duration, desiredUnclampedTime)
57
+ : desiredUnclampedTime;
44
58
  const isTime = mediaRef.current.currentTime;
45
59
  const timeShift = Math.abs(shouldBeTime - isTime);
46
- if (timeShift > acceptableTimeshift && !mediaRef.current.ended) {
60
+ if (timeShift > acceptableTimeshift) {
47
61
  // If scrubbing around, adjust timing
48
- // or if time shift is bigger than 0.2sec
62
+ // or if time shift is bigger than 0.45sec
49
63
  mediaRef.current.currentTime = shouldBeTime;
50
64
  if (!onlyWarnForMediaSeekingError) {
51
65
  (0, warn_about_non_seekable_media_js_1.warnAboutNonSeekableMedia)(mediaRef.current, onlyWarnForMediaSeekingError ? 'console-warning' : 'console-error');
52
66
  }
67
+ return;
53
68
  }
54
69
  // Only perform a seek if the time is not already the same.
55
70
  // Chrome rounds to 6 digits, so 0.033333333 -> 0.033333,
@@ -57,15 +72,15 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
57
72
  // Refer to the https://github.com/remotion-dev/video-buffering-example
58
73
  // which is fixed by only seeking conditionally.
59
74
  const makesSenseToSeek = Math.abs(mediaRef.current.currentTime - shouldBeTime) > 0.00001;
75
+ if (!makesSenseToSeek) {
76
+ return;
77
+ }
60
78
  if (!playing || absoluteFrame === 0) {
61
- if (makesSenseToSeek) {
62
- mediaRef.current.currentTime = shouldBeTime;
63
- }
79
+ mediaRef.current.currentTime = shouldBeTime;
80
+ return;
64
81
  }
65
82
  if (mediaRef.current.paused && !mediaRef.current.ended && playing) {
66
- if (makesSenseToSeek) {
67
- mediaRef.current.currentTime = shouldBeTime;
68
- }
83
+ mediaRef.current.currentTime = shouldBeTime;
69
84
  (0, play_and_handle_not_allowed_error_js_1.playAndHandleNotAllowedError)(mediaRef, mediaType);
70
85
  }
71
86
  }, [
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.15";
1
+ export declare const VERSION = "4.0.17";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // Automatically generated on publish
5
- exports.VERSION = '4.0.15';
5
+ exports.VERSION = '4.0.17';
@@ -59,7 +59,7 @@ function truthy(value) {
59
59
  }
60
60
 
61
61
  // Automatically generated on publish
62
- const VERSION = '4.0.15';
62
+ const VERSION = '4.0.17';
63
63
 
64
64
  const checkMultipleRemotionVersions = () => {
65
65
  if (typeof globalThis === 'undefined') {
@@ -549,11 +549,15 @@ const resolveVideoConfig = ({ composition, editorProps: editorPropsOrUndefined,
549
549
  abortSignal: signal,
550
550
  })
551
551
  : null;
552
+ const fallbackProps = {
553
+ ...((_c = composition.defaultProps) !== null && _c !== void 0 ? _c : {}),
554
+ ...(inputProps !== null && inputProps !== void 0 ? inputProps : {}),
555
+ };
552
556
  if (calculatedProm !== null &&
553
557
  typeof calculatedProm === 'object' &&
554
558
  'then' in calculatedProm) {
555
559
  return calculatedProm.then((c) => {
556
- var _a, _b, _c;
560
+ var _a, _b;
557
561
  const { height, width, durationInFrames, fps } = validateCalculated({
558
562
  calculated: c,
559
563
  composition,
@@ -565,7 +569,7 @@ const resolveVideoConfig = ({ composition, editorProps: editorPropsOrUndefined,
565
569
  durationInFrames,
566
570
  id: composition.id,
567
571
  defaultProps: (_a = composition.defaultProps) !== null && _a !== void 0 ? _a : {},
568
- props: (_c = (_b = c.props) !== null && _b !== void 0 ? _b : composition.defaultProps) !== null && _c !== void 0 ? _c : {},
572
+ props: (_b = c.props) !== null && _b !== void 0 ? _b : fallbackProps,
569
573
  };
570
574
  });
571
575
  }
@@ -577,11 +581,8 @@ const resolveVideoConfig = ({ composition, editorProps: editorPropsOrUndefined,
577
581
  return {
578
582
  ...data,
579
583
  id: composition.id,
580
- defaultProps: (_c = composition.defaultProps) !== null && _c !== void 0 ? _c : {},
581
- props: {
582
- ...((_d = composition.defaultProps) !== null && _d !== void 0 ? _d : {}),
583
- ...(inputProps !== null && inputProps !== void 0 ? inputProps : {}),
584
- },
584
+ defaultProps: (_d = composition.defaultProps) !== null && _d !== void 0 ? _d : {},
585
+ props: fallbackProps,
585
586
  };
586
587
  }
587
588
  return {
@@ -1776,7 +1777,14 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
1776
1777
  if (mediaRef.current.playbackRate !== playbackRateToSet) {
1777
1778
  mediaRef.current.playbackRate = playbackRateToSet;
1778
1779
  }
1779
- const _shouldBeTime = getMediaTime({
1780
+ // Let's throttle the seeking to only every 10 frames when a video is playing to avoid bottlenecking
1781
+ // the video tag.
1782
+ if (playing) {
1783
+ if (absoluteFrame % 10 !== 0) {
1784
+ return;
1785
+ }
1786
+ }
1787
+ const desiredUnclampedTime = getMediaTime({
1780
1788
  fps,
1781
1789
  frame,
1782
1790
  src,
@@ -1786,18 +1794,18 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
1786
1794
  });
1787
1795
  const { duration } = mediaRef.current;
1788
1796
  const shouldBeTime = !Number.isNaN(duration) && Number.isFinite(duration)
1789
- ? Math.min(duration, _shouldBeTime)
1790
- : _shouldBeTime;
1797
+ ? Math.min(duration, desiredUnclampedTime)
1798
+ : desiredUnclampedTime;
1791
1799
  const isTime = mediaRef.current.currentTime;
1792
1800
  const timeShift = Math.abs(shouldBeTime - isTime);
1793
1801
  if (timeShift > acceptableTimeshift) {
1794
1802
  // If scrubbing around, adjust timing
1795
1803
  // or if time shift is bigger than 0.45sec
1796
- console.log('seekingA', timeShift, mediaRef.current.currentTime, shouldBeTime);
1797
1804
  mediaRef.current.currentTime = shouldBeTime;
1798
1805
  if (!onlyWarnForMediaSeekingError) {
1799
1806
  warnAboutNonSeekableMedia(mediaRef.current, onlyWarnForMediaSeekingError ? 'console-warning' : 'console-error');
1800
1807
  }
1808
+ return;
1801
1809
  }
1802
1810
  // Only perform a seek if the time is not already the same.
1803
1811
  // Chrome rounds to 6 digits, so 0.033333333 -> 0.033333,
@@ -1805,17 +1813,15 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
1805
1813
  // Refer to the https://github.com/remotion-dev/video-buffering-example
1806
1814
  // which is fixed by only seeking conditionally.
1807
1815
  const makesSenseToSeek = Math.abs(mediaRef.current.currentTime - shouldBeTime) > 0.00001;
1816
+ if (!makesSenseToSeek) {
1817
+ return;
1818
+ }
1808
1819
  if (!playing || absoluteFrame === 0) {
1809
- if (makesSenseToSeek) {
1810
- console.log('seekingB');
1811
- mediaRef.current.currentTime = shouldBeTime;
1812
- }
1820
+ mediaRef.current.currentTime = shouldBeTime;
1821
+ return;
1813
1822
  }
1814
1823
  if (mediaRef.current.paused && !mediaRef.current.ended && playing) {
1815
- if (makesSenseToSeek) {
1816
- console.log('seekingC');
1817
- mediaRef.current.currentTime = shouldBeTime;
1818
- }
1824
+ mediaRef.current.currentTime = shouldBeTime;
1819
1825
  playAndHandleNotAllowedError(mediaRef, mediaType);
1820
1826
  }
1821
1827
  }, [
@@ -1,4 +1,4 @@
1
1
  // Automatically generated on publish
2
- const VERSION = '4.0.15';
2
+ const VERSION = '4.0.17';
3
3
 
4
4
  export { VERSION };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remotion",
3
- "version": "4.0.15",
3
+ "version": "4.0.17",
4
4
  "description": "Render videos in React",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",