@remotion/media 4.0.353 → 4.0.354

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.
Files changed (81) hide show
  1. package/dist/audio/audio-for-rendering.js +37 -27
  2. package/dist/audio/audio.js +6 -3
  3. package/dist/audio/props.d.ts +0 -5
  4. package/dist/audio-extraction/extract-audio.d.ts +6 -3
  5. package/dist/audio-extraction/extract-audio.js +16 -7
  6. package/dist/audio-for-rendering.d.ts +3 -0
  7. package/dist/audio-for-rendering.js +94 -0
  8. package/dist/audio.d.ts +3 -0
  9. package/dist/audio.js +60 -0
  10. package/dist/audiodata-to-array.d.ts +0 -0
  11. package/dist/audiodata-to-array.js +1 -0
  12. package/dist/convert-audiodata/apply-volume.d.ts +1 -0
  13. package/dist/convert-audiodata/apply-volume.js +17 -0
  14. package/dist/convert-audiodata/convert-audiodata.d.ts +2 -2
  15. package/dist/convert-audiodata/convert-audiodata.js +13 -7
  16. package/dist/convert-audiodata/data-types.d.ts +1 -0
  17. package/dist/convert-audiodata/data-types.js +22 -0
  18. package/dist/convert-audiodata/is-planar-format.d.ts +1 -0
  19. package/dist/convert-audiodata/is-planar-format.js +3 -0
  20. package/dist/convert-audiodata/log-audiodata.d.ts +1 -0
  21. package/dist/convert-audiodata/log-audiodata.js +8 -0
  22. package/dist/convert-audiodata/resample-audiodata.d.ts +1 -2
  23. package/dist/convert-audiodata/resample-audiodata.js +39 -18
  24. package/dist/convert-audiodata/trim-audiodata.d.ts +0 -0
  25. package/dist/convert-audiodata/trim-audiodata.js +1 -0
  26. package/dist/deserialized-audiodata.d.ts +15 -0
  27. package/dist/deserialized-audiodata.js +26 -0
  28. package/dist/esm/index.mjs +206 -120
  29. package/dist/extract-audio.d.ts +7 -0
  30. package/dist/extract-audio.js +98 -0
  31. package/dist/extract-frame-and-audio.d.ts +3 -2
  32. package/dist/extract-frame-and-audio.js +4 -3
  33. package/dist/extract-frame-via-broadcast-channel.d.ts +15 -0
  34. package/dist/extract-frame-via-broadcast-channel.js +104 -0
  35. package/dist/extract-frame.d.ts +27 -0
  36. package/dist/extract-frame.js +21 -0
  37. package/dist/extrct-audio.d.ts +7 -0
  38. package/dist/extrct-audio.js +94 -0
  39. package/dist/get-frames-since-keyframe.d.ts +22 -0
  40. package/dist/get-frames-since-keyframe.js +41 -0
  41. package/dist/keyframe-bank.d.ts +25 -0
  42. package/dist/keyframe-bank.js +120 -0
  43. package/dist/keyframe-manager.d.ts +23 -0
  44. package/dist/keyframe-manager.js +170 -0
  45. package/dist/looped-frame.d.ts +9 -0
  46. package/dist/looped-frame.js +10 -0
  47. package/dist/new-video-for-rendering.d.ts +3 -0
  48. package/dist/new-video-for-rendering.js +108 -0
  49. package/dist/new-video.d.ts +3 -0
  50. package/dist/new-video.js +37 -0
  51. package/dist/props.d.ts +29 -0
  52. package/dist/props.js +1 -0
  53. package/dist/remember-actual-matroska-timestamps.d.ts +4 -0
  54. package/dist/remember-actual-matroska-timestamps.js +19 -0
  55. package/dist/serialize-videoframe.d.ts +0 -0
  56. package/dist/serialize-videoframe.js +1 -0
  57. package/dist/video/media-player.d.ts +62 -0
  58. package/dist/video/media-player.js +361 -0
  59. package/dist/video/new-video-for-preview.d.ts +10 -0
  60. package/dist/video/new-video-for-preview.js +108 -0
  61. package/dist/video/props.d.ts +0 -5
  62. package/dist/video/timeout-utils.d.ts +2 -0
  63. package/dist/video/timeout-utils.js +18 -0
  64. package/dist/video/video-for-preview.d.ts +11 -0
  65. package/dist/video/video-for-preview.js +113 -0
  66. package/dist/video/video-for-rendering.js +41 -31
  67. package/dist/video/video.js +2 -2
  68. package/dist/video-extraction/extract-frame-via-broadcast-channel.d.ts +3 -2
  69. package/dist/video-extraction/extract-frame-via-broadcast-channel.js +9 -5
  70. package/dist/video-extraction/extract-frame.js +3 -0
  71. package/dist/video-extraction/get-frames-since-keyframe.d.ts +1 -1
  72. package/dist/video-extraction/get-frames-since-keyframe.js +6 -7
  73. package/dist/video-extraction/media-player.d.ts +64 -0
  74. package/dist/video-extraction/media-player.js +501 -0
  75. package/dist/video-extraction/new-video-for-preview.d.ts +10 -0
  76. package/dist/video-extraction/new-video-for-preview.js +114 -0
  77. package/dist/video-for-rendering.d.ts +3 -0
  78. package/dist/video-for-rendering.js +108 -0
  79. package/dist/video.d.ts +3 -0
  80. package/dist/video.js +37 -0
  81. package/package.json +3 -3
@@ -0,0 +1,108 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useContext, useLayoutEffect, useMemo, useRef, useState, } from 'react';
3
+ import { cancelRender, Internals, useCurrentFrame, useDelayRender, useRemotionEnvironment, } from 'remotion';
4
+ import { extractFrameViaBroadcastChannel } from './extract-frame-via-broadcast-channel';
5
+ export const VideoForRendering = ({ volume: volumeProp, playbackRate, src, muted, loopVolumeCurveBehavior, delayRenderRetries, delayRenderTimeoutInMilliseconds,
6
+ // call when a frame of the video, i.e. frame drawn on canvas
7
+ onVideoFrame, logLevel = window.remotion_logLevel, }) => {
8
+ const absoluteFrame = Internals.useTimelinePosition();
9
+ const videoConfig = Internals.useUnsafeVideoConfig();
10
+ const canvasRef = useRef(null);
11
+ const { registerRenderAsset, unregisterRenderAsset } = useContext(Internals.RenderAssetManager);
12
+ const frame = useCurrentFrame();
13
+ const volumePropsFrame = Internals.useFrameForVolumeProp(loopVolumeCurveBehavior ?? 'repeat');
14
+ const environment = useRemotionEnvironment();
15
+ const [id] = useState(() => `${Math.random()}`.replace('0.', ''));
16
+ if (!videoConfig) {
17
+ throw new Error('No video config found');
18
+ }
19
+ if (!src) {
20
+ throw new TypeError('No `src` was passed to <Video>.');
21
+ }
22
+ const volume = Internals.evaluateVolume({
23
+ volume: volumeProp,
24
+ frame: volumePropsFrame,
25
+ mediaVolume: 1,
26
+ });
27
+ Internals.warnAboutTooHighVolume(volume);
28
+ const shouldRenderAudio = useMemo(() => {
29
+ if (!window.remotion_audioEnabled) {
30
+ return false;
31
+ }
32
+ if (muted) {
33
+ return false;
34
+ }
35
+ if (volume <= 0) {
36
+ return false;
37
+ }
38
+ return true;
39
+ }, [muted, volume]);
40
+ const { fps } = videoConfig;
41
+ const { delayRender, continueRender } = useDelayRender();
42
+ useLayoutEffect(() => {
43
+ if (!canvasRef.current) {
44
+ return;
45
+ }
46
+ const actualFps = playbackRate ? fps / playbackRate : fps;
47
+ const timestamp = frame / actualFps;
48
+ const durationInSeconds = 1 / actualFps;
49
+ const newHandle = delayRender(`Extracting frame number ${frame}`, {
50
+ retries: delayRenderRetries ?? undefined,
51
+ timeoutInMilliseconds: delayRenderTimeoutInMilliseconds ?? undefined,
52
+ });
53
+ extractFrameViaBroadcastChannel({
54
+ src,
55
+ timeInSeconds: timestamp,
56
+ durationInSeconds,
57
+ logLevel: logLevel ?? 'info',
58
+ shouldRenderAudio,
59
+ isClientSideRendering: environment.isClientSideRendering,
60
+ })
61
+ .then(({ frame: imageBitmap, audio }) => {
62
+ if (!imageBitmap) {
63
+ cancelRender(new Error('No video frame found'));
64
+ }
65
+ onVideoFrame?.(imageBitmap);
66
+ canvasRef.current?.getContext('2d')?.drawImage(imageBitmap, 0, 0);
67
+ imageBitmap.close();
68
+ if (audio) {
69
+ registerRenderAsset({
70
+ type: 'inline-audio',
71
+ id,
72
+ audio: Array.from(audio.data),
73
+ sampleRate: audio.sampleRate,
74
+ numberOfChannels: audio.numberOfChannels,
75
+ frame: absoluteFrame,
76
+ timestamp: audio.timestamp,
77
+ duration: (audio.numberOfFrames / audio.sampleRate) * 1000000,
78
+ });
79
+ }
80
+ continueRender(newHandle);
81
+ })
82
+ .catch((error) => {
83
+ cancelRender(error);
84
+ });
85
+ return () => {
86
+ continueRender(newHandle);
87
+ unregisterRenderAsset(id);
88
+ };
89
+ }, [
90
+ absoluteFrame,
91
+ continueRender,
92
+ delayRender,
93
+ delayRenderRetries,
94
+ delayRenderTimeoutInMilliseconds,
95
+ environment.isClientSideRendering,
96
+ fps,
97
+ frame,
98
+ id,
99
+ logLevel,
100
+ onVideoFrame,
101
+ playbackRate,
102
+ registerRenderAsset,
103
+ shouldRenderAudio,
104
+ src,
105
+ unregisterRenderAsset,
106
+ ]);
107
+ return (_jsx("canvas", { ref: canvasRef, width: videoConfig.width, height: videoConfig.height }));
108
+ };
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import type { VideoProps } from './props';
3
+ export declare const Video: React.FC<VideoProps>;
package/dist/video.js ADDED
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCallback } from 'react';
3
+ import { Internals, Sequence, useRemotionEnvironment } from 'remotion';
4
+ import { VideoForRendering } from './video-for-rendering';
5
+ const { validateMediaTrimProps, resolveTrimProps, validateMediaProps, VideoForPreview, } = Internals;
6
+ export const Video = (props) => {
7
+ // Should only destruct `trimBefore` and `trimAfter` from props,
8
+ // rest gets drilled down
9
+ const { trimBefore, trimAfter, name, pauseWhenBuffering, stack, showInTimeline, ...otherProps } = props;
10
+ const environment = useRemotionEnvironment();
11
+ const onDuration = useCallback(() => undefined, []);
12
+ if (typeof props.src !== 'string') {
13
+ throw new TypeError(`The \`<Video>\` tag requires a string for \`src\`, but got ${JSON.stringify(props.src)} instead.`);
14
+ }
15
+ validateMediaTrimProps({
16
+ startFrom: undefined,
17
+ endAt: undefined,
18
+ trimBefore,
19
+ trimAfter,
20
+ });
21
+ const { trimBeforeValue, trimAfterValue } = resolveTrimProps({
22
+ startFrom: undefined,
23
+ endAt: undefined,
24
+ trimBefore,
25
+ trimAfter,
26
+ });
27
+ if (typeof trimBeforeValue !== 'undefined' ||
28
+ typeof trimAfterValue !== 'undefined') {
29
+ return (_jsx(Sequence, { layout: "none", from: 0 - (trimBeforeValue ?? 0), showInTimeline: false, durationInFrames: trimAfterValue, name: name, children: _jsx(Video, { pauseWhenBuffering: pauseWhenBuffering ?? false, ...otherProps }) }));
30
+ }
31
+ validateMediaProps(props, 'Video');
32
+ if (environment.isRendering) {
33
+ return _jsx(VideoForRendering, { ...otherProps });
34
+ }
35
+ const { onAutoPlayError, onVideoFrame, crossOrigin, delayRenderRetries, delayRenderTimeoutInMilliseconds, ...propsForPreview } = otherProps;
36
+ return (_jsx(VideoForPreview, { _remotionInternalStack: stack ?? null, _remotionInternalNativeLoopPassed: false, onDuration: onDuration, onlyWarnForMediaSeekingError: true, pauseWhenBuffering: pauseWhenBuffering ?? false, showInTimeline: showInTimeline ?? true, onAutoPlayError: onAutoPlayError ?? undefined, onVideoFrame: onVideoFrame ?? null, crossOrigin: crossOrigin, ...propsForPreview }));
37
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/media",
3
- "version": "4.0.353",
3
+ "version": "4.0.354",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/esm/index.mjs",
@@ -15,7 +15,7 @@
15
15
  "dependencies": {
16
16
  "mediabunny": "1.17.0",
17
17
  "webdriverio": "9.19.2",
18
- "remotion": "4.0.353"
18
+ "remotion": "4.0.354"
19
19
  },
20
20
  "peerDependencies": {
21
21
  "react": ">=16.8.0",
@@ -27,7 +27,7 @@
27
27
  "react": "19.0.0",
28
28
  "react-dom": "19.0.0",
29
29
  "vitest": "3.2.4",
30
- "@remotion/eslint-config-internal": "4.0.353"
30
+ "@remotion/eslint-config-internal": "4.0.354"
31
31
  },
32
32
  "keywords": [],
33
33
  "publishConfig": {