@remotion/renderer 4.0.419 → 4.0.421

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.
@@ -54,6 +54,19 @@ const numberTo32BiIntLittleEndian = (num) => {
54
54
  const numberTo16BitLittleEndian = (num) => {
55
55
  return new Uint8Array([num & 0xff, (num >> 8) & 0xff]);
56
56
  };
57
+ /**
58
+ * When multiplying seconds by sample rate, floating point errors can cause
59
+ * results like 244799.99999999997 instead of 244800 (5.1 * 48000).
60
+ * This snaps to the nearest integer when within tolerance,
61
+ * preventing Math.floor/Math.ceil from rounding incorrectly.
62
+ */
63
+ const correctFloatingPointError = (value) => {
64
+ const rounded = Math.round(value);
65
+ if (Math.abs(value - rounded) < 0.00001) {
66
+ return rounded;
67
+ }
68
+ return value;
69
+ };
57
70
  const BIT_DEPTH = 16;
58
71
  const BYTES_PER_SAMPLE = BIT_DEPTH / 8;
59
72
  const NUMBER_OF_CHANNELS = 2;
@@ -149,17 +162,20 @@ const makeInlineAudioMixing = (dir) => {
149
162
  // Rendering https://github.com/remotion-dev/remotion/pull/5920 in native frame rate
150
163
  // could hit this case
151
164
  if (isFirst) {
152
- arr = arr.slice(Math.floor(samplesToShaveFromStart) * NUMBER_OF_CHANNELS);
165
+ arr = arr.slice(Math.floor(correctFloatingPointError(samplesToShaveFromStart)) *
166
+ NUMBER_OF_CHANNELS);
153
167
  }
154
168
  if (isLast) {
155
- arr = arr.slice(0, arr.length + Math.ceil(samplesToShaveFromEnd) * NUMBER_OF_CHANNELS);
169
+ arr = arr.slice(0, arr.length +
170
+ Math.ceil(correctFloatingPointError(samplesToShaveFromEnd)) *
171
+ NUMBER_OF_CHANNELS);
156
172
  }
157
173
  const positionInSeconds = (asset.frame - firstFrame) / fps - (isFirst ? 0 : trimLeftOffset);
158
174
  // Always rounding down to ensure there are no gaps when the samples don't align
159
175
  // In @remotion/media, we also round down the sample start timestamp and round up the end timestamp
160
176
  // This might lead to overlapping, hopefully aligning perfectly!
161
177
  // Test case: https://github.com/remotion-dev/remotion/issues/5758
162
- const position = Math.floor(positionInSeconds * sample_rate_1.DEFAULT_SAMPLE_RATE) *
178
+ const position = Math.floor(correctFloatingPointError(positionInSeconds * sample_rate_1.DEFAULT_SAMPLE_RATE)) *
163
179
  NUMBER_OF_CHANNELS *
164
180
  BYTES_PER_SAMPLE;
165
181
  (0, node_fs_1.writeSync)(
@@ -166,14 +166,25 @@ const downloadBrowser = async ({ logLevel, indent, onProgress, version, chromeMo
166
166
  abortSignal: new AbortController().signal,
167
167
  });
168
168
  await (0, extract_zip_1.default)(archivePath, { dir: outputPath });
169
- const chromePath = path.join(outputPath, 'chrome-linux', 'chrome');
170
- const chromeHeadlessShellPath = path.join(outputPath, 'chrome-linux', 'chrome-headless-shell');
171
- if (fs.existsSync(chromePath)) {
172
- fs.renameSync(chromePath, chromeHeadlessShellPath);
173
- }
174
- const chromeLinuxFolder = path.join(outputPath, 'chrome-linux');
175
- if (fs.existsSync(chromeLinuxFolder)) {
176
- fs.renameSync(chromeLinuxFolder, path.join(outputPath, 'chrome-headless-shell-linux-arm64'));
169
+ const possibleSubdirs = [
170
+ 'chrome-linux',
171
+ 'chrome-headless-shell-linux64',
172
+ 'chromium-headless-shell-amazon-linux2023-arm64',
173
+ 'chromium-headless-shell-amazon-linux2023-x64',
174
+ ];
175
+ for (const subdir of possibleSubdirs) {
176
+ const chromeLinuxFolder = path.join(outputPath, subdir);
177
+ const chromePath = path.join(chromeLinuxFolder, 'chrome');
178
+ if (fs.existsSync(chromePath)) {
179
+ const chromeHeadlessShellPath = path.join(chromeLinuxFolder, 'chrome-headless-shell');
180
+ fs.renameSync(chromePath, chromeHeadlessShellPath);
181
+ }
182
+ if (fs.existsSync(chromeLinuxFolder)) {
183
+ const targetFolder = path.join(outputPath, 'chrome-headless-shell-' + platform);
184
+ if (chromeLinuxFolder !== targetFolder) {
185
+ fs.renameSync(chromeLinuxFolder, targetFolder);
186
+ }
187
+ }
177
188
  }
178
189
  }
179
190
  catch (err) {
@@ -212,7 +223,7 @@ const getExecutablePath = (chromeMode) => {
212
223
  if (chromeMode === 'headless-shell') {
213
224
  return path.join(folderPath, `chrome-headless-shell-${platform}`, platform === 'win64'
214
225
  ? 'chrome-headless-shell.exe'
215
- : platform === 'linux-arm64'
226
+ : platform === 'linux-arm64' || (0, get_chrome_download_url_1.isAmazonLinux2023)()
216
227
  ? 'headless_shell'
217
228
  : 'chrome-headless-shell');
218
229
  }
@@ -1,6 +1,7 @@
1
1
  import type { ChromeMode } from '../options/chrome-mode';
2
2
  export declare const TESTED_VERSION = "144.0.7559.20";
3
3
  export type Platform = 'linux64' | 'linux-arm64' | 'mac-x64' | 'mac-arm64' | 'win64';
4
+ export declare const isAmazonLinux2023: () => boolean;
4
5
  export declare const canUseRemotionMediaBinaries: () => boolean;
5
6
  export declare function getChromeDownloadUrl({ platform, version, chromeMode }: {
6
7
  platform: Platform;
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.logDownloadUrl = exports.canUseRemotionMediaBinaries = exports.TESTED_VERSION = void 0;
36
+ exports.logDownloadUrl = exports.canUseRemotionMediaBinaries = exports.isAmazonLinux2023 = exports.TESTED_VERSION = void 0;
37
37
  exports.getChromeDownloadUrl = getChromeDownloadUrl;
38
38
  const fs = __importStar(require("node:fs"));
39
39
  const os = __importStar(require("node:os"));
@@ -54,6 +54,7 @@ const isAmazonLinux2023 = () => {
54
54
  return false;
55
55
  }
56
56
  };
57
+ exports.isAmazonLinux2023 = isAmazonLinux2023;
57
58
  // remotion.media binaries are built on Ubuntu 24.04 which requires glibc 2.35+
58
59
  const MINIMUM_GLIBC_FOR_REMOTION_MEDIA = [2, 35];
59
60
  const getGlibcVersion = () => {
@@ -107,7 +108,7 @@ function getChromeDownloadUrl({ platform, version, chromeMode, }) {
107
108
  if (platform === 'linux-arm64') {
108
109
  // Amazon Linux 2023 on arm64 needs a special build.
109
110
  // This binary is compatible with older glibc (no 2.35 requirement).
110
- if (isAmazonLinux2023() && chromeMode === 'headless-shell' && !version) {
111
+ if ((0, exports.isAmazonLinux2023)() && chromeMode === 'headless-shell' && !version) {
111
112
  return 'https://remotion.media/chromium-headless-shell-amazon-linux-arm64-144.0.7559.20.zip';
112
113
  }
113
114
  if (chromeMode === 'chrome-for-testing') {
@@ -124,6 +125,11 @@ function getChromeDownloadUrl({ platform, version, chromeMode, }) {
124
125
  return `https://playwright.azureedge.net/builds/chromium/${PLAYWRIGHT_VERSION}/chromium-headless-shell-linux-arm64.zip`;
125
126
  }
126
127
  if (chromeMode === 'headless-shell') {
128
+ // Amazon Linux 2023 needs a special build.
129
+ // This binary is compatible with older glibc (no 2.35 requirement).
130
+ if ((0, exports.isAmazonLinux2023)() && platform === 'linux64' && !version) {
131
+ return `https://remotion.media/chromium-headless-shell-amazon-linux-x64-144.0.7559.20.zip`;
132
+ }
127
133
  if (platform === 'linux64' && version === null) {
128
134
  if ((0, exports.canUseRemotionMediaBinaries)()) {
129
135
  return `https://remotion.media/chromium-headless-shell-linux-x64-${exports.TESTED_VERSION}.zip?clearcache`;
package/dist/client.d.ts CHANGED
@@ -1070,6 +1070,21 @@ export declare const BrowserSafeApis: {
1070
1070
  };
1071
1071
  setConfig(value: boolean): void;
1072
1072
  };
1073
+ forceNewStudioOption: {
1074
+ name: string;
1075
+ cliFlag: "force-new";
1076
+ description: () => import("react/jsx-runtime").JSX.Element;
1077
+ ssrName: null;
1078
+ docLink: string;
1079
+ type: boolean;
1080
+ getValue: ({ commandLine }: {
1081
+ commandLine: Record<string, unknown>;
1082
+ }) => {
1083
+ value: boolean;
1084
+ source: string;
1085
+ };
1086
+ setConfig(value: boolean): void;
1087
+ };
1073
1088
  };
1074
1089
  validColorSpaces: readonly ["default", "bt709", "bt2020-ncl"];
1075
1090
  optionsMap: {