@remotion/renderer 4.0.344 → 4.0.346

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.
@@ -0,0 +1,7 @@
1
+ import type { InlineAudioAsset } from 'remotion/no-react';
2
+ export declare const makeInlineAudioMixing: (dir: string) => {
3
+ cleanup: () => void;
4
+ addAsset: (asset: InlineAudioAsset, fps: number, totalNumberOfFrames: number) => void;
5
+ folder: string;
6
+ };
7
+ export type InlineAudioMixing = ReturnType<typeof makeInlineAudioMixing>;
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.makeInlineAudioMixing = void 0;
40
+ const node_fs_1 = __importStar(require("node:fs"));
41
+ const node_path_1 = __importDefault(require("node:path"));
42
+ const delete_directory_1 = require("../delete-directory");
43
+ const sample_rate_1 = require("../sample-rate");
44
+ const download_map_1 = require("./download-map");
45
+ const numberTo32BiIntLittleEndian = (num) => {
46
+ return new Uint8Array([
47
+ num & 0xff,
48
+ (num >> 8) & 0xff,
49
+ (num >> 16) & 0xff,
50
+ (num >> 24) & 0xff,
51
+ ]);
52
+ };
53
+ const numberTo16BitLittleEndian = (num) => {
54
+ return new Uint8Array([num & 0xff, (num >> 8) & 0xff]);
55
+ };
56
+ const BIT_DEPTH = 16;
57
+ const BYTES_PER_SAMPLE = BIT_DEPTH / 8;
58
+ const makeInlineAudioMixing = (dir) => {
59
+ const folderToAdd = (0, download_map_1.makeAndReturn)(dir, 'remotion-inline-audio-mixing');
60
+ // asset id -> file descriptor
61
+ const openFiles = {};
62
+ const cleanup = () => {
63
+ for (const fd of Object.values(openFiles)) {
64
+ node_fs_1.default.closeSync(fd);
65
+ }
66
+ (0, delete_directory_1.deleteDirectory)(folderToAdd);
67
+ };
68
+ const ensureAsset = (asset, fps, totalNumberOfFrames) => {
69
+ const filePath = node_path_1.default.join(folderToAdd, `${asset.id}.wav`);
70
+ if (!openFiles[asset.id]) {
71
+ openFiles[asset.id] = node_fs_1.default.openSync(filePath, 'w');
72
+ }
73
+ const expectedDataSize = Math.round((totalNumberOfFrames / fps) *
74
+ asset.numberOfChannels *
75
+ sample_rate_1.DEFAULT_SAMPLE_RATE *
76
+ BYTES_PER_SAMPLE);
77
+ console.log({ totalNumberOfFrames, fps });
78
+ const expectedSize = 40 + expectedDataSize;
79
+ const { numberOfChannels } = asset;
80
+ const fd = openFiles[asset.id];
81
+ (0, node_fs_1.writeSync)(fd, new Uint8Array([0x52, 0x49, 0x46, 0x46]), 0, 4, 0); // "RIFF"
82
+ (0, node_fs_1.writeSync)(fd, new Uint8Array(numberTo32BiIntLittleEndian(expectedSize)), 0, 4, 4); // Remaining size
83
+ (0, node_fs_1.writeSync)(fd, new Uint8Array([0x57, 0x41, 0x56, 0x45]), 0, 4, 8); // "WAVE"
84
+ (0, node_fs_1.writeSync)(fd, new Uint8Array([0x66, 0x6d, 0x74, 0x20]), 0, 4, 12); // "fmt "
85
+ (0, node_fs_1.writeSync)(fd, new Uint8Array([BIT_DEPTH, 0x00, 0x00, 0x00]), 0, 4, 16); // fmt chunk size = 16
86
+ (0, node_fs_1.writeSync)(fd, new Uint8Array([0x01, 0x00]), 0, 2, 20); // Audio format (PCM) = 1, set 3 if float32 would be true
87
+ (0, node_fs_1.writeSync)(fd, new Uint8Array([numberOfChannels, 0x00]), 0, 2, 22); // Number of channels
88
+ (0, node_fs_1.writeSync)(fd, new Uint8Array(numberTo32BiIntLittleEndian(sample_rate_1.DEFAULT_SAMPLE_RATE)), 0, 4, 24); // Sample rate
89
+ (0, node_fs_1.writeSync)(fd, new Uint8Array(numberTo32BiIntLittleEndian(sample_rate_1.DEFAULT_SAMPLE_RATE * numberOfChannels * BYTES_PER_SAMPLE)), 0, 4, 28); // Byte rate
90
+ (0, node_fs_1.writeSync)(fd, new Uint8Array(numberTo16BitLittleEndian(numberOfChannels * BYTES_PER_SAMPLE)), 0, 2, 32); // Block align
91
+ (0, node_fs_1.writeSync)(fd, numberTo16BitLittleEndian(BIT_DEPTH), 0, 2, 34); // Bits per sample
92
+ (0, node_fs_1.writeSync)(fd, new Uint8Array([0x64, 0x61, 0x74, 0x61]), 0, 4, 36); // "data"
93
+ (0, node_fs_1.writeSync)(fd, new Uint8Array(numberTo32BiIntLittleEndian(expectedDataSize)), 0, 4, 40); // Remaining size
94
+ };
95
+ const addAsset = (asset, fps, totalNumberOfFrames) => {
96
+ ensureAsset(asset, fps, totalNumberOfFrames);
97
+ const fileDescriptor = openFiles[asset.id];
98
+ const arr = new Int16Array(asset.audio);
99
+ (0, node_fs_1.writeSync)(
100
+ // fs
101
+ fileDescriptor,
102
+ // data
103
+ arr,
104
+ // offset of dats
105
+ 0,
106
+ // length
107
+ arr.byteLength,
108
+ // position
109
+ 44 +
110
+ Math.round((asset.frame / fps) *
111
+ asset.numberOfChannels *
112
+ sample_rate_1.DEFAULT_SAMPLE_RATE *
113
+ BYTES_PER_SAMPLE));
114
+ console.log('wrote', arr.byteLength, 'bytes to', node_path_1.default.join(folderToAdd, `${asset.id}.wav`), Math.round((asset.frame / fps) *
115
+ asset.numberOfChannels *
116
+ sample_rate_1.DEFAULT_SAMPLE_RATE *
117
+ BYTES_PER_SAMPLE));
118
+ };
119
+ return {
120
+ cleanup,
121
+ addAsset,
122
+ folder: folderToAdd,
123
+ };
124
+ };
125
+ exports.makeInlineAudioMixing = makeInlineAudioMixing;
@@ -0,0 +1,12 @@
1
+ export declare const getActualTrimLeft: ({ fps, trimLeftOffset, seamless, assetDuration, audioStartFrame, trimLeft, playbackRate, }: {
2
+ trimLeft: number;
3
+ audioStartFrame: number;
4
+ fps: number;
5
+ trimLeftOffset: number;
6
+ seamless: boolean;
7
+ assetDuration: number | null;
8
+ playbackRate: number;
9
+ }) => {
10
+ trimLeft: number;
11
+ maxTrim: number | null;
12
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getActualTrimLeft = void 0;
4
+ const getActualTrimLeft = ({ fps, trimLeftOffset, seamless, assetDuration, audioStartFrame, trimLeft, playbackRate, }) => {
5
+ const sinceStart = trimLeft - audioStartFrame;
6
+ if (!seamless) {
7
+ return {
8
+ trimLeft: audioStartFrame / fps +
9
+ (sinceStart / fps) * playbackRate +
10
+ trimLeftOffset,
11
+ maxTrim: assetDuration,
12
+ };
13
+ }
14
+ if (seamless) {
15
+ return {
16
+ trimLeft: audioStartFrame / fps / playbackRate +
17
+ sinceStart / fps +
18
+ trimLeftOffset,
19
+ maxTrim: assetDuration ? assetDuration / playbackRate : null,
20
+ };
21
+ }
22
+ throw new Error('This should never happen');
23
+ };
24
+ exports.getActualTrimLeft = getActualTrimLeft;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/renderer"
4
4
  },
5
5
  "name": "@remotion/renderer",
6
- "version": "4.0.344",
6
+ "version": "4.0.346",
7
7
  "description": "Render Remotion videos using Node.js or Bun",
8
8
  "main": "dist/index.js",
9
9
  "types": "dist/index.d.ts",
@@ -18,8 +18,8 @@
18
18
  "extract-zip": "2.0.1",
19
19
  "source-map": "^0.8.0-beta.0",
20
20
  "ws": "8.17.1",
21
- "remotion": "4.0.344",
22
- "@remotion/streaming": "4.0.344"
21
+ "remotion": "4.0.346",
22
+ "@remotion/streaming": "4.0.346"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "react": ">=16.8.0",
@@ -33,17 +33,17 @@
33
33
  "react-dom": "19.0.0",
34
34
  "@types/ws": "8.5.10",
35
35
  "eslint": "9.19.0",
36
- "@remotion/example-videos": "4.0.344",
37
- "@remotion/eslint-config-internal": "4.0.344"
36
+ "@remotion/example-videos": "4.0.346",
37
+ "@remotion/eslint-config-internal": "4.0.346"
38
38
  },
39
39
  "optionalDependencies": {
40
- "@remotion/compositor-darwin-arm64": "4.0.344",
41
- "@remotion/compositor-darwin-x64": "4.0.344",
42
- "@remotion/compositor-win32-x64-msvc": "4.0.344",
43
- "@remotion/compositor-linux-x64-musl": "4.0.344",
44
- "@remotion/compositor-linux-arm64-gnu": "4.0.344",
45
- "@remotion/compositor-linux-arm64-musl": "4.0.344",
46
- "@remotion/compositor-linux-x64-gnu": "4.0.344"
40
+ "@remotion/compositor-darwin-arm64": "4.0.346",
41
+ "@remotion/compositor-darwin-x64": "4.0.346",
42
+ "@remotion/compositor-linux-arm64-musl": "4.0.346",
43
+ "@remotion/compositor-linux-x64-gnu": "4.0.346",
44
+ "@remotion/compositor-linux-x64-musl": "4.0.346",
45
+ "@remotion/compositor-win32-x64-msvc": "4.0.346",
46
+ "@remotion/compositor-linux-arm64-gnu": "4.0.346"
47
47
  },
48
48
  "keywords": [
49
49
  "remotion",