@remotion/media 4.0.377 → 4.0.379

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.
@@ -17,6 +17,6 @@ type ExtractAudioParams = {
17
17
  declare const extractAudioInternal: ({ src, timeInSeconds: unloopedTimeInSeconds, durationInSeconds: durationNotYetApplyingPlaybackRate, logLevel, loop, playbackRate, audioStreamIndex, trimBefore, trimAfter, fps, maxCacheSize, }: ExtractAudioParams) => Promise<{
18
18
  data: PcmS16AudioData | null;
19
19
  durationInSeconds: number | null;
20
- } | "cannot-decode" | "unknown-container-format">;
20
+ } | "cannot-decode" | "unknown-container-format" | "network-error">;
21
21
  export declare const extractAudio: (params: ExtractAudioParams) => Promise<ExtractAudioReturnType>;
22
22
  export {};
@@ -11,6 +11,9 @@ const extractAudioInternal = async ({ src, timeInSeconds: unloopedTimeInSeconds,
11
11
  mediaDurationInSeconds = await getDuration();
12
12
  }
13
13
  const audio = await getAudio(audioStreamIndex);
14
+ if (audio === 'network-error') {
15
+ return 'network-error';
16
+ }
14
17
  if (audio === 'no-audio-track') {
15
18
  return { data: null, durationInSeconds: null };
16
19
  }
@@ -2208,10 +2208,13 @@ var rememberActualMatroskaTimestamps = (isMatroska) => {
2208
2208
  var getRetryDelay = () => {
2209
2209
  return null;
2210
2210
  };
2211
- var getFormatOrNull = async (input) => {
2211
+ var getFormatOrNullOrNetworkError = async (input) => {
2212
2212
  try {
2213
2213
  return await input.getFormat();
2214
- } catch {
2214
+ } catch (err) {
2215
+ if (isNetworkError(err)) {
2216
+ return "network-error";
2217
+ }
2215
2218
  return null;
2216
2219
  }
2217
2220
  };
@@ -2222,9 +2225,12 @@ var getSinks = async (src) => {
2222
2225
  getRetryDelay
2223
2226
  })
2224
2227
  });
2225
- const format = await getFormatOrNull(input);
2228
+ const format = await getFormatOrNullOrNetworkError(input);
2226
2229
  const isMatroska = format === MATROSKA || format === WEBM;
2227
2230
  const getVideoSinks = async () => {
2231
+ if (format === "network-error") {
2232
+ return "network-error";
2233
+ }
2228
2234
  if (format === null) {
2229
2235
  return "unknown-container-format";
2230
2236
  }
@@ -2254,6 +2260,9 @@ var getSinks = async (src) => {
2254
2260
  if (format === null) {
2255
2261
  return "unknown-container-format";
2256
2262
  }
2263
+ if (format === "network-error") {
2264
+ return "network-error";
2265
+ }
2257
2266
  const audioTracks = await input.getAudioTracks();
2258
2267
  const audioTrack = audioTracks[index];
2259
2268
  if (!audioTrack) {
@@ -2833,6 +2842,9 @@ var extractAudioInternal = async ({
2833
2842
  mediaDurationInSeconds = await getDuration();
2834
2843
  }
2835
2844
  const audio = await getAudio(audioStreamIndex);
2845
+ if (audio === "network-error") {
2846
+ return "network-error";
2847
+ }
2836
2848
  if (audio === "no-audio-track") {
2837
2849
  return { data: null, durationInSeconds: null };
2838
2850
  }
@@ -2951,6 +2963,9 @@ var extractFrameInternal = async ({
2951
2963
  if (video === "unknown-container-format") {
2952
2964
  return { type: "unknown-container-format" };
2953
2965
  }
2966
+ if (video === "network-error") {
2967
+ return { type: "network-error" };
2968
+ }
2954
2969
  let mediaDurationInSeconds = null;
2955
2970
  if (loop) {
2956
2971
  mediaDurationInSeconds = await sink.getDuration();
@@ -3094,12 +3109,21 @@ var extractFrameAndAudio = async ({
3094
3109
  durationInSeconds: frame.durationInSeconds
3095
3110
  };
3096
3111
  }
3112
+ if (frame?.type === "network-error") {
3113
+ return { type: "network-error" };
3114
+ }
3097
3115
  if (audio === "unknown-container-format") {
3098
3116
  if (frame !== null) {
3099
3117
  frame?.frame?.close();
3100
3118
  }
3101
3119
  return { type: "unknown-container-format" };
3102
3120
  }
3121
+ if (audio === "network-error") {
3122
+ if (frame !== null) {
3123
+ frame?.frame?.close();
3124
+ }
3125
+ return { type: "network-error" };
3126
+ }
3103
3127
  if (audio === "cannot-decode") {
3104
3128
  if (frame?.type === "success" && frame.frame !== null) {
3105
3129
  frame?.frame.close();
@@ -4091,7 +4115,7 @@ var VideoForRendering = ({
4091
4115
  cancelRender3(new Error(`Cannot decode ${src}, and 'disallowFallbackToOffthreadVideo' was set. Failing the render.`));
4092
4116
  }
4093
4117
  if (window.remotion_isMainTab) {
4094
- Internals16.Log.info({ logLevel, tag: "@remotion/media" }, `Network error fetching ${src}, falling back to <OffthreadVideo>`);
4118
+ Internals16.Log.warn({ logLevel, tag: "@remotion/media" }, `Network error fetching ${src} (no CORS?), falling back to <OffthreadVideo>`);
4095
4119
  }
4096
4120
  setReplaceWithOffthreadVideo({ durationInSeconds: null });
4097
4121
  return;
@@ -49,12 +49,21 @@ export const extractFrameAndAudio = async ({ src, timeInSeconds, logLevel, durat
49
49
  durationInSeconds: frame.durationInSeconds,
50
50
  };
51
51
  }
52
+ if (frame?.type === 'network-error') {
53
+ return { type: 'network-error' };
54
+ }
52
55
  if (audio === 'unknown-container-format') {
53
56
  if (frame !== null) {
54
57
  frame?.frame?.close();
55
58
  }
56
59
  return { type: 'unknown-container-format' };
57
60
  }
61
+ if (audio === 'network-error') {
62
+ if (frame !== null) {
63
+ frame?.frame?.close();
64
+ }
65
+ return { type: 'network-error' };
66
+ }
58
67
  if (audio === 'cannot-decode') {
59
68
  if (frame?.type === 'success' && frame.frame !== null) {
60
69
  frame?.frame.close();
@@ -116,7 +116,7 @@ export const VideoForRendering = ({ volume: volumeProp, playbackRate, src, muted
116
116
  cancelRender(new Error(`Cannot decode ${src}, and 'disallowFallbackToOffthreadVideo' was set. Failing the render.`));
117
117
  }
118
118
  if (window.remotion_isMainTab) {
119
- Internals.Log.info({ logLevel, tag: '@remotion/media' }, `Network error fetching ${src}, falling back to <OffthreadVideo>`);
119
+ Internals.Log.warn({ logLevel, tag: '@remotion/media' }, `Network error fetching ${src} (no CORS?), falling back to <OffthreadVideo>`);
120
120
  }
121
121
  setReplaceWithOffthreadVideo({ durationInSeconds: null });
122
122
  return;
@@ -12,6 +12,8 @@ type ExtractFrameResult = {
12
12
  durationInSeconds: number | null;
13
13
  } | {
14
14
  type: 'unknown-container-format';
15
+ } | {
16
+ type: 'network-error';
15
17
  };
16
18
  type ExtractFrameParams = {
17
19
  src: string;
@@ -13,6 +13,9 @@ const extractFrameInternal = async ({ src, timeInSeconds: unloopedTimeInSeconds,
13
13
  if (video === 'unknown-container-format') {
14
14
  return { type: 'unknown-container-format' };
15
15
  }
16
+ if (video === 'network-error') {
17
+ return { type: 'network-error' };
18
+ }
16
19
  let mediaDurationInSeconds = null;
17
20
  if (loop) {
18
21
  mediaDurationInSeconds = await sink.getDuration();
@@ -8,8 +8,8 @@ type VideoSinks = {
8
8
  type AudioSinks = {
9
9
  sampleSink: AudioSampleSink;
10
10
  };
11
- export type AudioSinkResult = AudioSinks | 'no-audio-track' | 'cannot-decode-audio' | 'unknown-container-format';
12
- export type VideoSinkResult = VideoSinks | 'no-video-track' | 'cannot-decode' | 'unknown-container-format';
11
+ export type AudioSinkResult = AudioSinks | 'no-audio-track' | 'cannot-decode-audio' | 'unknown-container-format' | 'network-error';
12
+ export type VideoSinkResult = VideoSinks | 'no-video-track' | 'cannot-decode' | 'unknown-container-format' | 'network-error';
13
13
  export declare const getSinks: (src: string) => Promise<{
14
14
  getVideo: () => Promise<VideoSinkResult>;
15
15
  getAudio: (index: number) => Promise<AudioSinkResult>;
@@ -1,14 +1,18 @@
1
1
  import { ALL_FORMATS, AudioSampleSink, EncodedPacketSink, Input, MATROSKA, UrlSource, VideoSampleSink, WEBM, } from 'mediabunny';
2
+ import { isNetworkError } from '../is-network-error';
2
3
  import { makeKeyframeBank } from './keyframe-bank';
3
4
  import { rememberActualMatroskaTimestamps } from './remember-actual-matroska-timestamps';
4
5
  const getRetryDelay = (() => {
5
6
  return null;
6
7
  });
7
- const getFormatOrNull = async (input) => {
8
+ const getFormatOrNullOrNetworkError = async (input) => {
8
9
  try {
9
10
  return await input.getFormat();
10
11
  }
11
- catch {
12
+ catch (err) {
13
+ if (isNetworkError(err)) {
14
+ return 'network-error';
15
+ }
12
16
  return null;
13
17
  }
14
18
  };
@@ -19,9 +23,12 @@ export const getSinks = async (src) => {
19
23
  getRetryDelay,
20
24
  }),
21
25
  });
22
- const format = await getFormatOrNull(input);
26
+ const format = await getFormatOrNullOrNetworkError(input);
23
27
  const isMatroska = format === MATROSKA || format === WEBM;
24
28
  const getVideoSinks = async () => {
29
+ if (format === 'network-error') {
30
+ return 'network-error';
31
+ }
25
32
  if (format === null) {
26
33
  return 'unknown-container-format';
27
34
  }
@@ -52,6 +59,9 @@ export const getSinks = async (src) => {
52
59
  if (format === null) {
53
60
  return 'unknown-container-format';
54
61
  }
62
+ if (format === 'network-error') {
63
+ return 'network-error';
64
+ }
55
65
  const audioTracks = await input.getAudioTracks();
56
66
  const audioTrack = audioTracks[index];
57
67
  if (!audioTrack) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/media",
3
- "version": "4.0.377",
3
+ "version": "4.0.379",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/esm/index.mjs",
@@ -22,14 +22,14 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "mediabunny": "1.24.5",
25
- "remotion": "4.0.377"
25
+ "remotion": "4.0.379"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "react": ">=16.8.0",
29
29
  "react-dom": ">=16.8.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@remotion/eslint-config-internal": "4.0.377",
32
+ "@remotion/eslint-config-internal": "4.0.379",
33
33
  "@vitest/browser-webdriverio": "4.0.7",
34
34
  "eslint": "9.19.0",
35
35
  "react": "19.0.0",