@remotion/media 4.0.402 → 4.0.404

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 (77) hide show
  1. package/dist/audio/audio-for-preview.d.ts +2 -0
  2. package/dist/audio/audio-preview-iterator.d.ts +8 -3
  3. package/dist/audio/props.d.ts +2 -0
  4. package/dist/audio-extraction/audio-iterator.d.ts +5 -4
  5. package/dist/audio-extraction/audio-manager.d.ts +23 -7
  6. package/dist/audio-extraction/extract-audio.d.ts +2 -4
  7. package/dist/audio-iterator-manager.d.ts +2 -2
  8. package/dist/caches.d.ts +34 -17
  9. package/dist/convert-audiodata/apply-volume.d.ts +1 -1
  10. package/dist/convert-audiodata/resample-audiodata.d.ts +2 -2
  11. package/dist/debug-overlay/preview-overlay.d.ts +83 -5
  12. package/dist/esm/index.mjs +524 -476
  13. package/dist/extract-frame-and-audio.d.ts +1 -2
  14. package/dist/get-sink.d.ts +1 -2
  15. package/dist/index.d.ts +2 -1
  16. package/dist/media-player.d.ts +1 -1
  17. package/dist/on-error.d.ts +12 -0
  18. package/dist/show-in-timeline.d.ts +2 -2
  19. package/dist/use-media-in-timeline.d.ts +2 -2
  20. package/dist/video/props.d.ts +5 -0
  21. package/dist/video/video-for-preview.d.ts +2 -0
  22. package/dist/video/video-for-rendering.d.ts +2 -0
  23. package/dist/video/video-preview-iterator.d.ts +7 -2
  24. package/dist/video-extraction/extract-frame-via-broadcast-channel.d.ts +1 -2
  25. package/dist/video-extraction/extract-frame.d.ts +2 -4
  26. package/dist/video-extraction/get-frames-since-keyframe.d.ts +2 -12
  27. package/dist/video-extraction/keyframe-bank.d.ts +14 -12
  28. package/dist/video-extraction/keyframe-manager.d.ts +7 -9
  29. package/dist/video-iterator-manager.d.ts +4 -5
  30. package/package.json +8 -7
  31. package/dist/audio/allow-wait.js +0 -15
  32. package/dist/audio/audio-for-preview.js +0 -304
  33. package/dist/audio/audio-for-rendering.js +0 -194
  34. package/dist/audio/audio-preview-iterator.js +0 -176
  35. package/dist/audio/audio.js +0 -20
  36. package/dist/audio/props.js +0 -1
  37. package/dist/audio-extraction/audio-cache.js +0 -66
  38. package/dist/audio-extraction/audio-iterator.js +0 -132
  39. package/dist/audio-extraction/audio-manager.js +0 -113
  40. package/dist/audio-extraction/extract-audio.js +0 -132
  41. package/dist/audio-iterator-manager.js +0 -228
  42. package/dist/browser-can-use-webgl2.js +0 -13
  43. package/dist/caches.js +0 -61
  44. package/dist/calculate-playbacktime.js +0 -4
  45. package/dist/convert-audiodata/apply-volume.js +0 -17
  46. package/dist/convert-audiodata/combine-audiodata.js +0 -23
  47. package/dist/convert-audiodata/convert-audiodata.js +0 -73
  48. package/dist/convert-audiodata/resample-audiodata.js +0 -94
  49. package/dist/debug-overlay/preview-overlay.js +0 -44
  50. package/dist/extract-frame-and-audio.js +0 -101
  51. package/dist/get-sink.js +0 -15
  52. package/dist/get-time-in-seconds.js +0 -40
  53. package/dist/helpers/round-to-4-digits.js +0 -4
  54. package/dist/index.js +0 -12
  55. package/dist/is-type-of-error.js +0 -20
  56. package/dist/looped-frame.js +0 -10
  57. package/dist/media-player.js +0 -445
  58. package/dist/nonce-manager.js +0 -13
  59. package/dist/prewarm-iterator-for-looping.js +0 -56
  60. package/dist/render-timestamp-range.js +0 -9
  61. package/dist/show-in-timeline.js +0 -31
  62. package/dist/use-media-in-timeline.js +0 -103
  63. package/dist/video/props.js +0 -1
  64. package/dist/video/video-for-preview.js +0 -329
  65. package/dist/video/video-for-rendering.js +0 -263
  66. package/dist/video/video-preview-iterator.js +0 -122
  67. package/dist/video/video.js +0 -35
  68. package/dist/video-extraction/add-broadcast-channel-listener.js +0 -125
  69. package/dist/video-extraction/extract-frame-via-broadcast-channel.js +0 -113
  70. package/dist/video-extraction/extract-frame.js +0 -85
  71. package/dist/video-extraction/get-allocation-size.js +0 -6
  72. package/dist/video-extraction/get-frames-since-keyframe.js +0 -108
  73. package/dist/video-extraction/keyframe-bank.js +0 -159
  74. package/dist/video-extraction/keyframe-manager.js +0 -206
  75. package/dist/video-extraction/remember-actual-matroska-timestamps.js +0 -19
  76. package/dist/video-extraction/rotate-frame.js +0 -34
  77. 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
- };