@remotion/renderer 4.0.0-audio.0 → 4.0.0-audio.13

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.
@@ -4,9 +4,10 @@ declare type FfmpegVolumeExpression = {
4
4
  eval: FfmpegEval;
5
5
  value: string;
6
6
  };
7
- export declare const ffmpegVolumeExpression: ({ volume, startInVideo, fps, }: {
7
+ export declare const ffmpegVolumeExpression: ({ volume, startInVideo, fps, trimLeft, }: {
8
8
  volume: AssetVolume;
9
9
  startInVideo: number;
10
+ trimLeft: number;
10
11
  fps: number;
11
12
  }) => FfmpegVolumeExpression;
12
13
  export {};
@@ -12,7 +12,7 @@ const FFMPEG_TIME_VARIABLE = 't';
12
12
  const ffmpegIfOrElse = (condition, then, elseDo) => {
13
13
  return `if(${condition},${then},${elseDo})`;
14
14
  };
15
- const ffmpegIsOneOfFrames = (frames, fps) => {
15
+ const ffmpegIsOneOfFrames = ({ frames, trimLeft, fps, }) => {
16
16
  const consecutiveArrays = [];
17
17
  for (let i = 0; i < frames.length; i++) {
18
18
  const previousFrame = frames[i - 1];
@@ -28,11 +28,11 @@ const ffmpegIsOneOfFrames = (frames, fps) => {
28
28
  const lastFrame = f[f.length - 1];
29
29
  const before = (firstFrame - 0.5) / fps;
30
30
  const after = (lastFrame + 0.5) / fps;
31
- return `between(${FFMPEG_TIME_VARIABLE},${before.toFixed(4)},${after.toFixed(4)})`;
31
+ return `between(${FFMPEG_TIME_VARIABLE},${(before + trimLeft).toFixed(4)},${(after + trimLeft).toFixed(4)})`;
32
32
  })
33
33
  .join('+');
34
34
  };
35
- const ffmpegBuildVolumeExpression = (arr, fps) => {
35
+ const ffmpegBuildVolumeExpression = (arr, delay, fps) => {
36
36
  if (arr.length === 0) {
37
37
  throw new Error('Volume array expression should never have length 0');
38
38
  }
@@ -40,13 +40,13 @@ const ffmpegBuildVolumeExpression = (arr, fps) => {
40
40
  // FFMpeg tends to request volume for frames outside the range
41
41
  // where the audio actually plays.
42
42
  // If this is the case, we just return volume 0 to clip it.
43
- return ffmpegIfOrElse(ffmpegIsOneOfFrames(arr[0][1], fps), String(arr[0][0]), String(0));
43
+ return ffmpegIfOrElse(ffmpegIsOneOfFrames({ frames: arr[0][1], trimLeft: delay, fps }), String(arr[0][0]), String(0));
44
44
  }
45
45
  const [first, ...rest] = arr;
46
46
  const [volume, frames] = first;
47
- return ffmpegIfOrElse(ffmpegIsOneOfFrames(frames, fps), String(volume), ffmpegBuildVolumeExpression(rest, fps));
47
+ return ffmpegIfOrElse(ffmpegIsOneOfFrames({ frames, trimLeft: delay, fps }), String(volume), ffmpegBuildVolumeExpression(rest, delay, fps));
48
48
  };
49
- const ffmpegVolumeExpression = ({ volume, startInVideo, fps, }) => {
49
+ const ffmpegVolumeExpression = ({ volume, startInVideo, fps, trimLeft, }) => {
50
50
  // If it's a static volume, we return it and tell
51
51
  // FFMPEG it only has to evaluate it once
52
52
  if (typeof volume === 'number') {
@@ -60,6 +60,7 @@ const ffmpegVolumeExpression = ({ volume, startInVideo, fps, }) => {
60
60
  volume: volume[0],
61
61
  startInVideo,
62
62
  fps,
63
+ trimLeft,
63
64
  });
64
65
  }
65
66
  // Otherwise, we construct an FFMPEG expression. First step:
@@ -81,7 +82,7 @@ const ffmpegVolumeExpression = ({ volume, startInVideo, fps, }) => {
81
82
  .map((key) => [Number(key), volumeMap[key]])
82
83
  .sort((a, b) => a[1].length - b[1].length);
83
84
  // Construct and tell FFMPEG it has to evaluate expression on each frame
84
- const expression = ffmpegBuildVolumeExpression(volumeArray, fps);
85
+ const expression = ffmpegBuildVolumeExpression(volumeArray, trimLeft, fps);
85
86
  return {
86
87
  eval: 'frame',
87
88
  value: `'${expression}'`,
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
@@ -1,6 +1,6 @@
1
1
  import puppeteer from 'puppeteer-core';
2
2
  import { Browser } from 'remotion';
3
- declare const validRenderers: readonly ["angle", "egl", "swiftshader"];
3
+ declare const validRenderers: readonly ["swangle", "angle", "egl", "swiftshader"];
4
4
  declare type OpenGlRenderer = typeof validRenderers[number];
5
5
  export declare type ChromiumOptions = {
6
6
  ignoreCertificateErrors?: boolean;
@@ -13,5 +13,6 @@ export declare const openBrowser: (browser: Browser, options?: {
13
13
  shouldDumpIo?: boolean | undefined;
14
14
  browserExecutable?: string | null | undefined;
15
15
  chromiumOptions?: ChromiumOptions | undefined;
16
+ forceDeviceScaleFactor?: number | undefined;
16
17
  } | undefined) => Promise<puppeteer.Browser>;
17
18
  export {};
@@ -10,11 +10,17 @@ const path_1 = __importDefault(require("path"));
10
10
  const puppeteer_core_1 = __importDefault(require("puppeteer-core"));
11
11
  const remotion_1 = require("remotion");
12
12
  const get_local_browser_executable_1 = require("./get-local-browser-executable");
13
- const validRenderers = ['angle', 'egl', 'swiftshader'];
13
+ const validRenderers = ['swangle', 'angle', 'egl', 'swiftshader'];
14
14
  const getOpenGlRenderer = (option) => {
15
15
  const renderer = option !== null && option !== void 0 ? option : remotion_1.Internals.DEFAULT_OPENGL_RENDERER;
16
16
  remotion_1.Internals.validateOpenGlRenderer(renderer);
17
- return renderer;
17
+ if (renderer === 'swangle') {
18
+ return [`--use-gl=angle`, `--use-angle=swiftshader`];
19
+ }
20
+ if (renderer === null) {
21
+ return [];
22
+ }
23
+ return [`--use-gl=${renderer}`];
18
24
  };
19
25
  const browserInstances = [];
20
26
  const killAllBrowsers = async () => {
@@ -38,12 +44,48 @@ const openBrowser = async (browser, options) => {
38
44
  executablePath,
39
45
  product: browser,
40
46
  dumpio: (_e = options === null || options === void 0 ? void 0 : options.shouldDumpIo) !== null && _e !== void 0 ? _e : false,
41
- headless: (_g = (_f = options === null || options === void 0 ? void 0 : options.chromiumOptions) === null || _f === void 0 ? void 0 : _f.headless) !== null && _g !== void 0 ? _g : true,
47
+ ignoreDefaultArgs: true,
42
48
  args: [
49
+ 'about:blank',
50
+ '--allow-pre-commit-input',
51
+ '--disable-background-networking',
52
+ '--enable-features=NetworkService,NetworkServiceInProcess',
53
+ '--disable-background-timer-throttling',
54
+ '--disable-backgrounding-occluded-windows',
55
+ '--disable-breakpad',
56
+ '--disable-client-side-phishing-detection',
57
+ '--disable-component-extensions-with-background-pages',
58
+ '--disable-default-apps',
59
+ '--disable-dev-shm-usage',
60
+ '--disable-extensions',
61
+ '--no-proxy-server',
62
+ "--proxy-server='direct://'",
63
+ '--proxy-bypass-list=*',
64
+ // TODO: remove AvoidUnnecessaryBeforeUnloadCheckSync below
65
+ // once crbug.com/1324138 is fixed and released.
66
+ '--disable-features=Translate,BackForwardCache,AvoidUnnecessaryBeforeUnloadCheckSync',
67
+ '--disable-hang-monitor',
68
+ '--disable-ipc-flooding-protection',
69
+ '--disable-popup-blocking',
70
+ '--disable-prompt-on-repost',
71
+ '--disable-renderer-backgrounding',
72
+ '--disable-sync',
73
+ '--force-color-profile=srgb',
74
+ '--metrics-recording-only',
75
+ '--no-first-run',
76
+ '--video-threads=16',
77
+ '--enable-automation',
78
+ '--password-store=basic',
79
+ '--use-mock-keychain',
80
+ // TODO(sadym): remove '--enable-blink-features=IdleDetection'
81
+ // once IdleDetection is turned on by default.
82
+ '--enable-blink-features=IdleDetection',
83
+ '--export-tagged-pdf',
84
+ '--intensive-wake-up-throttling-policy=0',
85
+ ((_g = (_f = options === null || options === void 0 ? void 0 : options.chromiumOptions) === null || _f === void 0 ? void 0 : _f.headless) !== null && _g !== void 0 ? _g : true) ? '--headless' : null,
43
86
  '--no-sandbox',
44
87
  '--disable-setuid-sandbox',
45
- '--disable-dev-shm-usage',
46
- customGlRenderer ? `--use-gl=${customGlRenderer}` : null,
88
+ ...customGlRenderer,
47
89
  '--disable-background-media-suspend',
48
90
  process.platform === 'linux' ? '--single-process' : null,
49
91
  '--allow-running-insecure-content',
@@ -52,12 +94,14 @@ const openBrowser = async (browser, options) => {
52
94
  '--disable-features=AudioServiceOutOfProcess,IsolateOrigins,site-per-process',
53
95
  '--disable-print-preview',
54
96
  '--disable-site-isolation-trials',
55
- '--disk-cache-size=33554432',
97
+ '--disk-cache-size=268435456',
56
98
  '--hide-scrollbars',
57
99
  '--no-default-browser-check',
58
100
  '--no-pings',
59
101
  '--no-zygote',
60
- '--disable-background-media-suspend',
102
+ (options === null || options === void 0 ? void 0 : options.forceDeviceScaleFactor)
103
+ ? `--force-device-scale-factor=${options.forceDeviceScaleFactor}`
104
+ : null,
61
105
  ((_h = options === null || options === void 0 ? void 0 : options.chromiumOptions) === null || _h === void 0 ? void 0 : _h.ignoreCertificateErrors)
62
106
  ? '--ignore-certificate-errors'
63
107
  : null,
@@ -187,7 +187,7 @@ const innerRenderFrames = async ({ onFrameUpdate, outputDir, onStart, inputProps
187
187
  return returnValue;
188
188
  };
189
189
  const renderFrames = async (options) => {
190
- var _a, _b;
190
+ var _a, _b, _c;
191
191
  const composition = getComposition(options);
192
192
  if (!composition) {
193
193
  throw new Error('No `composition` option has been specified for renderFrames()');
@@ -207,8 +207,9 @@ const renderFrames = async (options) => {
207
207
  shouldDumpIo: options.dumpBrowserLogs,
208
208
  browserExecutable: options.browserExecutable,
209
209
  chromiumOptions: options.chromiumOptions,
210
+ forceDeviceScaleFactor: (_b = options.scale) !== null && _b !== void 0 ? _b : 1,
210
211
  }));
211
- const actualParallelism = (0, get_concurrency_1.getActualConcurrency)((_b = options.parallelism) !== null && _b !== void 0 ? _b : null);
212
+ const actualParallelism = (0, get_concurrency_1.getActualConcurrency)((_c = options.parallelism) !== null && _c !== void 0 ? _c : null);
212
213
  const { stopCycling } = (0, cycle_browser_tabs_1.cycleBrowserTabs)(browserInstance, actualParallelism);
213
214
  const openedPages = [];
214
215
  return new Promise((resolve, reject) => {
@@ -68,6 +68,7 @@ const innerRenderStill = async ({ composition, quality, imageFormat = 'png', ser
68
68
  browserExecutable,
69
69
  shouldDumpIo: dumpBrowserLogs,
70
70
  chromiumOptions,
71
+ forceDeviceScaleFactor: scale !== null && scale !== void 0 ? scale : 1,
71
72
  }));
72
73
  const page = await browserInstance.newPage();
73
74
  page.setViewport({
@@ -24,9 +24,9 @@ const setPropsAndEnv = async ({ inputProps, envVariables, page, serveUrl, initia
24
24
  window.remotion_envVariables = input;
25
25
  }, [JSON.stringify(envVariables)]);
26
26
  }
27
- await page.evaluateOnNewDocument((key, value) => {
28
- window.localStorage.setItem(key, value);
29
- }, [remotion_1.Internals.INITIAL_FRAME_LOCAL_STORAGE_KEY, initialFrame]);
27
+ await page.evaluateOnNewDocument((key) => {
28
+ window.remotion_initialFrame = key;
29
+ }, [initialFrame]);
30
30
  const pageRes = await page.goto(urlToVisit);
31
31
  const status = pageRes.status();
32
32
  if (status !== 200 &&
@@ -11,6 +11,7 @@ const stringifyFfmpegFilter = ({ trimLeft, trimRight, channels, startInVideo, vo
11
11
  volume,
12
12
  startInVideo,
13
13
  fps,
14
+ trimLeft,
14
15
  });
15
16
  // Avoid setting filters if possible, as combining them can create noise
16
17
  const chunkLength = durationInFrames / fps;
@@ -37,6 +38,8 @@ const stringifyFfmpegFilter = ({ trimLeft, trimRight, channels, startInVideo, vo
37
38
  .fill((startInVideoSeconds * 1000).toFixed(0))
38
39
  .join('|')}`,
39
40
  // set the volume if needed
41
+ // The timings for volume must include whatever is in atrim, unless the volume
42
+ // filter gets applied before atrim
40
43
  volumeFilter.value === '1'
41
44
  ? null
42
45
  : `volume=${volumeFilter.value}:eval=${volumeFilter.eval}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/renderer",
3
- "version": "4.0.0-audio.0+9876e2ce3",
3
+ "version": "4.0.0-audio.13+0b79d452c",
4
4
  "description": "Renderer for Remotion",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,10 +20,10 @@
20
20
  "url": "https://github.com/remotion-dev/remotion/issues"
21
21
  },
22
22
  "dependencies": {
23
- "@remotion/bundler": "4.0.0-audio.0+9876e2ce3",
23
+ "@remotion/bundler": "4.0.0-audio.13+0b79d452c",
24
24
  "execa": "5.1.1",
25
25
  "puppeteer-core": "13.5.1",
26
- "remotion": "4.0.0-audio.0+9876e2ce3",
26
+ "remotion": "4.0.0-audio.13+0b79d452c",
27
27
  "serve-handler": "6.1.3",
28
28
  "source-map": "^0.8.0-beta.0"
29
29
  },
@@ -60,5 +60,5 @@
60
60
  "publishConfig": {
61
61
  "access": "public"
62
62
  },
63
- "gitHead": "9876e2ce3f5e81e926ee08211ba093fbdf234b53"
63
+ "gitHead": "0b79d452c04f18dd6745a6fddf21fb4c73617c61"
64
64
  }