@remotion/renderer 4.0.153 → 4.0.154

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.
@@ -74,12 +74,6 @@ const startOffthreadVideoServer = ({ downloadMap, concurrency, logLevel, indent,
74
74
  }
75
75
  const { src, time, transparent, toneMapped } = (0, exports.extractUrlAndSourceFromUrl)(req.url);
76
76
  response.setHeader('access-control-allow-origin', '*');
77
- if (transparent) {
78
- response.setHeader('content-type', `image/png`);
79
- }
80
- else {
81
- response.setHeader('content-type', `image/bmp`);
82
- }
83
77
  // Prevent caching of the response and excessive disk writes
84
78
  // https://github.com/remotion-dev/remotion/issues/2760
85
79
  response.setHeader('cache-control', 'no-cache, no-store, must-revalidate');
@@ -134,6 +128,21 @@ const startOffthreadVideoServer = ({ downloadMap, concurrency, logLevel, indent,
134
128
  if (timeToExtract > 1000) {
135
129
  logger_1.Log.verbose({ indent, logLevel }, `Took ${timeToExtract}ms to extract frame from ${src} at ${time}`);
136
130
  }
131
+ const firstByte = readable.at(0);
132
+ const secondByte = readable.at(1);
133
+ const thirdByte = readable.at(2);
134
+ const isPng = firstByte === 0x89 && secondByte === 0x50 && thirdByte === 0x4e;
135
+ const isBmp = firstByte === 0x42 && secondByte === 0x4d;
136
+ if (isPng) {
137
+ response.setHeader('content-type', `image/png`);
138
+ }
139
+ else if (isBmp) {
140
+ response.setHeader('content-type', `image/bmp`);
141
+ }
142
+ else {
143
+ reject(new Error(`Unknown file type: ${firstByte} ${secondByte} ${thirdByte}`));
144
+ return;
145
+ }
137
146
  response.writeHead(200);
138
147
  response.write(readable, (err) => {
139
148
  response.end();
@@ -7,12 +7,16 @@ export type ProcessedTrack = {
7
7
  pad_start: string | null;
8
8
  pad_end: string | null;
9
9
  };
10
- export declare const getActualTrimLeft: ({ asset, fps, trimLeftOffset, seamless, }: {
10
+ export declare const getActualTrimLeft: ({ asset, fps, trimLeftOffset, seamless, assetDuration, }: {
11
11
  asset: MediaAsset;
12
12
  fps: number;
13
13
  trimLeftOffset: number;
14
14
  seamless: boolean;
15
- }) => number;
15
+ assetDuration: number | null;
16
+ }) => {
17
+ trimLeft: number;
18
+ maxTrim: number | null;
19
+ };
16
20
  export declare const stringifyFfmpegFilter: ({ channels, volume, fps, assetDuration, chunkLengthInSeconds, forSeamlessAacConcatenation, trimLeftOffset, trimRightOffset, asset, indent, logLevel, }: {
17
21
  channels: number;
18
22
  volume: AssetVolume;
@@ -15,17 +15,23 @@ const stringifyTrim = (trim) => {
15
15
  }
16
16
  return asString;
17
17
  };
18
- const getActualTrimLeft = ({ asset, fps, trimLeftOffset, seamless, }) => {
18
+ const getActualTrimLeft = ({ asset, fps, trimLeftOffset, seamless, assetDuration, }) => {
19
19
  const sinceStart = asset.trimLeft - asset.audioStartFrame;
20
20
  if (!seamless) {
21
- return (asset.audioStartFrame / fps +
22
- (sinceStart / fps) * asset.playbackRate +
23
- trimLeftOffset);
21
+ return {
22
+ trimLeft: asset.audioStartFrame / fps +
23
+ (sinceStart / fps) * asset.playbackRate +
24
+ trimLeftOffset,
25
+ maxTrim: assetDuration,
26
+ };
24
27
  }
25
28
  if (seamless) {
26
- return (asset.audioStartFrame / fps / asset.playbackRate +
27
- sinceStart / fps +
28
- trimLeftOffset);
29
+ return {
30
+ trimLeft: asset.audioStartFrame / fps / asset.playbackRate +
31
+ sinceStart / fps +
32
+ trimLeftOffset,
33
+ maxTrim: assetDuration ? assetDuration / asset.playbackRate : null,
34
+ };
29
35
  }
30
36
  throw new Error('This should never happen');
31
37
  };
@@ -36,15 +42,16 @@ const trimAndSetTempo = ({ forSeamlessAacConcatenation, assetDuration, asset, tr
36
42
  // and the offset needs to be the same for all audio tracks, before processing it further.
37
43
  // This also affects the trimLeft and trimRight values, as they need to be adjusted.
38
44
  if (forSeamlessAacConcatenation) {
39
- const trimLeft = (0, exports.getActualTrimLeft)({
45
+ const { trimLeft, maxTrim } = (0, exports.getActualTrimLeft)({
40
46
  asset,
41
47
  fps,
42
48
  trimLeftOffset,
43
49
  seamless: true,
50
+ assetDuration,
44
51
  });
45
52
  const trimRight = trimLeft + asset.duration / fps - trimLeftOffset + trimRightOffset;
46
- let trimRightOrAssetDuration = assetDuration
47
- ? Math.min(trimRight, assetDuration / asset.playbackRate)
53
+ let trimRightOrAssetDuration = maxTrim
54
+ ? Math.min(trimRight, maxTrim)
48
55
  : trimRight;
49
56
  if (trimRightOrAssetDuration < trimLeft) {
50
57
  logger_1.Log.warn({ indent, logLevel }, 'trimRightOrAssetDuration < trimLeft: ' +
@@ -68,15 +75,16 @@ const trimAndSetTempo = ({ forSeamlessAacConcatenation, assetDuration, asset, tr
68
75
  // Otherwise, we first trim and then apply playback rate, as then the atempo
69
76
  // filter needs to do less work.
70
77
  if (!forSeamlessAacConcatenation) {
71
- const actualTrimLeft = (0, exports.getActualTrimLeft)({
78
+ const { trimLeft: actualTrimLeft, maxTrim } = (0, exports.getActualTrimLeft)({
72
79
  asset,
73
80
  fps,
74
81
  trimLeftOffset,
75
82
  seamless: false,
83
+ assetDuration,
76
84
  });
77
85
  const trimRight = actualTrimLeft + (asset.duration / fps) * asset.playbackRate;
78
- const trimRightOrAssetDuration = assetDuration
79
- ? Math.min(trimRight, assetDuration)
86
+ const trimRightOrAssetDuration = maxTrim
87
+ ? Math.min(trimRight, maxTrim)
80
88
  : trimRight;
81
89
  return {
82
90
  filter: [
@@ -93,16 +101,16 @@ const stringifyFfmpegFilter = ({ channels, volume, fps, assetDuration, chunkLeng
93
101
  if (channels === 0) {
94
102
  return null;
95
103
  }
96
- const { toneFrequency, startInVideo, playbackRate } = asset;
104
+ const { toneFrequency, startInVideo } = asset;
97
105
  const startInVideoSeconds = startInVideo / fps;
98
- if (assetDuration &&
99
- (0, exports.getActualTrimLeft)({
100
- asset,
101
- fps,
102
- trimLeftOffset,
103
- seamless: forSeamlessAacConcatenation,
104
- }) >=
105
- assetDuration / playbackRate) {
106
+ const { trimLeft, maxTrim } = (0, exports.getActualTrimLeft)({
107
+ asset,
108
+ fps,
109
+ trimLeftOffset,
110
+ seamless: forSeamlessAacConcatenation,
111
+ assetDuration,
112
+ });
113
+ if (maxTrim && trimLeft >= maxTrim) {
106
114
  return null;
107
115
  }
108
116
  if (toneFrequency !== null && (toneFrequency <= 0 || toneFrequency > 2)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/renderer",
3
- "version": "4.0.153",
3
+ "version": "4.0.154",
4
4
  "description": "Renderer for Remotion",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "extract-zip": "2.0.1",
19
19
  "source-map": "^0.8.0-beta.0",
20
20
  "ws": "8.7.0",
21
- "remotion": "4.0.153"
21
+ "remotion": "4.0.154"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": ">=16.8.0",
@@ -43,13 +43,13 @@
43
43
  "@types/ws": "8.5.10"
44
44
  },
45
45
  "optionalDependencies": {
46
- "@remotion/compositor-darwin-x64": "4.0.153",
47
- "@remotion/compositor-linux-arm64-gnu": "4.0.153",
48
- "@remotion/compositor-linux-arm64-musl": "4.0.153",
49
- "@remotion/compositor-win32-x64-msvc": "4.0.153",
50
- "@remotion/compositor-linux-x64-musl": "4.0.153",
51
- "@remotion/compositor-darwin-arm64": "4.0.153",
52
- "@remotion/compositor-linux-x64-gnu": "4.0.153"
46
+ "@remotion/compositor-linux-arm64-gnu": "4.0.154",
47
+ "@remotion/compositor-linux-arm64-musl": "4.0.154",
48
+ "@remotion/compositor-darwin-arm64": "4.0.154",
49
+ "@remotion/compositor-darwin-x64": "4.0.154",
50
+ "@remotion/compositor-linux-x64-gnu": "4.0.154",
51
+ "@remotion/compositor-linux-x64-musl": "4.0.154",
52
+ "@remotion/compositor-win32-x64-msvc": "4.0.154"
53
53
  },
54
54
  "keywords": [
55
55
  "remotion",