@remotion/media 4.0.423 → 4.0.424

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 (51) hide show
  1. package/dist/esm/index.mjs +21 -3
  2. package/dist/video-extraction/get-allocation-size.d.ts +2 -2
  3. package/dist/video-extraction/keyframe-bank.d.ts +2 -1
  4. package/package.json +6 -7
  5. package/dist/audio/allow-wait.js +0 -15
  6. package/dist/audio/audio-for-preview.js +0 -304
  7. package/dist/audio/audio-for-rendering.js +0 -194
  8. package/dist/audio/audio-preview-iterator.js +0 -176
  9. package/dist/audio/audio.js +0 -20
  10. package/dist/audio/props.js +0 -1
  11. package/dist/audio-extraction/audio-cache.js +0 -66
  12. package/dist/audio-extraction/audio-iterator.js +0 -132
  13. package/dist/audio-extraction/audio-manager.js +0 -113
  14. package/dist/audio-extraction/extract-audio.js +0 -132
  15. package/dist/audio-iterator-manager.js +0 -228
  16. package/dist/browser-can-use-webgl2.js +0 -13
  17. package/dist/caches.js +0 -61
  18. package/dist/calculate-playbacktime.js +0 -4
  19. package/dist/convert-audiodata/apply-volume.js +0 -17
  20. package/dist/convert-audiodata/combine-audiodata.js +0 -23
  21. package/dist/convert-audiodata/convert-audiodata.js +0 -73
  22. package/dist/convert-audiodata/resample-audiodata.js +0 -94
  23. package/dist/debug-overlay/preview-overlay.js +0 -42
  24. package/dist/extract-frame-and-audio.js +0 -101
  25. package/dist/get-sink.js +0 -15
  26. package/dist/get-time-in-seconds.js +0 -40
  27. package/dist/helpers/round-to-4-digits.js +0 -4
  28. package/dist/index.js +0 -12
  29. package/dist/is-type-of-error.js +0 -20
  30. package/dist/looped-frame.js +0 -10
  31. package/dist/media-player.js +0 -431
  32. package/dist/nonce-manager.js +0 -13
  33. package/dist/prewarm-iterator-for-looping.js +0 -56
  34. package/dist/render-timestamp-range.js +0 -9
  35. package/dist/show-in-timeline.js +0 -31
  36. package/dist/use-media-in-timeline.js +0 -103
  37. package/dist/video/props.js +0 -1
  38. package/dist/video/video-for-preview.js +0 -331
  39. package/dist/video/video-for-rendering.js +0 -263
  40. package/dist/video/video-preview-iterator.js +0 -122
  41. package/dist/video/video.js +0 -35
  42. package/dist/video-extraction/add-broadcast-channel-listener.js +0 -125
  43. package/dist/video-extraction/extract-frame-via-broadcast-channel.js +0 -113
  44. package/dist/video-extraction/extract-frame.js +0 -85
  45. package/dist/video-extraction/get-allocation-size.js +0 -6
  46. package/dist/video-extraction/get-frames-since-keyframe.js +0 -108
  47. package/dist/video-extraction/keyframe-bank.js +0 -159
  48. package/dist/video-extraction/keyframe-manager.js +0 -206
  49. package/dist/video-extraction/remember-actual-matroska-timestamps.js +0 -19
  50. package/dist/video-extraction/rotate-frame.js +0 -34
  51. package/dist/video-iterator-manager.js +0 -109
@@ -1,109 +0,0 @@
1
- import { CanvasSink } from 'mediabunny';
2
- import { Internals } from 'remotion';
3
- import { makePrewarmedVideoIteratorCache } from './prewarm-iterator-for-looping';
4
- import { createVideoIterator, } from './video/video-preview-iterator';
5
- export const videoIteratorManager = ({ delayPlaybackHandleIfNotPremounting, canvas, context, drawDebugOverlay, logLevel, getOnVideoFrameCallback, videoTrack, getEndTime, getStartTime, getIsLooping, }) => {
6
- let videoIteratorsCreated = 0;
7
- let videoFrameIterator = null;
8
- let framesRendered = 0;
9
- let currentDelayHandle = null;
10
- if (canvas) {
11
- canvas.width = videoTrack.displayWidth;
12
- canvas.height = videoTrack.displayHeight;
13
- }
14
- const canvasSink = new CanvasSink(videoTrack, {
15
- poolSize: 2,
16
- fit: 'contain',
17
- alpha: true,
18
- });
19
- const prewarmedVideoIteratorCache = makePrewarmedVideoIteratorCache(canvasSink);
20
- const drawFrame = (frame) => {
21
- if (context && canvas) {
22
- context.clearRect(0, 0, canvas.width, canvas.height);
23
- context.drawImage(frame.canvas, 0, 0);
24
- }
25
- framesRendered++;
26
- drawDebugOverlay();
27
- const callback = getOnVideoFrameCallback();
28
- if (callback) {
29
- callback(frame.canvas);
30
- }
31
- Internals.Log.trace({ logLevel, tag: '@remotion/media' }, `[MediaPlayer] Drew frame ${frame.timestamp.toFixed(3)}s`);
32
- };
33
- const startVideoIterator = async (timeToSeek, nonce) => {
34
- videoFrameIterator?.destroy();
35
- const iterator = createVideoIterator(timeToSeek, prewarmedVideoIteratorCache);
36
- videoIteratorsCreated++;
37
- videoFrameIterator = iterator;
38
- const delayHandle = delayPlaybackHandleIfNotPremounting();
39
- currentDelayHandle = delayHandle;
40
- let frameResult;
41
- try {
42
- frameResult = await iterator.getNext();
43
- }
44
- finally {
45
- delayHandle.unblock();
46
- currentDelayHandle = null;
47
- }
48
- if (iterator.isDestroyed()) {
49
- return;
50
- }
51
- if (nonce.isStale()) {
52
- return;
53
- }
54
- if (videoFrameIterator.isDestroyed()) {
55
- return;
56
- }
57
- if (!frameResult.value) {
58
- // media ended
59
- return;
60
- }
61
- drawFrame(frameResult.value);
62
- };
63
- const seek = async ({ newTime, nonce }) => {
64
- if (!videoFrameIterator) {
65
- return;
66
- }
67
- if (getIsLooping()) {
68
- // If less than 1 second from the end away, we pre-warm a new iterator
69
- if (getEndTime() - newTime < 1) {
70
- prewarmedVideoIteratorCache.prewarmIteratorForLooping({
71
- timeToSeek: getStartTime(),
72
- });
73
- }
74
- }
75
- // Should return immediately, so it's okay to not use Promise.all here
76
- const videoSatisfyResult = await videoFrameIterator.tryToSatisfySeek(newTime);
77
- // Doing this before the staleness check, because
78
- // frame might be better than what we currently have
79
- // TODO: check if this is actually true
80
- if (videoSatisfyResult.type === 'satisfied') {
81
- drawFrame(videoSatisfyResult.frame);
82
- return;
83
- }
84
- if (nonce.isStale()) {
85
- return;
86
- }
87
- await startVideoIterator(newTime, nonce);
88
- };
89
- return {
90
- startVideoIterator,
91
- getVideoIteratorsCreated: () => videoIteratorsCreated,
92
- seek,
93
- destroy: () => {
94
- prewarmedVideoIteratorCache.destroy();
95
- videoFrameIterator?.destroy();
96
- if (context && canvas) {
97
- context.clearRect(0, 0, canvas.width, canvas.height);
98
- }
99
- if (currentDelayHandle) {
100
- currentDelayHandle.unblock();
101
- currentDelayHandle = null;
102
- }
103
- videoFrameIterator = null;
104
- },
105
- getVideoFrameIterator: () => videoFrameIterator,
106
- drawFrame,
107
- getFramesRendered: () => framesRendered,
108
- };
109
- };