@remotion/media 4.0.457 → 4.0.458

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.
@@ -844,65 +844,90 @@ import { CanvasSink } from "mediabunny";
844
844
  import { Internals as Internals4 } from "remotion";
845
845
 
846
846
  // src/canvas-ahead-of-time.ts
847
+ var BUFFER_SIZE = 3;
847
848
  var canvasesAheadOfTime = (videoSink, startTimestamp) => {
848
849
  const iterator = videoSink.canvases(startTimestamp);
849
- let inFlight = iterator.next();
850
- let resolved = null;
851
- const trackResolution = () => {
852
- const captured = inFlight;
853
- captured.then((result) => {
854
- if (captured === inFlight) {
855
- resolved = result;
850
+ const buffer = [];
851
+ let chaining = false;
852
+ let reachedEnd = false;
853
+ let closed = false;
854
+ let inFlight = null;
855
+ const closeFrame = (frame) => {
856
+ frame.close?.();
857
+ };
858
+ const fillNext = () => {
859
+ if (chaining || reachedEnd || closed)
860
+ return;
861
+ if (buffer.length >= BUFFER_SIZE)
862
+ return;
863
+ chaining = true;
864
+ const slot = { promise: iterator.next(), resolved: null };
865
+ buffer.push(slot);
866
+ inFlight = slot.promise.then((result) => {
867
+ slot.resolved = result;
868
+ chaining = false;
869
+ inFlight = null;
870
+ if (result.done) {
871
+ reachedEnd = true;
872
+ return;
873
+ }
874
+ if (closed) {
875
+ closeFrame(result.value);
876
+ return;
856
877
  }
878
+ fillNext();
857
879
  }, () => {
858
- return;
880
+ chaining = false;
881
+ inFlight = null;
859
882
  });
860
883
  };
861
- trackResolution();
862
- const advance = () => {
863
- inFlight = iterator.next();
864
- resolved = null;
865
- trackResolution();
866
- };
884
+ fillNext();
867
885
  const next = () => {
868
- if (resolved) {
869
- if (resolved.done) {
886
+ const slot = buffer.shift();
887
+ fillNext();
888
+ if (!slot) {
889
+ if (reachedEnd || closed) {
870
890
  return { type: "ready", frame: null };
871
891
  }
872
- const frame = resolved.value;
873
- advance();
874
- return { type: "ready", frame };
892
+ const chain = inFlight;
893
+ return {
894
+ type: "pending",
895
+ wait: async () => {
896
+ await chain;
897
+ const next2 = buffer.shift();
898
+ fillNext();
899
+ if (!next2)
900
+ return null;
901
+ if (next2.resolved) {
902
+ return next2.resolved.done ? null : next2.resolved.value;
903
+ }
904
+ const result = await next2.promise;
905
+ return result.done ? null : result.value;
906
+ }
907
+ };
908
+ }
909
+ if (slot.resolved) {
910
+ if (slot.resolved.done) {
911
+ return { type: "ready", frame: null };
912
+ }
913
+ return { type: "ready", frame: slot.resolved.value };
875
914
  }
876
- const captured = inFlight;
877
915
  return {
878
916
  type: "pending",
879
917
  wait: async () => {
880
- const result = await captured;
881
- if (captured === inFlight && !result.done) {
882
- advance();
883
- }
918
+ const result = await slot.promise;
884
919
  return result.done ? null : result.value;
885
920
  }
886
921
  };
887
922
  };
888
- const closeFrame = (frame) => {
889
- frame.close?.();
890
- };
891
923
  const closeIterator = async () => {
892
- if (resolved) {
893
- if (!resolved.done) {
894
- closeFrame(resolved.value);
924
+ closed = true;
925
+ for (const slot of buffer) {
926
+ if (slot.resolved && !slot.resolved.done) {
927
+ closeFrame(slot.resolved.value);
895
928
  }
896
- } else {
897
- const captured = inFlight;
898
- captured.then((result) => {
899
- if (!result.done) {
900
- closeFrame(result.value);
901
- }
902
- }, () => {
903
- return;
904
- });
905
929
  }
930
+ buffer.length = 0;
906
931
  await iterator.return();
907
932
  };
908
933
  return { next, closeIterator };
@@ -1946,8 +1971,7 @@ var AudioForPreviewAssertedShowing = ({
1946
1971
  const [mediaPlayerReady, setMediaPlayerReady] = useState(false);
1947
1972
  const [shouldFallbackToNativeAudio, setShouldFallbackToNativeAudio] = useState(false);
1948
1973
  const [playing] = Timeline.usePlayingState();
1949
- const timelineContext = Internals7.useTimelineContext();
1950
- const globalPlaybackRate = timelineContext.playbackRate;
1974
+ const { playbackRate: globalPlaybackRate } = Internals7.usePlaybackRate();
1951
1975
  const sharedAudioContext = useContext2(SharedAudioContext);
1952
1976
  const buffer = useBufferState();
1953
1977
  const [mediaMuted] = useMediaMutedState();
@@ -4553,8 +4577,7 @@ var VideoForPreviewAssertedShowing = ({
4553
4577
  const [mediaPlayerReady, setMediaPlayerReady] = useState4(false);
4554
4578
  const [shouldFallbackToNativeVideo, setShouldFallbackToNativeVideo] = useState4(false);
4555
4579
  const [playing] = Timeline2.usePlayingState();
4556
- const timelineContext = Internals18.useTimelineContext();
4557
- const globalPlaybackRate = timelineContext.playbackRate;
4580
+ const { playbackRate: globalPlaybackRate } = Internals18.usePlaybackRate();
4558
4581
  const sharedAudioContext = useContext4(SharedAudioContext2);
4559
4582
  const buffer = useBufferState2();
4560
4583
  const [mediaMuted] = useMediaMutedState2();
@@ -5219,34 +5242,7 @@ var videoSchema = {
5219
5242
  description: "Playback Rate"
5220
5243
  },
5221
5244
  loop: { type: "boolean", default: false, description: "Loop" },
5222
- "style.translate": {
5223
- type: "translate",
5224
- step: 1,
5225
- default: "0px 0px",
5226
- description: "Position"
5227
- },
5228
- "style.scale": {
5229
- type: "number",
5230
- min: 0.05,
5231
- max: 100,
5232
- step: 0.01,
5233
- default: 1,
5234
- description: "Scale"
5235
- },
5236
- "style.rotate": {
5237
- type: "rotation",
5238
- step: 1,
5239
- default: "0deg",
5240
- description: "Rotation"
5241
- },
5242
- "style.opacity": {
5243
- type: "number",
5244
- min: 0,
5245
- max: 1,
5246
- step: 0.01,
5247
- default: 1,
5248
- description: "Opacity"
5249
- }
5245
+ ...Internals20.sequenceStyleSchema
5250
5246
  };
5251
5247
  var InnerVideo = ({
5252
5248
  src,
@@ -0,0 +1,37 @@
1
+ import type { InputAudioTrack, InputVideoTrack } from 'mediabunny';
2
+ import { AudioBufferSink, CanvasSink, Input } from 'mediabunny';
3
+ type VideoSinkBundle = {
4
+ videoTrack: InputVideoTrack;
5
+ canvasSink: CanvasSink;
6
+ };
7
+ type AudioSinkBundle = {
8
+ audioTrack: InputAudioTrack;
9
+ audioSink: AudioBufferSink;
10
+ };
11
+ export declare const acquireInput: ({ src, credentials, }: {
12
+ src: string;
13
+ credentials: RequestCredentials | undefined;
14
+ }) => Input<import("mediabunny").Source>;
15
+ export declare const releaseInput: ({ src, credentials, }: {
16
+ src: string;
17
+ credentials: RequestCredentials | undefined;
18
+ }) => void;
19
+ export declare const acquireVideoSink: ({ src, credentials, }: {
20
+ src: string;
21
+ credentials: RequestCredentials | undefined;
22
+ }) => Promise<VideoSinkBundle | null>;
23
+ export declare const releaseVideoSink: ({ src, credentials, }: {
24
+ src: string;
25
+ credentials: RequestCredentials | undefined;
26
+ }) => void;
27
+ export declare const acquireAudioSink: ({ src, credentials, audioStreamIndex, }: {
28
+ src: string;
29
+ credentials: RequestCredentials | undefined;
30
+ audioStreamIndex: number | null;
31
+ }) => Promise<AudioSinkBundle | null>;
32
+ export declare const releaseAudioSink: ({ src, credentials, audioStreamIndex, }: {
33
+ src: string;
34
+ credentials: RequestCredentials | undefined;
35
+ audioStreamIndex: number | null;
36
+ }) => void;
37
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/media",
3
- "version": "4.0.457",
3
+ "version": "4.0.458",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/esm/index.mjs",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "mediabunny": "1.42.0",
26
- "remotion": "4.0.457",
26
+ "remotion": "4.0.458",
27
27
  "zod": "4.3.6"
28
28
  },
29
29
  "peerDependencies": {
@@ -31,7 +31,7 @@
31
31
  "react-dom": ">=16.8.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@remotion/eslint-config-internal": "4.0.457",
34
+ "@remotion/eslint-config-internal": "4.0.458",
35
35
  "@vitest/browser-webdriverio": "4.0.9",
36
36
  "eslint": "9.19.0",
37
37
  "react": "19.2.3",
@@ -1,7 +0,0 @@
1
- export type PriorityRef = {
2
- current: () => number;
3
- };
4
- export declare const scheduleDecode: <T>({ getPriority, run, }: {
5
- getPriority: () => number;
6
- run: () => Promise<T>;
7
- }) => Promise<T>;
@@ -1,14 +0,0 @@
1
- export declare class AudioDecodeScheduler {
2
- private activeTurns;
3
- private nextId;
4
- private queue;
5
- private pendingBatch;
6
- private batchTimer;
7
- requestTurn(priority: number): Promise<number>;
8
- releaseTurn(id: number): void;
9
- private processBatch;
10
- private grant;
11
- private getMinActivePriority;
12
- private grantEligibleWaiters;
13
- }
14
- export declare const getAudioDecodeScheduler: (audioContext: AudioContext) => AudioDecodeScheduler;
@@ -1,14 +0,0 @@
1
- export type ObjectFitValue = 'fill' | 'contain' | 'cover' | 'none' | 'scale-down';
2
- /**
3
- * Draws a source image onto a canvas context with the specified object-fit behavior.
4
- * This implements object-fit at the canvas drawing level, which is more reliable
5
- * than CSS object-fit on canvas elements.
6
- */
7
- export declare const drawWithObjectFit: (ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, source: CanvasImageSource, options: {
8
- sourceWidth: number;
9
- sourceHeight: number;
10
- destWidth: number;
11
- destHeight: number;
12
- fit: ObjectFitValue;
13
- }) => void;
14
- export declare const parseObjectFit: (value: string | undefined) => ObjectFitValue | null;
@@ -1,11 +0,0 @@
1
- export declare const ALLOWED_GLOBAL_TIME_ANCHOR_SHIFT = 0.1;
2
- export declare const setGlobalTimeAnchor: ({ audioContext, audioSyncAnchor, absoluteTimeInSeconds, globalPlaybackRate, debugAudioScheduling, logLevel, }: {
3
- audioContext: AudioContext;
4
- audioSyncAnchor: {
5
- value: number;
6
- };
7
- absoluteTimeInSeconds: number;
8
- globalPlaybackRate: number;
9
- debugAudioScheduling: boolean;
10
- logLevel: "error" | "info" | "trace" | "verbose" | "warn";
11
- }) => void;
@@ -1,21 +0,0 @@
1
- import { type EffectDefinitionAndStack, type LoopDisplay, type SequenceControls } from 'remotion';
2
- import { type VolumeProp } from 'remotion';
3
- export declare const useMediaInTimeline: ({ volume, mediaVolume, src, mediaType, playbackRate, displayName, stack, showInTimeline, premountDisplay, postmountDisplay, loopDisplay, trimBefore, trimAfter, controls, _experimentalEffects, }: {
4
- volume: VolumeProp | undefined;
5
- mediaVolume: number;
6
- src: string | undefined;
7
- mediaType: "audio" | "video";
8
- playbackRate: number;
9
- displayName: string | null;
10
- stack: string | null;
11
- showInTimeline: boolean;
12
- premountDisplay: number | null;
13
- postmountDisplay: number | null;
14
- loopDisplay: LoopDisplay | undefined;
15
- trimBefore: number | undefined;
16
- trimAfter: number | undefined;
17
- controls: SequenceControls | undefined;
18
- _experimentalEffects: EffectDefinitionAndStack<unknown>[];
19
- }) => {
20
- id: string;
21
- };