@remotion/renderer 4.0.0-offthread.5 → 4.0.0-offthread.9

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.
@@ -5,7 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.extractFrameFromVideo = exports.extractFrameFromVideoFn = exports.streamToString = void 0;
7
7
  const execa_1 = __importDefault(require("execa"));
8
+ const remotion_1 = require("remotion");
8
9
  const frame_to_ffmpeg_timestamp_1 = require("./frame-to-ffmpeg-timestamp");
10
+ const is_beyond_last_frame_1 = require("./is-beyond-last-frame");
9
11
  const last_frame_from_video_cache_1 = require("./last-frame-from-video-cache");
10
12
  const p_limit_1 = require("./p-limit");
11
13
  function streamToString(stream) {
@@ -17,7 +19,8 @@ function streamToString(stream) {
17
19
  });
18
20
  }
19
21
  exports.streamToString = streamToString;
20
- const limit = (0, p_limit_1.pLimit)(5);
22
+ const lastFrameLimit = (0, p_limit_1.pLimit)(5);
23
+ const mainLimit = (0, p_limit_1.pLimit)(5);
21
24
  const getLastFrameOfVideoUnlimited = async ({ ffmpegExecutable, offset, src, }) => {
22
25
  if (offset > 100) {
23
26
  throw new Error('could not get last frame of ' +
@@ -63,7 +66,11 @@ const getLastFrameOfVideoUnlimited = async ({ ffmpegExecutable, offset, src, })
63
66
  const [stdErr, stdoutBuffer] = await Promise.all([stdErrString, stdoutChunk]);
64
67
  const isEmpty = stdErr.includes('Output file is empty');
65
68
  if (isEmpty) {
66
- return getLastFrameOfVideo({ ffmpegExecutable, offset: offset + 10, src });
69
+ return getLastFrameOfVideoUnlimited({
70
+ ffmpegExecutable,
71
+ offset: offset + 10,
72
+ src,
73
+ });
67
74
  }
68
75
  return stdoutBuffer;
69
76
  };
@@ -72,11 +79,18 @@ const getLastFrameOfVideo = async (options) => {
72
79
  if (fromCache) {
73
80
  return fromCache;
74
81
  }
75
- const result = await limit(getLastFrameOfVideoUnlimited, options);
82
+ const result = await lastFrameLimit(getLastFrameOfVideoUnlimited, options);
76
83
  (0, last_frame_from_video_cache_1.setLastFrameInCache)(options, result);
77
84
  return result;
78
85
  };
79
86
  const extractFrameFromVideoFn = async ({ time, src, ffmpegExecutable, }) => {
87
+ if ((0, is_beyond_last_frame_1.isBeyondLastFrame)(src, time)) {
88
+ return getLastFrameOfVideo({
89
+ ffmpegExecutable,
90
+ offset: 0,
91
+ src,
92
+ });
93
+ }
80
94
  const ffmpegTimestamp = (0, frame_to_ffmpeg_timestamp_1.frameToFfmpegTimestamp)(time);
81
95
  const { stdout, stderr } = (0, execa_1.default)(ffmpegExecutable !== null && ffmpegExecutable !== void 0 ? ffmpegExecutable : 'ffmpeg', [
82
96
  '-ss',
@@ -126,6 +140,7 @@ const extractFrameFromVideoFn = async ({ time, src, ffmpegExecutable, }) => {
126
140
  stdoutBuffer,
127
141
  ]);
128
142
  if (stderrStr.includes('Output file is empty')) {
143
+ (0, is_beyond_last_frame_1.markAsBeyondLastFrame)(src, time);
129
144
  return getLastFrameOfVideo({
130
145
  ffmpegExecutable,
131
146
  offset: 0,
@@ -135,7 +150,10 @@ const extractFrameFromVideoFn = async ({ time, src, ffmpegExecutable, }) => {
135
150
  return stdOut;
136
151
  };
137
152
  exports.extractFrameFromVideoFn = extractFrameFromVideoFn;
138
- const extractFrameFromVideo = (options) => {
139
- return limit(exports.extractFrameFromVideoFn, options);
153
+ const extractFrameFromVideo = async (options) => {
154
+ const perf = remotion_1.Internals.perf.startPerfMeasure('extract-frame');
155
+ const res = await mainLimit(exports.extractFrameFromVideoFn, options);
156
+ remotion_1.Internals.perf.stopPerfMeasure(perf);
157
+ return res;
140
158
  };
141
159
  exports.extractFrameFromVideo = extractFrameFromVideo;
@@ -0,0 +1,2 @@
1
+ export declare const isBeyondLastFrame: (src: string, time: number) => boolean | 0;
2
+ export declare const markAsBeyondLastFrame: (src: string, time: number) => void;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.markAsBeyondLastFrame = exports.isBeyondLastFrame = void 0;
4
+ const map = {};
5
+ const isBeyondLastFrame = (src, time) => {
6
+ return map[src] && time >= map[src];
7
+ };
8
+ exports.isBeyondLastFrame = isBeyondLastFrame;
9
+ const markAsBeyondLastFrame = (src, time) => {
10
+ map[src] = time;
11
+ };
12
+ exports.markAsBeyondLastFrame = markAsBeyondLastFrame;
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { FfmpegExecutable } from 'remotion';
2
3
  export declare type LastFrameOptions = {
3
4
  ffmpegExecutable: FfmpegExecutable;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import puppeteer from 'puppeteer-core';
3
2
  import { ImageFormat } from 'remotion';
4
3
  export declare const provideScreenshot: ({ page, imageFormat, options, quality, }: {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.provideScreenshot = void 0;
4
4
  const screenshot_dom_element_1 = require("./screenshot-dom-element");
5
- const provideScreenshot = async ({ page, imageFormat, options, quality, }) => {
5
+ const provideScreenshot = ({ page, imageFormat, options, quality, }) => {
6
6
  return (0, screenshot_dom_element_1.screenshotDOMElement)({
7
7
  page,
8
8
  opts: {
@@ -135,6 +135,7 @@ const innerRenderFrames = ({ onFrameUpdate, outputDir, onStart, inputProps, qual
135
135
  await (0, seek_to_frame_1.seekToFrame)({ frame, page: freePage });
136
136
  if (imageFormat !== 'none') {
137
137
  if (onFrameBuffer) {
138
+ const id = remotion_1.Internals.perf.startPerfMeasure('save');
138
139
  const buffer = await (0, provide_screenshot_1.provideScreenshot)({
139
140
  page: freePage,
140
141
  imageFormat,
@@ -144,6 +145,7 @@ const innerRenderFrames = ({ onFrameUpdate, outputDir, onStart, inputProps, qual
144
145
  output: undefined,
145
146
  },
146
147
  });
148
+ remotion_1.Internals.perf.stopPerfMeasure(id);
147
149
  onFrameBuffer(buffer, frame);
148
150
  }
149
151
  else {
@@ -137,7 +137,9 @@ const renderMedia = ({ parallelism, proResProfile, crf, composition, imageFormat
137
137
  if (cancelled) {
138
138
  return;
139
139
  }
140
+ const id = remotion_1.Internals.perf.startPerfMeasure('piping');
140
141
  (_a = stitcherFfmpeg === null || stitcherFfmpeg === void 0 ? void 0 : stitcherFfmpeg.stdin) === null || _a === void 0 ? void 0 : _a.write(buffer);
142
+ remotion_1.Internals.perf.stopPerfMeasure(id);
141
143
  setFrameToStitch(frame + 1);
142
144
  }
143
145
  : undefined,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/renderer",
3
- "version": "4.0.0-offthread.5+74268d3f1",
3
+ "version": "4.0.0-offthread.9+41e641761",
4
4
  "description": "Renderer for Remotion",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,7 +22,7 @@
22
22
  "dependencies": {
23
23
  "execa": "5.1.1",
24
24
  "puppeteer-core": "13.5.1",
25
- "remotion": "4.0.0-offthread.5+74268d3f1",
25
+ "remotion": "4.0.0-offthread.9+41e641761",
26
26
  "serve-handler": "6.1.3",
27
27
  "source-map": "^0.8.0-beta.0"
28
28
  },
@@ -59,5 +59,5 @@
59
59
  "publishConfig": {
60
60
  "access": "public"
61
61
  },
62
- "gitHead": "74268d3f1bd53f919fdef44575596b9005e112ab"
62
+ "gitHead": "41e641761b9df6c7c876fb8bbb5ca4e5a0fe6e2a"
63
63
  }