@remotion/media 4.0.352 → 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 (43) 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 +1 -7
  4. package/dist/audio-extraction/audio-iterator.d.ts +1 -1
  5. package/dist/audio-extraction/audio-iterator.js +2 -2
  6. package/dist/audio-extraction/audio-manager.d.ts +1 -1
  7. package/dist/audio-extraction/extract-audio.d.ts +7 -4
  8. package/dist/audio-extraction/extract-audio.js +16 -7
  9. package/dist/caches.d.ts +6 -6
  10. package/dist/caches.js +5 -6
  11. package/dist/convert-audiodata/apply-volume.d.ts +1 -0
  12. package/dist/convert-audiodata/apply-volume.js +17 -0
  13. package/dist/convert-audiodata/convert-audiodata.d.ts +2 -2
  14. package/dist/convert-audiodata/convert-audiodata.js +13 -7
  15. package/dist/convert-audiodata/resample-audiodata.d.ts +1 -2
  16. package/dist/convert-audiodata/resample-audiodata.js +42 -20
  17. package/dist/esm/index.mjs +242 -182
  18. package/dist/extract-frame-and-audio.d.ts +3 -2
  19. package/dist/extract-frame-and-audio.js +4 -3
  20. package/dist/looped-frame.d.ts +9 -0
  21. package/dist/looped-frame.js +10 -0
  22. package/dist/video/media-player.d.ts +28 -30
  23. package/dist/video/media-player.js +174 -314
  24. package/dist/video/new-video-for-preview.d.ts +1 -1
  25. package/dist/video/new-video-for-preview.js +12 -18
  26. package/dist/video/props.d.ts +0 -5
  27. package/dist/video/timeout-utils.d.ts +2 -0
  28. package/dist/video/timeout-utils.js +18 -0
  29. package/dist/video/video-for-preview.d.ts +11 -0
  30. package/dist/video/video-for-preview.js +113 -0
  31. package/dist/video/video-for-rendering.js +41 -31
  32. package/dist/video/video.js +2 -2
  33. package/dist/video-extraction/extract-frame-via-broadcast-channel.d.ts +4 -3
  34. package/dist/video-extraction/extract-frame-via-broadcast-channel.js +9 -5
  35. package/dist/video-extraction/extract-frame.d.ts +1 -1
  36. package/dist/video-extraction/extract-frame.js +3 -0
  37. package/dist/video-extraction/get-frames-since-keyframe.d.ts +1 -1
  38. package/dist/video-extraction/get-frames-since-keyframe.js +7 -8
  39. package/dist/video-extraction/keyframe-bank.d.ts +1 -1
  40. package/dist/video-extraction/keyframe-bank.js +7 -7
  41. package/dist/video-extraction/keyframe-manager.d.ts +1 -1
  42. package/dist/video-extraction/keyframe-manager.js +6 -6
  43. package/package.json +3 -3
@@ -1,15 +1,16 @@
1
1
  import type { LogLevel } from 'remotion';
2
2
  import type { PcmS16AudioData } from './convert-audiodata/convert-audiodata';
3
- export declare const extractFrameAndAudio: ({ src, timeInSeconds, logLevel, durationInSeconds, includeAudio, includeVideo, volume, loop, }: {
3
+ export declare const extractFrameAndAudio: ({ src, timeInSeconds, logLevel, durationInSeconds, playbackRate, includeAudio, includeVideo, loop, }: {
4
4
  src: string;
5
5
  timeInSeconds: number;
6
6
  logLevel: LogLevel;
7
7
  durationInSeconds: number;
8
+ playbackRate: number;
8
9
  includeAudio: boolean;
9
10
  includeVideo: boolean;
10
- volume: number;
11
11
  loop: boolean;
12
12
  }) => Promise<{
13
13
  frame: VideoFrame | null;
14
14
  audio: PcmS16AudioData | null;
15
+ durationInSeconds: number | null;
15
16
  }>;
@@ -1,6 +1,6 @@
1
1
  import { extractAudio } from './audio-extraction/extract-audio';
2
2
  import { extractFrame } from './video-extraction/extract-frame';
3
- export const extractFrameAndAudio = async ({ src, timeInSeconds, logLevel, durationInSeconds, includeAudio, includeVideo, volume, loop, }) => {
3
+ export const extractFrameAndAudio = async ({ src, timeInSeconds, logLevel, durationInSeconds, playbackRate, includeAudio, includeVideo, loop, }) => {
4
4
  const [frame, audio] = await Promise.all([
5
5
  includeVideo
6
6
  ? extractFrame({
@@ -15,14 +15,15 @@ export const extractFrameAndAudio = async ({ src, timeInSeconds, logLevel, durat
15
15
  src,
16
16
  timeInSeconds,
17
17
  durationInSeconds,
18
- volume,
19
18
  logLevel,
20
19
  loop,
20
+ playbackRate,
21
21
  })
22
22
  : null,
23
23
  ]);
24
24
  return {
25
25
  frame: frame?.toVideoFrame() ?? null,
26
- audio,
26
+ audio: audio?.data ?? null,
27
+ durationInSeconds: audio?.durationInSeconds ?? null,
27
28
  };
28
29
  };
@@ -0,0 +1,9 @@
1
+ import { type LoopVolumeCurveBehavior } from 'remotion';
2
+ export declare const frameForVolumeProp: ({ behavior, loop, assetDurationInSeconds, fps, frame, startsAt, }: {
3
+ behavior: LoopVolumeCurveBehavior;
4
+ loop: boolean;
5
+ assetDurationInSeconds: number;
6
+ fps: number;
7
+ frame: number;
8
+ startsAt: number;
9
+ }) => number;
@@ -0,0 +1,10 @@
1
+ export const frameForVolumeProp = ({ behavior, loop, assetDurationInSeconds, fps, frame, startsAt, }) => {
2
+ if (!loop) {
3
+ return frame + startsAt;
4
+ }
5
+ if (behavior === 'extend') {
6
+ return frame + startsAt;
7
+ }
8
+ const assetDurationInFrames = Math.floor(assetDurationInSeconds * fps) - startsAt;
9
+ return (frame % assetDurationInFrames) + startsAt;
10
+ };
@@ -1,4 +1,5 @@
1
- import { type LogLevel } from '../log';
1
+ import type { LogLevel } from 'remotion';
2
+ export declare const SEEK_THRESHOLD = 0.05;
2
3
  export declare class MediaPlayer {
3
4
  private canvas;
4
5
  private context;
@@ -11,54 +12,51 @@ export declare class MediaPlayer {
11
12
  private audioBufferIterator;
12
13
  private queuedAudioNodes;
13
14
  private gainNode;
14
- private expectedAudioTime;
15
15
  private sharedAudioContext;
16
- private mediaTimeOffset;
16
+ private audioSyncAnchor;
17
17
  private playing;
18
18
  private animationFrameId;
19
- private asyncId;
19
+ private videoAsyncId;
20
20
  private initialized;
21
21
  private totalDuration;
22
- private actualFps;
23
- private isStalled;
24
- private onStalledChangeCallback?;
25
- private lastAudioProgressAtMs;
26
- private lastNetworkActivityAtMs;
27
- private isNetworkActive;
28
- private isSeeking;
29
- private canStartAudio;
22
+ private isBuffering;
23
+ private onBufferingChangeCallback?;
24
+ private audioBufferHealth;
25
+ private audioIteratorStarted;
26
+ private readonly HEALTHY_BUFER_THRESHOLD_SECONDS;
30
27
  constructor({ canvas, src, logLevel, sharedAudioContext, }: {
31
28
  canvas: HTMLCanvasElement;
32
29
  src: string;
33
30
  logLevel: LogLevel;
34
- sharedAudioContext?: AudioContext | null;
31
+ sharedAudioContext: AudioContext;
35
32
  });
33
+ private input;
34
+ private isReady;
35
+ private hasAudio;
36
+ private isCurrentlyBuffering;
36
37
  initialize(startTime?: number): Promise<void>;
37
- seekTo(time: number): void;
38
- drawInitialFrame(time?: number): Promise<void>;
38
+ private cleanupAudioQueue;
39
+ private cleanAudioIteratorAndNodes;
40
+ seekTo(time: number): Promise<void>;
39
41
  play(): Promise<void>;
40
42
  pause(): void;
41
43
  dispose(): void;
42
- get currentTime(): number;
43
44
  private getPlaybackTime;
44
- get duration(): number;
45
- get isPlaying(): boolean;
46
- get stalled(): boolean;
47
- onStalledChange(callback: (isStalled: boolean) => void): void;
48
- private renderSingleFrame;
45
+ private scheduleAudioChunk;
46
+ onBufferingChange(callback: (isBuffering: boolean) => void): void;
47
+ private canRenderVideo;
49
48
  private startRenderLoop;
50
49
  private stopRenderLoop;
51
50
  private render;
51
+ private shouldRenderFrame;
52
+ private drawCurrentFrame;
53
+ private startAudioIterator;
52
54
  private startVideoIterator;
53
55
  private updateNextFrame;
54
- private tryStartAudio;
55
- private getCurrentTimeMs;
56
- private resetAudioProgressStopwatch;
57
- private getAudioLookaheadSec;
58
- private calculateAudioStallThresholdSec;
59
- private isNetworkStalled;
60
- private checkVideoStall;
61
- private checkIfStalled;
62
- private updateStalledState;
56
+ private bufferingStartedAtMs;
57
+ private minBufferingTimeoutMs;
58
+ private setBufferingState;
59
+ private maybeResumeFromBuffering;
60
+ private maybeForceResumeFromBuffering;
63
61
  private runAudioIterator;
64
62
  }