@remotion/renderer 4.0.131 → 4.0.133

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.
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.preprocessAudioTrack = void 0;
4
+ const flatten_volume_array_1 = require("./assets/flatten-volume-array");
4
5
  const get_audio_channels_1 = require("./assets/get-audio-channels");
5
- const calculate_ffmpeg_filters_1 = require("./calculate-ffmpeg-filters");
6
6
  const call_ffmpeg_1 = require("./call-ffmpeg");
7
7
  const ffmpeg_filter_file_1 = require("./ffmpeg-filter-file");
8
8
  const logger_1 = require("./logger");
@@ -10,6 +10,7 @@ const p_limit_1 = require("./p-limit");
10
10
  const parse_ffmpeg_progress_1 = require("./parse-ffmpeg-progress");
11
11
  const resolve_asset_src_1 = require("./resolve-asset-src");
12
12
  const sample_rate_1 = require("./sample-rate");
13
+ const stringify_ffmpeg_filter_1 = require("./stringify-ffmpeg-filter");
13
14
  const preprocessAudioTrackUnlimited = async ({ outName, asset, fps, downloadMap, indent, logLevel, binariesDirectory, cancelSignal, onProgress, chunkLengthInSeconds, trimLeftOffset, trimRightOffset, forSeamlessAacConcatenation, }) => {
14
15
  var _a;
15
16
  const { channels, duration } = await (0, get_audio_channels_1.getAudioChannelsAndDuration)({
@@ -20,7 +21,7 @@ const preprocessAudioTrackUnlimited = async ({ outName, asset, fps, downloadMap,
20
21
  binariesDirectory,
21
22
  cancelSignal,
22
23
  });
23
- const filter = (0, calculate_ffmpeg_filters_1.calculateFfmpegFilter)({
24
+ const filter = (0, stringify_ffmpeg_filter_1.stringifyFfmpegFilter)({
24
25
  asset,
25
26
  fps,
26
27
  channels,
@@ -29,6 +30,7 @@ const preprocessAudioTrackUnlimited = async ({ outName, asset, fps, downloadMap,
29
30
  trimLeftOffset,
30
31
  trimRightOffset,
31
32
  forSeamlessAacConcatenation,
33
+ volume: (0, flatten_volume_array_1.flattenVolumeArray)(asset.volume),
32
34
  });
33
35
  if (filter === null) {
34
36
  return null;
@@ -6,15 +6,11 @@ export type ProcessedTrack = {
6
6
  pad_start: string | null;
7
7
  pad_end: string | null;
8
8
  };
9
- export declare const stringifyFfmpegFilter: ({ channels, startInVideo, volume, fps, playbackRate, assetDuration, allowAmplificationDuringRender, toneFrequency, chunkLengthInSeconds, forSeamlessAacConcatenation, trimLeftOffset, trimRightOffset, asset, }: {
9
+ export declare const stringifyFfmpegFilter: ({ channels, volume, fps, assetDuration, chunkLengthInSeconds, forSeamlessAacConcatenation, trimLeftOffset, trimRightOffset, asset, }: {
10
10
  channels: number;
11
- startInVideo: number;
12
11
  volume: AssetVolume;
13
12
  fps: number;
14
- playbackRate: number;
15
13
  assetDuration: number | null;
16
- allowAmplificationDuringRender: boolean;
17
- toneFrequency: number | null;
18
14
  chunkLengthInSeconds: number;
19
15
  forSeamlessAacConcatenation: boolean;
20
16
  trimLeftOffset: number;
@@ -14,25 +14,22 @@ const stringifyTrim = (trim) => {
14
14
  }
15
15
  return asString;
16
16
  };
17
- const trimAndSetTempo = ({ playbackRate, forSeamlessAacConcatenation, assetDuration, asset, trimLeftOffset, trimRightOffset, fps, }) => {
17
+ const trimAndSetTempo = ({ forSeamlessAacConcatenation, assetDuration, asset, trimLeftOffset, trimRightOffset, fps, }) => {
18
18
  // If we need seamless AAC stitching, we need to apply the tempo filter first
19
19
  // because the atempo filter is not frame-perfect. It creates a small offset
20
20
  // and the offset needs to be the same for all audio tracks, before processing it further.
21
21
  // This also affects the trimLeft and trimRight values, as they need to be adjusted.
22
22
  if (forSeamlessAacConcatenation) {
23
- const trimLeft = (asset.trimLeft * asset.playbackRate) / fps +
24
- trimLeftOffset * asset.playbackRate;
25
- const trimRight = trimLeft +
26
- (asset.duration * asset.playbackRate) / fps +
27
- trimRightOffset * asset.playbackRate;
23
+ const trimLeft = (asset.trimLeft / fps + trimLeftOffset) / asset.playbackRate;
24
+ const trimRight = trimLeft + (asset.duration / fps + trimRightOffset) / asset.playbackRate;
28
25
  const trimRightOrAssetDuration = assetDuration
29
- ? Math.min(trimRight, assetDuration * asset.playbackRate)
26
+ ? Math.min(trimRight, assetDuration / asset.playbackRate)
30
27
  : trimRight;
31
- const actualTrimLeft = trimLeft / playbackRate;
32
- const actualTrimRight = trimRightOrAssetDuration / playbackRate;
28
+ const actualTrimLeft = trimLeft * asset.playbackRate;
29
+ const actualTrimRight = trimRightOrAssetDuration * asset.playbackRate;
33
30
  return {
34
31
  filter: [
35
- (0, calculate_atempo_1.calculateATempo)(playbackRate),
32
+ (0, calculate_atempo_1.calculateATempo)(asset.playbackRate),
36
33
  `atrim=${stringifyTrim(actualTrimLeft)}:${stringifyTrim(actualTrimRight)}`,
37
34
  ],
38
35
  actualTrimLeft,
@@ -42,35 +39,36 @@ const trimAndSetTempo = ({ playbackRate, forSeamlessAacConcatenation, assetDurat
42
39
  // Otherwise, we first trim and then apply playback rate, as then the atempo
43
40
  // filter needs to do less work.
44
41
  if (!forSeamlessAacConcatenation) {
45
- const trimLeft = asset.trimLeft / fps + trimLeftOffset * asset.playbackRate;
46
- const trimRight = trimLeft + asset.duration / fps + trimRightOffset * asset.playbackRate;
42
+ const trimLeft = asset.trimLeft / fps;
43
+ const trimRight = (trimLeft + asset.duration / fps) * asset.playbackRate;
47
44
  const trimRightOrAssetDuration = assetDuration
48
45
  ? Math.min(trimRight, assetDuration)
49
46
  : trimRight;
47
+ const actualTrimLeft = trimLeft * asset.playbackRate;
50
48
  return {
51
49
  filter: [
52
- `atrim=${stringifyTrim(trimLeft)}:${stringifyTrim(trimRightOrAssetDuration)}`,
53
- (0, calculate_atempo_1.calculateATempo)(playbackRate),
50
+ `atrim=${stringifyTrim(actualTrimLeft)}:${stringifyTrim(trimRightOrAssetDuration)}`,
51
+ (0, calculate_atempo_1.calculateATempo)(asset.playbackRate),
54
52
  ],
55
- actualTrimLeft: trimLeft,
56
- audibleDuration: (trimRightOrAssetDuration - trimLeft) / playbackRate,
53
+ actualTrimLeft,
54
+ audibleDuration: (trimRightOrAssetDuration - actualTrimLeft) / asset.playbackRate,
57
55
  };
58
56
  }
59
57
  throw new Error('This should never happen');
60
58
  };
61
- const stringifyFfmpegFilter = ({ channels, startInVideo, volume, fps, playbackRate, assetDuration, allowAmplificationDuringRender, toneFrequency, chunkLengthInSeconds, forSeamlessAacConcatenation, trimLeftOffset, trimRightOffset, asset, }) => {
59
+ const stringifyFfmpegFilter = ({ channels, volume, fps, assetDuration, chunkLengthInSeconds, forSeamlessAacConcatenation, trimLeftOffset, trimRightOffset, asset, }) => {
62
60
  if (channels === 0) {
63
61
  return null;
64
62
  }
63
+ const { toneFrequency, startInVideo, trimLeft, playbackRate } = asset;
65
64
  const startInVideoSeconds = startInVideo / fps;
66
- if (assetDuration && asset.trimLeft / fps >= assetDuration) {
65
+ if (assetDuration && (trimLeft / fps) * playbackRate >= assetDuration) {
67
66
  return null;
68
67
  }
69
68
  if (toneFrequency !== null && (toneFrequency <= 0 || toneFrequency > 2)) {
70
69
  throw new Error('toneFrequency must be a positive number between 0.01 and 2');
71
70
  }
72
71
  const { actualTrimLeft, audibleDuration, filter: trimAndTempoFilter, } = trimAndSetTempo({
73
- playbackRate,
74
72
  forSeamlessAacConcatenation,
75
73
  assetDuration,
76
74
  trimLeftOffset,
@@ -82,7 +80,7 @@ const stringifyFfmpegFilter = ({ channels, startInVideo, volume, fps, playbackRa
82
80
  volume,
83
81
  fps,
84
82
  trimLeft: actualTrimLeft,
85
- allowAmplificationDuringRender,
83
+ allowAmplificationDuringRender: asset.allowAmplificationDuringRender,
86
84
  });
87
85
  const padAtEnd = chunkLengthInSeconds - audibleDuration - startInVideoSeconds;
88
86
  // Set as few filters as possible, as combining them can create noise
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/renderer",
3
- "version": "4.0.131",
3
+ "version": "4.0.133",
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.131"
21
+ "remotion": "4.0.133"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": ">=16.8.0",
@@ -40,13 +40,13 @@
40
40
  "vitest": "0.31.1"
41
41
  },
42
42
  "optionalDependencies": {
43
- "@remotion/compositor-darwin-x64": "4.0.131",
44
- "@remotion/compositor-linux-arm64-gnu": "4.0.131",
45
- "@remotion/compositor-darwin-arm64": "4.0.131",
46
- "@remotion/compositor-linux-arm64-musl": "4.0.131",
47
- "@remotion/compositor-linux-x64-musl": "4.0.131",
48
- "@remotion/compositor-win32-x64-msvc": "4.0.131",
49
- "@remotion/compositor-linux-x64-gnu": "4.0.131"
43
+ "@remotion/compositor-darwin-arm64": "4.0.133",
44
+ "@remotion/compositor-darwin-x64": "4.0.133",
45
+ "@remotion/compositor-linux-arm64-musl": "4.0.133",
46
+ "@remotion/compositor-linux-arm64-gnu": "4.0.133",
47
+ "@remotion/compositor-linux-x64-gnu": "4.0.133",
48
+ "@remotion/compositor-linux-x64-musl": "4.0.133",
49
+ "@remotion/compositor-win32-x64-msvc": "4.0.133"
50
50
  },
51
51
  "keywords": [
52
52
  "remotion",