simple-ffmpegjs 0.4.3 → 0.4.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simple-ffmpegjs",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "Declarative video composition for Node.js — define clips, transitions, text, and audio as simple objects, and let FFmpeg handle the rest.",
5
5
  "author": "Brayden Blackwell <braydenblackwell21@gmail.com> (https://github.com/Fats403)",
6
6
  "license": "MIT",
@@ -12,19 +12,23 @@ function buildBackgroundMusicMix(
12
12
  };
13
13
  }
14
14
 
15
+ // Prefer the caller-supplied visualEnd which accounts for transition
16
+ // compression, falling back to clip end values for audio-only projects.
15
17
  const projectDuration =
16
- project.videoOrAudioClips.filter(
17
- (c) => c.type === "video" || c.type === "image"
18
- ).length > 0
19
- ? Math.max(
20
- ...project.videoOrAudioClips
21
- .filter((c) => c.type === "video" || c.type === "image")
22
- .map((c) => c.end)
23
- )
24
- : Math.max(
25
- 0,
26
- ...backgroundClips.map((c) => (typeof c.end === "number" ? c.end : 0))
27
- );
18
+ typeof visualEnd === "number" && visualEnd > 0
19
+ ? visualEnd
20
+ : project.videoOrAudioClips.filter(
21
+ (c) => c.type === "video" || c.type === "image"
22
+ ).length > 0
23
+ ? Math.max(
24
+ ...project.videoOrAudioClips
25
+ .filter((c) => c.type === "video" || c.type === "image")
26
+ .map((c) => c.end)
27
+ )
28
+ : Math.max(
29
+ 0,
30
+ ...backgroundClips.map((c) => (typeof c.end === "number" ? c.end : 0))
31
+ );
28
32
 
29
33
  let filter = "";
30
34
  const bgLabels = [];
@@ -469,17 +469,11 @@ class SIMPLEFFMPEG {
469
469
  finalVideoLabel = vres.finalVideoLabel;
470
470
  hasVideo = vres.hasVideo;
471
471
 
472
- // Use the actual video output length for finalVisualEnd so that
473
- // audio trim and BGM duration match the real video stream length,
474
- // rather than an original-timeline position that may differ due to
475
- // transition compression.
472
+ // Use the actual video output length so that audio trim and BGM
473
+ // duration match the real video stream length, which may be shorter
474
+ // than the original-timeline positions due to transition compression.
476
475
  if (typeof vres.videoDuration === "number" && vres.videoDuration > 0) {
477
476
  totalVideoDuration = vres.videoDuration;
478
- }
479
- if (
480
- typeof vres.videoDuration === "number" &&
481
- vres.videoDuration > finalVisualEnd
482
- ) {
483
477
  finalVisualEnd = vres.videoDuration;
484
478
  }
485
479
  }